1
0
mirror of https://gitee.com/bitdance-team/chrome-extension synced 2025-10-08 00:45:13 +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();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -0,0 +1,29 @@
{
"name":"助手-pomodoro",
"description":"manage your time",
"version":"0.1",
"manifest_version":3,
"background":{
"service_worker":"./assets/js/background.js"
},
"options_page": "./assets/html/options.html",
"permissions":["storage","activeTab", "scripting","notifications","alarms", "contextMenus"],
"action":{
"default_popup":"popup.html",
"default_icon":{
"16": "./images/pomo_16.png",
"48": "./images/pomo_48.png",
"128": "./images/pomo_128.png"
}
},
"icons": {
"16": "./images/pomo_16.png",
"48": "./images/pomo_48.png",
"128": "./images/pomo_128.png"
},
"content_scripts":[{
"matches":["https://*/*","http://*/*"],
"js":["./assets/js/common/jquery.min.js"]
}]
}

67
gitee_pomodoro/popup.html Normal file
View File

@@ -0,0 +1,67 @@
<!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>my todo list</title>
<link rel="stylesheet" href="./assets/css/popup.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400&display=swap" rel="stylesheet">
</head>
<body>
<audio id="audio">
<source src="./src/alarm.mp3" type="audio/mp3">
</audio>
<header id="timer">
<div class="buttons">
<div class="slider">
<span class="left">&lt;</span>
<span class="right">&gt;</span>
</div>
<div class="button" id="pomodoro-btn">开始专注</div>
<!-- <div class="button" id="short-break-btn">Short Break</div>
<div class="button" id="long-break-btn">Long Break</div> -->
</div>
<div id="countdown">
<span>25:00</span>
</div>
<div id="start-btn">Start</div>
<div id="reset-btn">Reset</div>
</header>
<div id="worklist">
<div id="current-task-display">
<div id="message">You are working on:</div>
<div id="selected-task"></div>
</div>
<div id="tasks-container">
<ul id="tasks"></ul>
<div id="add-task-btn">Add Task</div>
<form id="task-form" class="hide">
<input id="text" type="text" placeholder="What are you working on?">
<label for="est-pomodoro">Est Rounds</label>
<input id="est-pomodoro" type="number">
<div id="btn-container">
<button id="save" type="submit">Save</button>
<button id="cancel" type="button">Cancel</button>
</div>
</form>
</div>
</div>
<footer>
<div class="settings">
<a href="./assets/html/options.html">settings</a>
</div>
</footer>
<script src="./assets/js/"></script>
</body>
</html>

Binary file not shown.