diff --git a/background.js b/background.js index 243aeae..6e7bffa 100755 --- a/background.js +++ b/background.js @@ -840,6 +840,7 @@ function clear_cookies() { }); } +var chrome_scheme = 'light'; ext_api.runtime.onMessage.addListener(function (message, sender) { // check storage for opt in if (message.request === 'optin') { @@ -866,6 +867,13 @@ ext_api.runtime.onMessage.addListener(function (message, sender) { } }); } + if (message.scheme && message.scheme !== chrome_scheme) { + let icon_path = {path: {'128': 'bypass.png'}}; + if (message.scheme === 'dark') + icon_path = {path: {'128': 'bypass-dark.png'}}; + ext_api.browserAction.setIcon(icon_path); + chrome_scheme = message.scheme; + } }); // show the tab if we haven't registered the user reacting to the prompt. diff --git a/bypass-dark.png b/bypass-dark.png new file mode 100644 index 0000000..54af653 Binary files /dev/null and b/bypass-dark.png differ diff --git a/changelog.txt b/changelog.txt index 640aeab..0bff34a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ Post-release Add Deutsche Wirtschafts Nachrichten Add WirtschaftsWoche (Germany) Fix-update Quartz (newsletter) +Icon for dark/incognito mode (Chrome) * v1.9.2.0 (2020-10-25) Add Foreign Affairs diff --git a/contentScript.js b/contentScript.js index 9914820..630219c 100755 --- a/contentScript.js +++ b/contentScript.js @@ -28,6 +28,13 @@ ext_api.runtime.onMessage.addListener(function (message, sender) { // ask for opt-in confirmation ext_api.runtime.sendMessage({request: 'optin'}); +// message for dark or incognito mode (chrome) +if (typeof browser !== 'object') + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches || ext_api.extension.inIncognitoContext) + ext_api.runtime.sendMessage({scheme: 'dark'}); + else + ext_api.runtime.sendMessage({scheme: 'light'}); + // Content workarounds/domain if (matchDomain("thesaturdaypaper.com.au")) { diff --git a/manifest.json b/manifest.json index c78575d..bccddf3 100644 --- a/manifest.json +++ b/manifest.json @@ -324,5 +324,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.9.2.2" + "version": "1.9.2.3" } \ No newline at end of file