diff options
Diffstat (limited to 'browsers/firefox/extension')
| -rw-r--r-- | browsers/firefox/extension/background.js | 34 | ||||
| -rw-r--r-- | browsers/firefox/extension/content.js | 15 | ||||
| -rw-r--r-- | browsers/firefox/extension/manifest.json | 22 |
3 files changed, 0 insertions, 71 deletions
diff --git a/browsers/firefox/extension/background.js b/browsers/firefox/extension/background.js deleted file mode 100644 index df0ee80..0000000 --- a/browsers/firefox/extension/background.js +++ /dev/null @@ -1,34 +0,0 @@ -let port = browser.runtime.connectNative("accent_color"); -let current = null; - -function broadcast(color) { - browser.tabs.query({}).then(tabs => { - for (let tab of tabs) { - browser.tabs.sendMessage(tab.id, {color}).catch(() => {}); - } - }); - browser.theme.update({colors: {toolbar: color}}); -} - -port.onMessage.addListener(msg => { - if (msg.color && msg.color !== current) { - current = msg.color; - broadcast(current); - } -}); - -function poll() { - try { - port.postMessage({query: "color"}); - } catch (e) { - // ignore - } -} -setInterval(poll, 1000); -poll(); - -browser.runtime.onMessage.addListener((msg, sender) => { - if (msg.request === "color") { - return Promise.resolve({color: current}); - } -}); diff --git a/browsers/firefox/extension/content.js b/browsers/firefox/extension/content.js deleted file mode 100644 index 118c7ee..0000000 --- a/browsers/firefox/extension/content.js +++ /dev/null @@ -1,15 +0,0 @@ -function apply(color) { - document.documentElement.style.setProperty("--accent-color", color); -} - -browser.runtime.onMessage.addListener(msg => { - if (msg.color) { - apply(msg.color); - } -}); - -browser.runtime.sendMessage({request: "color"}).then(msg => { - if (msg && msg.color) { - apply(msg.color); - } -}); diff --git a/browsers/firefox/extension/manifest.json b/browsers/firefox/extension/manifest.json deleted file mode 100644 index abcbe08..0000000 --- a/browsers/firefox/extension/manifest.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "manifest_version": 2, - "name": "Accent Color Updater", - "version": "0.1", - "description": "Updates CSS variable --accent-color using a native host", - "applications": { - "gecko": { - "id": "accent-color@example.com" - } - }, - "background": { - "scripts": ["background.js"] - }, - "permissions": ["nativeMessaging", "tabs", "<all_urls>"], - "content_scripts": [ - { - "matches": ["<all_urls>"], - "js": ["content.js"], - "run_at": "document_start" - } - ] -} |
