diff --git a/README.md b/README.md index 2320255..4a09056 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,8 @@ By default BPC has limited permissions, but you can opt-in to enable custom site ### Update Check for updates (in about:addons) and allow permissions for newly supported sites (else no update will be installed).\ -You can also check for update of site rules at startup (opt-in). +You can also check for update of site rules at startup (opt-in).\ +For new sites you also have to opt-in to custom sites/request permissions for new domains (or wait for new release). #### Android On Android this add-on doesn't work with latest Firefox v84 (Fenix); it only supports a number of 'recommended' add-ons (for now).\ diff --git a/background.js b/background.js index db95f90..a580c9a 100644 --- a/background.js +++ b/background.js @@ -137,7 +137,9 @@ function set_rules(sites, sites_updated, sites_custom) { rule = defaultSites[site]; if (sites_updated.hasOwnProperty(site)) rule = sites_updated[site]; - } else if (sites_custom.hasOwnProperty(site)) { // custom sites + } else if (sites_updated.hasOwnProperty(site)) { // updated (new) sites + rule = sites_updated[site]; + } else if (sites_custom.hasOwnProperty(site)) { // custom (new) sites rule = sites_custom[site]; custom = true; } else @@ -278,8 +280,9 @@ ext_api.storage.local.get({ var sites = items.sites; optionSites = sites; var sites_default = items.sites_default; - var sites_custom = items.sites_custom; - var sites_updated = items.sites_updated; + customSites = items.sites_custom; + customSites_domains = Object.values(customSites).map(x => x.domain); + updatedSites = items.sites_updated; var ext_version_old = items.ext_version_old; optin_setcookie = items.optIn; optin_update = items.optInUpdate; @@ -294,9 +297,9 @@ ext_api.storage.local.get({ // Enable new sites by default (opt-in) if (ext_version > ext_version_old) { if (enabledSites.includes('#options_enable_new_sites')) { - var sites_new = Object.keys(defaultSites).filter(x => !defaultSites[x].domain.match(/^(#options_|###$)/) && !sites_default.includes(x)); + let sites_new = Object.keys(defaultSites).filter(x => !defaultSites[x].domain.match(/^(#options_|###$)/) && !sites_default.includes(x)); for (let site_new of sites_new) { - sites[site_new] = defaultSites[site_new]; + sites[site_new] = defaultSites[site_new].domain; } ext_api.storage.local.set({ sites: sites @@ -309,9 +312,6 @@ ext_api.storage.local.get({ }); } - customSites = sites_custom; - customSites_domains = Object.values(sites_custom).map(x => x.domain); - updatedSites = sites_updated; disabledSites = defaultSites_domains.concat(customSites_domains).filter(x => !enabledSites.includes(x) && x !== '###'); add_grouped_enabled_domains(grouped_sites); set_rules(sites, updatedSites, customSites); diff --git a/changelog.txt b/changelog.txt index 64d84a2..71d667b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ Changelog Bypass Paywalls Clean - Firefox Post-release Fix Nikkei Asian Review (cookies) Fix Repubblica sites (re-enable Googlebot) +Add rules for new sites (opt-in to custom sites) Check for update version on startup/options (now opt-out) * v2.4.3.0 (2021-11-07) diff --git a/manifest.json b/manifest.json index 7e6f637..b9831f5 100644 --- a/manifest.json +++ b/manifest.json @@ -558,5 +558,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.4.3.3" + "version": "2.4.3.4" } \ No newline at end of file diff --git a/options/options.js b/options/options.js index a4d417a..eb338b9 100644 --- a/options/options.js +++ b/options/options.js @@ -31,61 +31,71 @@ function save_options() { function renderOptions() { var labelEl; ext_api.storage.local.get({ - sites: {}, sites_custom: {}, sites_excluded: [] - }, function(items) { + sites: {}, + sites_updated: {}, + sites_custom: {}, + sites_excluded: [] + }, function (items) { var sites = items.sites; + var sites_updated = items.sites_updated; + var sites_custom = items.sites_custom; var sites_excluded = items.sites_excluded; var sitesEl = document.getElementById('bypass_sites'); - for (var key in defaultSites) { - if (!defaultSites.hasOwnProperty(key)) { - continue; + var site_types = { + "updated": { + sites: sites_updated, + title: '* Updated (new) Sites (opt-in to custom sites)', + default_sites: false + }, + "default": { + sites: defaultSites, + title: '* Default Sites', + default_sites: true + }, + "custom": { + sites: sites_custom, + title: '* Custom (new) Sites', + default_sites: false } - var value = defaultSites[key].domain; + }; + var first = true; + for (let site_type in site_types) { + if (!first) + labelEl.appendChild(document.createElement('hr')); + else + first = false; labelEl = document.createElement('label'); - var inputEl = document.createElement('input'); - inputEl.type = 'checkbox'; - inputEl.dataset.key = key; - inputEl.dataset.value = value; - inputEl.checked = Object.keys(sites).some(title => compareKey(title, key)) && !sites_excluded.includes(value); - if (value !== '###') { - labelEl.appendChild(inputEl); - } else { - labelEl.appendChild(document.createElement('hr')); - labelEl.setAttribute('style', ' font-weight: bold;'); - } - labelEl.appendChild(document.createTextNode(' ' + key)); - sitesEl.appendChild(labelEl); - } - // custom - labelEl.appendChild(document.createElement('hr')); - labelEl = document.createElement('label'); - labelEl.setAttribute('style', ' font-weight: bold;'); - labelEl.appendChild(document.createTextNode('* Custom Sites')); - sitesEl.appendChild(labelEl); - var sites_custom = items.sites_custom; - for (var key in sites_custom) { - var domain = sites_custom[key]['domain']; - if (defaultSites.hasOwnProperty(key) || defaultSites_domains.includes(domain)) { - continue; - } - labelEl = document.createElement('label'); - var inputEl = document.createElement('input'); - inputEl.type = 'checkbox'; - inputEl.dataset.key = key; - inputEl.dataset.value = domain; - inputEl.checked = Object.keys(sites).some(title => compareKey(title, key)) && !sites_excluded.includes(domain); - if (value !== '' && value !== '###') { - labelEl.appendChild(inputEl); - } - labelEl.appendChild(document.createTextNode(' '+key)); + labelEl.setAttribute('style', ' font-weight: bold;'); + labelEl.appendChild(document.createTextNode(site_types[site_type].title)); sitesEl.appendChild(labelEl); + let sites_arr = site_types[site_type].sites + for (let key in sites_arr) { + let domain = sites_arr[key]['domain']; + if (!site_types[site_type].default_sites && (defaultSites.hasOwnProperty(key) || defaultSites_domains.includes(domain))) { + continue; + } + labelEl = document.createElement('label'); + let inputEl = document.createElement('input'); + inputEl.type = 'checkbox'; + inputEl.dataset.key = key; + inputEl.dataset.value = domain; + inputEl.checked = Object.keys(sites).some(title => compareKey(title, key)) && !sites_excluded.includes(domain); + if (domain !== '' && domain !== '###') { + labelEl.appendChild(inputEl); + } else { + labelEl.appendChild(document.createElement('hr')); + labelEl.setAttribute('style', ' font-weight: bold;'); + } + labelEl.appendChild(document.createTextNode(' ' + key)); + sitesEl.appendChild(labelEl); + } } // excluded labelEl.appendChild(document.createElement('hr')); labelEl = document.createElement('label'); labelEl.setAttribute('style', ' font-weight: bold;'); labelEl.appendChild(document.createTextNode('* Excluded Sites (ignored when checked in list)')); - sitesEl.appendChild(labelEl); + sitesEl.appendChild(labelEl); labelEl = document.createElement('label'); labelEl.appendChild(document.createTextNode(sites_excluded.join())); sitesEl.appendChild(labelEl); diff --git a/options/options_custom.html b/options/options_custom.html index 017cf1f..55d6999 100644 --- a/options/options_custom.html +++ b/options/options_custom.html @@ -24,7 +24,7 @@ Custom sites (new) are enabled automatically in (cookies will be removed by default unless you enable allow_cookies).
If you want to use custom sites (for non-listed sites) enable it in Custom sites enabled:
- You can also just request permissions for the custom sites you added yourself (below).
+ You can also just request permissions for the custom sites you added yourself & post-release added sites (below).
On Android: to enable custom sites you need the 'custom' add-on version (with access to all sites): Bypass Paywalls Clean (custom)

