first commit

This commit is contained in:
编码猿
2025-02-04 19:16:43 +08:00
commit 53ce1dfa30
17 changed files with 415 additions and 0 deletions

1
js/.pydio Normal file
View File

@@ -0,0 +1 @@
c28add94-9a74-4b12-863a-833671d85ca6

76
js/newTab.js Normal file
View File

@@ -0,0 +1,76 @@
class NewTab {
constructor() {
// chrome.history.search({
// text: ''
// }, function (results) {
// console.log(results);
// })
this.input = document.querySelector(".search input");
this.input.focus();
this.ThemeClickChange();
this.SearchInput();
this.clearSearch();
}
clearSearch () {
var clear = document.querySelector(".clear");
console.log(clear);
clear.onclick = () => {
this.input.value = "";
}
}
/**
* 主题切换
*/
ThemeClickChange () {
var body = document.querySelector("body"),
theme = document.querySelector(".themeChange img");
// 当前为黑夜
if (localStorage.getItem("status") != null) {
body.className = "night";
theme.setAttribute("src", "./img/day.svg")
localStorage.setItem("status", "night")
}
theme.onclick = () => {
// 如果当前白天,切换为黑夜
if (body.classList.length == 0) {
body.className = "night";
theme.setAttribute("src", "./img/day.svg")
localStorage.setItem("status", "night")
} else {
body.className = "";
theme.setAttribute("src", "./img/night.svg");
localStorage.removeItem("status")
}
}
}
SearchInput() {
this.input.onkeydown = (event) => {
if (event.keyCode == 13) {
if (this.input.value.length != 0) {
window.open(`https://www.google.com/search?q=${this.input.value}`)
}
}
}
}
}
new NewTab()
// chrome.bookmarks.getTree(function (result) {
// console.log(result);
// })
// chrome.system.cpu.getInfo(function (res) {
// console.log(res);
// });