Add rules for new sites (opt-in to custom sites)
This commit is contained in:
parent
0846862c60
commit
6ba451e392
@ -68,7 +68,8 @@ Visit the [Firefox repository](https://gitlab.com/magnolia1234/bypass-paywalls-f
|
||||
### Update
|
||||
For crx-installation: check for updates (in chrome://extensions).\
|
||||
For zip-installation (load unpacked/developer mode): unzip files to installation folder or use a Git(Hub)-client to clone the extension (locally).\
|
||||
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).
|
||||
|
||||
### List of supported websites
|
||||
|
||||
|
@ -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);
|
||||
|
@ -4,6 +4,7 @@ Changelog Bypass Paywalls Clean - Chrome
|
||||
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)
|
||||
|
@ -39,5 +39,5 @@
|
||||
"webRequestBlocking",
|
||||
"<all_urls>"
|
||||
],
|
||||
"version": "2.4.3.3"
|
||||
"version": "2.4.3.4"
|
||||
}
|
@ -546,5 +546,5 @@
|
||||
"*://*.wallkit.net/*",
|
||||
"*://*.wsj.net/*"
|
||||
],
|
||||
"version": "2.4.3.3"
|
||||
"version": "2.4.3.4"
|
||||
}
|
@ -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);
|
||||
|
@ -24,7 +24,7 @@
|
||||
Custom sites (new) are enabled automatically in <small><button><a href="options.html" style="text-decoration:none;color:inherit">Options</a></button></small> (cookies will be removed by default unless you enable allow_cookies).<br>
|
||||
If you want to use custom sites (for non-listed sites) enable it in <small><button><a href="optin/opt-in.html" style="text-decoration:none;color:inherit">Opt-in</a></button></small>
|
||||
<strong>Custom sites enabled: <span id="custom-enabled"></span></strong><br>
|
||||
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).
|
||||
<br><br>
|
||||
</div>
|
||||
<div id='add_site'></div>
|
||||
@ -47,7 +47,7 @@
|
||||
<button id="edit">Edit (re-Add)</button>
|
||||
<button id="perm_request">Request<br>permissions</button>
|
||||
<button id="perm_remove">Remove<br>permissions</button><br>
|
||||
permissions granted (for all in custom list): <strong><span id="perm-custom"></span></strong>
|
||||
permissions granted (for all in custom list + updated): <strong><span id="perm-custom"></span></strong>
|
||||
</span>
|
||||
<div style="clear:both;"></div>
|
||||
<div style="width:90%;">
|
||||
|
@ -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({
|
||||
|
Loading…
x
Reference in New Issue
Block a user