@@ -48,7 +48,7 @@
- permissions granted (for all in custom list): + permissions granted (for all in custom list + updated):
diff --git a/options/options_custom.js b/options/options_custom.js index 894aa81..364f9ef 100644 --- a/options/options_custom.js +++ b/options/options_custom.js @@ -224,9 +224,12 @@ var perm_origins; // Restores checkbox input states using the preferences stored in ext_api.storage. function renderOptions() { ext_api.storage.local.get({ - sites_custom: {} + sites_custom: {}, + sites_updated: {} }, function (items) { var sites_custom = items.sites_custom; + var sites_updated = items.sites_updated; + var sites_updated_new = Object.keys(sites_updated).filter(x => !defaultSites_domains.includes(x.domain)); var sitesEl = document.getElementById('bypass_sites'); sitesEl.innerHTML = ''; var labelEl = document.createElement('label'); @@ -315,6 +318,12 @@ function renderOptions() { } labelEl.appendChild(selectEl); custom_sitesEl.appendChild(labelEl); + + for (let key in sites_updated_new) { + let domain = sites_updated_new[key]['domain']; + if (!perm_origins.includes(domain)) + perm_origins.push('*://*.' + domain + '/*'); + } var perm_custom = document.getElementById('perm-custom'); ext_api.permissions.contains({