-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
23 lines (23 loc) · 832 Bytes
/
background.js
File metadata and controls
23 lines (23 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Initialize the extension state
chrome.runtime.onInstalled.addListener(function () {
chrome.storage.local.set({ extensionPaused: false });
});
// Listen for messages from the popup script to toggle the extension state
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
if (message.action === "toggleExtensionState") {
const extensionPaused = message.extensionPaused;
chrome.storage.local.set({ extensionPaused: extensionPaused }, function () {
console.log(
"Extension state changed:",
extensionPaused ? "paused" : "playing"
);
});
chrome.tabs.reload();
}
if (message.action === "pauseExtension") {
chrome.storage.local.set({ extensionPaused: true }, function () {
console.log("Extension paused");
});
chrome.tabs.reload();
}
});