1
0
mirror of https://gitee.com/bitdance-team/chrome-extension synced 2025-10-07 16:35:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
chrome-extension/gitee_pomodoro/assets/js/popup.js
2022-01-30 14:12:52 +08:00

25 lines
604 B
JavaScript

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();
}