diff --git a/background.js b/background.js index 44879af..7207b8a 100755 --- a/background.js +++ b/background.js @@ -100,6 +100,7 @@ var customSites = {}; var customSites_domains = []; var updatedSites = {}; var updatedSites_new = []; +var updatedSites_domains_new = []; var excludedSites = []; function setDefaultOptions() { @@ -295,6 +296,7 @@ ext_api.storage.local.get({ customSites = items.sites_custom; customSites_domains = Object.values(customSites).map(x => x.domain); updatedSites = items.sites_updated; + updatedSites_domains_new = Object.values(updatedSites).filter(x => (x.domain && !defaultSites_domains.includes(x.domain) || x.group)).map(x => x.group ? x.group.filter(y => !defaultSites_domains.includes(y)) : x.domain).flat(); var ext_version_old = items.ext_version_old; optin_setcookie = items.optIn; optin_update = items.optInUpdate; @@ -385,6 +387,7 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) { if (key === 'sites_updated') { var sites_updated = storageChange.newValue ? storageChange.newValue : {}; updatedSites = sites_updated; + updatedSites_domains_new = Object.values(updatedSites).filter(x => (x.domain && !defaultSites_domains.includes(x.domain) || x.group)).map(x => x.group ? x.group.filter(y => !defaultSites_domains.includes(y)) : x.domain).flat(); updatedSites_new = Object.keys(updatedSites).filter(x => updatedSites[x].domain && !defaultSites_domains.includes(updatedSites[x].domain)); if (updatedSites_new.length > 0) { if (enabledSites.includes('#options_enable_new_sites')) { @@ -996,12 +999,13 @@ function updateBadge(activeTab) { badgeText = '^' + badgeText; let isDefaultSite = matchUrlDomain(defaultSites_domains, currentUrl); let isCustomSite = matchUrlDomain(customSites_domains, currentUrl); - if (!isDefaultSite && isCustomSite) { + let isUpdatedSite = matchUrlDomain(updatedSites_domains_new, currentUrl); + if (!isDefaultSite && (isCustomSite || isUpdatedSite)) { ext_api.permissions.contains({ - origins: ['*://*.' + isCustomSite + '/*'] + origins: ['*://*.' + (isCustomSite || isUpdatedSite) + '/*'] }, function (result) { if (!result) - badgeText = enabledSites.includes(isCustomSite) ? 'C' : ''; + badgeText = enabledSites.includes(isCustomSite || isUpdatedSite) ? 'C' : ''; if (color && badgeText) ext_api.browserAction.setBadgeBackgroundColor({color: color}); ext_api.browserAction.setBadgeText({text: badgeText}); @@ -1189,6 +1193,9 @@ ext_api.runtime.onMessage.addListener(function (message, sender) { if (message.request === 'site_switch') { site_switch(); } + if (message.request === 'check_sites_updated') { + check_sites_updated(); + } if (message.request === 'popup_show_toggle') { ext_api.tabs.query({ active: true, diff --git a/changelog.txt b/changelog.txt index 0bd7838..42aa6dc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,7 @@ Fix Live Law (permission) Fix The New Yorker (amp) Fix TheTimes.co.uk (only link to archive.today) Remove Saechsische Zeitung (obsolete) +Updated sites: check (options) & missing permission (badge) * v2.4.5.0 (2021-11-21) Add Advance Local (local USA) diff --git a/contentScript.js b/contentScript.js index 2523a4c..8e2206f 100755 --- a/contentScript.js +++ b/contentScript.js @@ -94,24 +94,25 @@ function amp_unhide_access_hide(amp_access = '', amp_access_not = '', amp_ads_se // custom sites: try to unhide text on amp-page if ((bg2csData !== undefined) && bg2csData.amp_unhide) { window.setTimeout(function () { - let amp_page = document.querySelector('script[src^="https://cdn.ampproject.org/"]') && (window.location.hostname.match(/\/amp(\d)?\./) || window.location.pathname.match(/(\/amp\/|(_|-|\.)amp\.html$|-amp\d|(\.|\/)amp$)/) || window.location.search.match(/\?(output(Type)?=)?amp/)); - if (amp_page) { + let amp_page_hide = document.querySelector('script[src*="/amp-access-"], script[src*="/amp-subscriptions-"]'); + if (amp_page_hide) { amp_unhide_subscr_section(); amp_unhide_access_hide(); amp_iframes_replace(); } - }, 500); // Delay (in milliseconds) + }, 100); // Delay (in milliseconds) } // updated sites: amp-redirect if ((bg2csData !== undefined) && bg2csData.amp_redirect) { window.setTimeout(function () { - let amp_page = document.querySelector('script[src^="https://cdn.ampproject.org/"]') && (window.location.hostname.match(/\/amp(\d)?\./) || window.location.pathname.match(/(\/amp\/|(_|-|\.)amp\.html$|-amp\d|(\.|\/)amp$)/) || window.location.search.match(/\?(output(Type)?=)?amp/)); + let amp_script = document.querySelector('script[src^="https://cdn.ampproject.org/"]'); + let amphtml = document.querySelector('link[rel="amphtml"]'); + let amp_page = amp_script && !amphtml; if (!amp_page) { let paywall = true; if (bg2csData.amp_redirect.paywall) paywall = document.querySelector(bg2csData.amp_redirect.paywall); - let amphtml = document.querySelector('link[rel="amphtml"]'); if (paywall && amphtml) { removeDOMElement(paywall); window.location.href = amphtml.href; diff --git a/options/options.html b/options/options.html index 9ae7b52..3017c15 100644 --- a/options/options.html +++ b/options/options.html @@ -28,6 +28,7 @@
+ diff --git a/options/options.js b/options/options.js index f989af7..4c4d4d0 100644 --- a/options/options.js +++ b/options/options.js @@ -129,6 +129,11 @@ function closeButton() { open(location).close(); } +function check_sites_updated() { + ext_api.runtime.sendMessage({request: 'check_sites_updated'}); + location.reload(); +} + function compareKey(firstStr, secondStr) { return firstStr.toLowerCase().replace(/\s\(.*\)/, '') === secondStr.toLowerCase().replace(/\s\(.*\)/, ''); } @@ -138,3 +143,4 @@ document.getElementById('save').addEventListener('click', save_options); document.getElementById('select-all').addEventListener('click', selectAll); document.getElementById('select-none').addEventListener('click', selectNone); document.getElementById("button-close").addEventListener('click', closeButton); +document.getElementById('sites_updated').addEventListener('click', check_sites_updated);