1
0
mirror of https://gitee.com/bitdance-team/chrome-extension synced 2025-10-08 08:45:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

番茄钟初始界面

This commit is contained in:
simonzhangs
2022-01-30 14:12:52 +08:00
parent cbf8a21ddb
commit 839518f25d
14 changed files with 314 additions and 1 deletions

View File

View File

@@ -0,0 +1,153 @@
/* @import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500&display=swap'); */
body {
/* background-color: rgb(51, 11, 116); */
background: url(../../images/pomo1.png) no-repeat;
background-image: "../../";
/* color: white; */
font-family: 'Fira Sans', sans-serif;
margin: 0;
padding: 0;
width: 280px;
height: 500px;
}
#timer {
/* background-color: rgb(77, 25, 161); */
padding: 10px 0 20px;
}
.buttons {
width: fit-content;
margin: auto;
font-size: 20px;
color: rgb(169, 172, 172);
}
.buttons .slider{
color: rgb(247, 226, 230);
}
.button {
float: left;
margin: 5px;
cursor: pointer;
padding: 8px;
}
/*计数部分*/
#countdown {
clear: both;
width: fit-content;
margin: auto;
font-size: 60px;
font-weight: 500;
padding: 20px;
color: aliceblue;
}
#start-btn {
width: 40px;
margin: 10px auto 0;
padding: 10px 30px;
text-align: center;
background-color: rgb(0, 179, 12);
cursor: pointer;
}
#reset-btn {
width: 40px;
margin: 10px auto 0;
padding: 10px 30px;
text-align: center;
background-color: rgb(187, 0, 0);
cursor: pointer;
}
.selected {
background-color: rgb(33, 10, 70);;
}
#current-task-display {
width: 100%;
padding-top: 30px;
margin: auto;
text-align: center;
}
#tasks-container {
margin: auto;
}
ul {
padding: 0;
}
li {
list-style-type: none;
padding: 20px 10px;
margin-bottom: 5px;
background-color: white;
color: black;
}
.right {
float: right;
}
.delete-btn {
padding: 10px;
background-color: rgb(33, 10, 70);
color: white;
margin-left: 10px;
cursor: pointer;
}
#add-task-btn {
width: 200px;
margin: 0 auto 10px;
background-color: rgb(33, 10, 70);
padding: 8px;
cursor: pointer;
text-align: center;
}
#task-form {
clear: both;
background-color: white;
color: black;
height: 100px;
padding: 15px;
}
#text {
border: none;
width: 95%;
font-size: 18px;
margin-bottom: 5px;
}
#est-pomodoro {
margin: 10px 10px 0;
width: 50px;
padding: 5px;
}
#save, #cancel {
border: none;
width: 60px;
padding: 8px;
margin-left: 5px;
cursor: pointer;
float: right;
}
.hide {
display: none;
}
footer .settings{
position: absolute;
bottom: 5px;
right: 5px;
}

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>this is a settings page</h1>
</body>
</html>

View File

@@ -0,0 +1,23 @@
// 用户首次安装插件时执行一次,后面不会再重新执行(除非用户重新安装插件)
chrome.runtime.onInstalled.addListener(() => {
// 插件功能安装默认启用
chrome.storage.sync.set({
linkOpen: true,
});
});
// 监听tab页面加载状态添加处理事件
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
// 设置判断条件,页面加载完成才添加事件,否则会导致事件重复添加触发多次
if (changeInfo.status === "complete" && /^http/.test(tab.url)) {
chrome.scripting
.executeScript({
target: { tabId: tabId },
files: ["./content-script.js"],
})
.then(() => {
console.log("INJECTED SCRIPT SUCC.");
})
.catch((err) => console.log(err));
}
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,25 @@
const btn = document.querySelector("#switch");
chrome.storage.sync.get("linkOpen", ({ linkOpen }) => {
btn.checked = linkOpen;
});
btn.addEventListener("change", () => {
if (btn.checked) {
chrome.storage.sync.set({ linkOpen: true });
} else {
chrome.storage.sync.set({ linkOpen: false });
}
// 获取当前tab窗口
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.scripting.executeScript({
target: { tabId: tabs[0].id },
func: refreshPage,
});
});
});
// 刷新页面
function refreshPage() {
window.location.reload();
}