Download background.js from akmall/23jin: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/akmall/23jin/resolve/main/background.js
- Command line
-
hf download hf://akmall/23jin/background.js
-
curl -L -o background.js https://huggingface.co/akmall/23jin/resolve/main/background.js
1.26 kB
| chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { | |
| console.log("Background received message:", message.action); | |
| if (message.action === "updateInterval") { | |
| chrome.storage.local.set({ breakInterval: message.interval }, () => { | |
| chrome.tabs.query({}, (tabs) => { | |
| tabs.forEach(tab => { | |
| chrome.tabs.sendMessage(tab.id, { action: "updateInterval", interval: message.interval }); | |
| }); | |
| }); | |
| sendResponse({ success: true }); | |
| }); | |
| return true; // Indicates async response | |
| } else if (message.action === "updateBubbleColor") { | |
| console.log("Relaying color update:", message.color); | |
| chrome.tabs.query({}, (tabs) => { | |
| tabs.forEach(tab => { | |
| chrome.tabs.sendMessage(tab.id, { action: "updateBubbleColor", color: message.color }); | |
| }); | |
| }); | |
| sendResponse({ success: true }); | |
| } else if (message.action === "toggleMute") { | |
| console.log("Relaying mute update:", message.muted); | |
| chrome.tabs.query({}, (tabs) => { | |
| tabs.forEach(tab => { | |
| chrome.tabs.sendMessage(tab.id, { action: "toggleMute", muted: message.muted }); | |
| }); | |
| }); | |
| sendResponse({ success: true }); | |
| } | |
| return true; // Ensures async handling | |
| }); |