From d1c0af7b55712740ae616744f5cbc3df782c4017 Mon Sep 17 00:00:00 2001 From: Aurelien David Date: Sun, 26 Jan 2020 14:07:00 +0100 Subject: [PATCH] use option to use color icon in url bar (#33) --- background.js | 20 +++++++++++++++----- icons/rss-19.png | Bin 0 -> 397 bytes icons/rss-38.png | Bin 0 -> 821 bytes settings/options.html | 2 ++ settings/options.js | 4 +++- 5 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 icons/rss-19.png create mode 100644 icons/rss-38.png diff --git a/background.js b/background.js index f6409fb..531ac68 100644 --- a/background.js +++ b/background.js @@ -49,14 +49,24 @@ browser.webRequest.onHeadersReceived.addListener( function handleMessage(request, sender, sendResponse) { + browser.storage.sync.get({orangeIcon: false}).then(function(options){ - let popup = new URL(browser.runtime.getURL('popup/popup.html')); - popup.searchParams.set('feeds', JSON.stringify(request)); + let popup = new URL(browser.runtime.getURL('popup/popup.html')); + popup.searchParams.set('feeds', JSON.stringify(request)); - browser.pageAction.setPopup( {tabId: sender.tab.id, popup: popup.toString() }); - browser.pageAction.show(sender.tab.id); + if (options.orangeIcon) { + browser.pageAction.setIcon({tabId: sender.tab.id, path: { + "19": "icons/rss-19.png", + "38": "icons/rss-38.png" + } + }); + } + browser.pageAction.setPopup( {tabId: sender.tab.id, popup: popup.toString() }); + browser.pageAction.show(sender.tab.id); - //sendResponse({response: "Response from background script to tab " + sender.tab.url , id: sender.tab.id }); + //sendResponse({response: "Response from background script to tab " + sender.tab.url , id: sender.tab.id }); + + }); } browser.runtime.onMessage.addListener(handleMessage); diff --git a/icons/rss-19.png b/icons/rss-19.png new file mode 100644 index 0000000000000000000000000000000000000000..277e422717e427f7ef9c4b8a0d5cbcbbded1710c GIT binary patch literal 397 zcmV;80doF{P)V-xShJ77B)5(g2dYsh!U09*@_S$K`gvP zO^Cv-vT^3OSeBEsyRKQ2fdj)o=X^8spBcl=n>9$Gx{a3wvuwZ;2*L!-{}ECsf;i=J|TjNr9>FWaG;xR8U;yYxY2zXC|;c z4tzFw(d{Yayg!m&Ep^y{iwzD8eOw;my3D1Vto_xWuW=7Uz4<`;!E6GoFhvPhJ5=b_ z;t4ia&Tj2DS?p+DOzSjHadV50Q+B=7q5KLEqcCYxd@qSi6Imp+JeaI4w5}>LCxVBTgI)8pChO63S)i##%b*9Ob zQw(-vFA$%%9?;XuKI|G{bxHf$$!cNpwYA$Mz^XTkv(VGZX07>%SfAe5-+K7ESAGew z(O&UI06ws0;dX}$C>ofl37nLSyb=%pjy{O=8KR&kV{Kb4-bVed$nbzjY zjVzdNEnhnuV&|a9Qp(N;ds8nCjz{^Mt*Eh0!>YGi60~I*z$gL!eCG$(mx|}w>@UHE zX}Z`PUq=fi#swunM=dZnoj7Qu8}Qp~uDSwD4J9&^?pl#m7x~TC=_@4%?4nEllu*KV z2fEyzq&&KN!E`m`d2otcUVw9ldllncDcScIUT4$vr2AJa00000NkvXXu0mjf;bDY* literal 0 HcmV?d00001 diff --git a/settings/options.html b/settings/options.html index 694e201..ba5c5ed 100644 --- a/settings/options.html +++ b/settings/options.html @@ -15,6 +15,8 @@

+ +
diff --git a/settings/options.js b/settings/options.js index bb14884..ed5f1fc 100644 --- a/settings/options.js +++ b/settings/options.js @@ -10,6 +10,7 @@ function saveOptions(e) { preventPreview: document.querySelector("#preventPreview").checked, fullPreview: document.querySelector("#fullPreview").checked, doAuthor: document.querySelector("#doAuthor").checked, + orangeIcon: document.querySelector("#orangeIcon").checked, enableCss: document.querySelector("#enableCss").checked, customCss: document.querySelector("#customCss").value }); @@ -27,6 +28,7 @@ function restoreOptions() { document.querySelector("#preventPreview").checked = result.preventPreview; document.querySelector("#fullPreview").checked = result.fullPreview; document.querySelector("#doAuthor").checked = result.doAuthor; + document.querySelector("#orangeIcon").checked = result.orangeIcon; document.querySelector("#enableCss").checked = result.enableCss; document.querySelector("#customCss").value = result.customCss; } @@ -43,6 +45,7 @@ function restoreOptions() { preventPreview: false, fullPreview: false, doAuthor: false, + orangeIcon: false, enableCss: false, customCss: null }); @@ -57,4 +60,3 @@ document.addEventListener("DOMContentLoaded", restoreOptions); document.querySelectorAll('.validate').forEach((elem) => { elem.addEventListener('change', saveOptions); }); -