dont-stop/background.js

20 lines
688 B
JavaScript
Raw Normal View History

2023-02-11 10:05:14 +09:00
chrome.runtime.onInstalled.addListener(() => {
chrome.storage.local.set({ isEnabled: false });
});
chrome.commands.onCommand.addListener((command) => {
if (command === "toggle-content-script") {
chrome.storage.local.get(['isEnabled'], (result) => {
const isEnabled = !result.isEnabled;
chrome.storage.local.set({ isEnabled }, () => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
for (const tab of tabs) {
chrome.tabs.reload(tab.id);
break;
}
});
});
});
}
});