diff --git a/background.js b/background.js index d25efef..c69fa49 100644 --- a/background.js +++ b/background.js @@ -723,6 +723,9 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) { } } } + if (key === 'version_new') { + version_new = storageChange.newValue; + } // reset disableJavascriptOnListedSites eventListener ext_api.webRequest.onBeforeRequest.removeListener(disableJavascriptOnListedSites); ext_api.webRequest.handlerBehaviorChanged(); @@ -1193,6 +1196,8 @@ function updateBadge(activeTab) { badgeText = 'OFF'; color = 'blue'; } + if (version_new) + badgeText = '^' + badgeText; let isDefaultSite = matchUrlDomain(defaultSites_domains, currentUrl); let isCustomSite = matchUrlDomain(customSites_domains, currentUrl); if (!isDefaultSite && isCustomSite) { @@ -1200,7 +1205,7 @@ function updateBadge(activeTab) { origins: ['*://*.' + isCustomSite + '/*'] }, function (result) { if (!result) - badgeText = ''; + badgeText = enabledSites.includes(isCustomSite) ? 'C' : ''; if (color && badgeText) ext_api.browserAction.setBadgeBackgroundColor({color: color}); ext_api.browserAction.setBadgeText({text: badgeText}); @@ -1213,6 +1218,30 @@ function updateBadge(activeTab) { } } +var version_new; +check_update(); +function check_update() { + var manifestData = ext_api.runtime.getManifest(); + var manifest_new = 'https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/raw/master/manifest.json'; + fetch(manifest_new) + .then(response => { + if (response.ok) { + response.json().then(json => { + ext_api.management.getSelf(function (result) { + var installType = result.installType; + var version_len = (installType === 'development') ? 7 : 5; + version_new = json['version']; + if (version_new.substring(0, version_len) <= manifestData.version.substring(0, version_len)) + version_new = ''; + ext_api.storage.local.set({ + version_new: version_new + }); + }); + }) + } + }); +} + function site_switch() { ext_api.tabs.query({ active: true, diff --git a/changelog.txt b/changelog.txt index ccea2a9..1149f37 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,7 @@ Add Levante-EMV (Spain) Add L'Oeil de la Photographie (fr/en) Add The New Atlantis Update custom sites (optional: only permissions for added sites) +Update badge (notification: update & custom permissions) * v2.1.8.0 (2021-04-25) Add Il Giorno (Italy) diff --git a/manifest.json b/manifest.json index 6642963..3303c3b 100644 --- a/manifest.json +++ b/manifest.json @@ -508,5 +508,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.1.8.5" + "version": "2.1.8.6" } \ No newline at end of file diff --git a/options/options_custom.js b/options/options_custom.js index f38f785..7b814de 100644 --- a/options/options_custom.js +++ b/options/options_custom.js @@ -203,7 +203,7 @@ function remove_permissions() { var perm_custom = document.getElementById('perm-custom'); var custom_enabled = document.getElementById('custom-enabled'); ext_api.permissions.remove({ - origins: [""] + origins: perm_origins }, function (removed) { if (removed) { perm_custom.innerText = 'NO'; diff --git a/options/version.js b/options/version.js index d49f1c6..71dfd85 100644 --- a/options/version.js +++ b/options/version.js @@ -20,6 +20,9 @@ fetch(manifest_new) var version_len = (installType === 'development') ? 7 : 5; var version_new = json['version']; if (version_new.substring(0, version_len) > manifestData.version.substring(0, version_len)) { + ext_api.storage.local.set({ + version_new: version_new + }); anchorEl = document.createElement('a'); anchorEl.innerText = 'New release v' + version_new; if (manifestData.applications && manifestData.applications.gecko.id.includes('magnolia')) { @@ -51,4 +54,4 @@ fetch(manifest_new) anchorEl.target = '_blank'; versionString_new.appendChild(anchorEl); } -}); \ No newline at end of file +});