Update custom sites (block regex & add import)

merge-requests/2/head
magnolia1234 3 years ago
parent 9a6e4a2eea
commit 31dc7ffed4

@ -650,10 +650,11 @@ Add your own custom site (also for testing).
Check 'Options'-link in popup-menu and go to custom sites.
\* by default BPC has limited permissions, but you can opt-in to enable custom sites (and also clear cookies/block general paywall-scripts for non-listed sites). You can also just request permissions for the custom sites you added yourself.
Make sure the (new) site is checked under Options (or check on/off-button).
By default sites' cookies/local storage are removed after page loads (to bypass article limit).
Also you can enable Googlebot/Bingbot user-agent, disable Javascript for (sub)domain(s)/external sources and/or set the referer (to Facebook, Google or Twitter; ignored when Googlebot is set).
[Example list of custom sites](https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/blob/master/custom/sites_custom.json) or [download list (json)](https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/raw/master/custom/sites_custom.json)
PS on Android: enabling custom sites isn't working (no optional permissions).\
Then you need the 'custom' add-on version (with access to all sites): [Bypass Paywalls Clean (custom)](https://addons.mozilla.org/en-US/firefox/addon/bypass-paywalls-clean-custom)

@ -721,6 +721,13 @@ ext_api.storage.local.get({
block_js_custom.push(domainVar);
if (sites_custom[key]['block_javascript_ext'] > 0)
block_js_custom_ext.push(domainVar);
if (!(defaultSites_domains.includes(domainVar) && blockedRegexes[domainVar])) {
if (sites_custom[key]['block_regex']) {
if (sites_custom[key]['block_regex'].match(/^\/.+\/$/))
sites_custom[key]['block_regex'] = sites_custom[key]['block_regex'].replace(/(^\/|\/$)/g, '');
blockedRegexes[domainVar] = new RegExp(sites_custom[key]['block_regex']);
}
}
switch (sites_custom[key]['referer']) {
case 'facebook':
use_facebook_referer.push(domainVar);
@ -831,6 +838,16 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
if (sites_custom[key]['block_javascript_ext'] > 0) {
block_js_custom_ext.push(domainVar);
}
if (!(defaultSites_domains.includes(domainVar) && blockedRegexes[domainVar])) {
if (sites_custom[key]['block_regex']) {
if (sites_custom[key]['block_regex'].match(/^\/.+\/$/))
sites_custom[key]['block_regex'] = sites_custom[key]['block_regex'].replace(/(^\/|\/$)/g, '');
blockedRegexes[domainVar] = new RegExp(sites_custom[key]['block_regex']);
} else {
if (blockedRegexes[domainVar])
delete blockedRegexes[domainVar];
}
}
switch (sites_custom[key]['referer']) {
case 'facebook':
use_facebook_referer.push(domainVar);

@ -7,6 +7,7 @@ Fix GElocal.it
Fix National Review
Fix Ruhr Nachrichten (amp)
Fix Tech in Asia (visual story)
Update custom sites (block regex & add import)
Update options: enable new sites by default
* v2.3.9.0 (2021-10-10)

@ -0,0 +1,110 @@
{
"Aargauerzeitung.ch": {
"allow_cookies": "1",
"domain": "aargauerzeitung.ch",
"useragent": "googlebot"
},
"Ara.cat": {
"allow_cookies": "1",
"domain": "ara.cat",
"useragent": "googlebot"
},
"Asiasentinel.com": {
"allow_cookies": "1",
"domain": "asiasentinel.com",
"useragent": "googlebot"
},
"Beobachter.ch": {
"allow_cookies": "1",
"domain": "beobachter.ch",
"useragent": "googlebot"
},
"Bnn.de": {
"allow_cookies": "1",
"domain": "bnn.de",
"useragent": "googlebot"
},
"Capital.bg": {
"allow_cookies": "1",
"domain": "capital.bg",
"useragent": "googlebot"
},
"Connexionfrance.com": {
"domain": "connexionfrance.com"
},
"Handelszeitung.ch": {
"allow_cookies": "1",
"domain": "handelszeitung.ch",
"useragent": "googlebot"
},
"Heraldscotland.com": {
"domain": "heraldscotland.com"
},
"Internationalepolitik.de": {
"allow_cookies": "1",
"domain": "internationalepolitik.de"
},
"Lindipendente.online": {
"allow_cookies": "1",
"domain": "lindipendente.online",
"useragent": "googlebot"
},
"Lsa-conso.fr": {
"allow_cookies": "1",
"domain": "lsa-conso.fr",
"useragent": "googlebot"
},
"Luzernerzeitung.ch": {
"allow_cookies": "1",
"domain": "luzernerzeitung.ch",
"useragent": "googlebot"
},
"Muensterschezeitung.de": {
"allow_cookies": "1",
"domain": "muensterschezeitung.de",
"useragent": "googlebot"
},
"Pressandjournal.co.uk": {
"allow_cookies": "1",
"domain": "pressandjournal.co.uk",
"useragent": "googlebot"
},
"Pv-digest.de": {
"allow_cookies": "1",
"domain": "pv-digest.de",
"useragent": "googlebot"
},
"Speld.nl": {
"domain": "speld.nl"
},
"Supchina.com": {
"allow_cookies": "1",
"domain": "supchina.com"
},
"Tagblatt.ch": {
"allow_cookies": "1",
"domain": "tagblatt.ch",
"useragent": "googlebot"
},
"The-past.com": {
"domain": "the-past.com"
},
"Themonthly.com.au": {
"domain": "themonthly.com.au"
},
"Tijorifinance.com": {
"allow_cookies": "1",
"domain": "tijorifinance.com",
"useragent": "googlebot"
},
"Voguebusiness.com": {
"allow_cookies": "1",
"domain": "voguebusiness.com",
"useragent": "googlebot"
},
"Wz.de": {
"allow_cookies": "1",
"domain": "wz.de",
"useragent": "googlebot"
}
}

@ -566,5 +566,5 @@
"*://*.wallkit.net/*",
"*://*.wsj.net/*"
],
"version": "2.3.9.5"
"version": "2.3.9.6"
}

@ -19,7 +19,7 @@
<body>
<h2>Custom Sites</h2>
<div style="width:90%;">
To add a new site, enter an unique title/domain (without www.), select options for useragent (like Googlebot)/block Javascript (block on (sub)domain(s) of site and/or external domains) and/or set referer (ignored when Googlebot is set).<br>
To add a new site, enter an unique title/domain (without www.). Select options for useragent (like Googlebot), block Javascript (on (sub)domain(s) of site and/or external domains), block regular expression (ignored when default site blocks regex) and/or set referer (ignored when Googlebot is set).<br>
Custom sites 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; cookie settings for default sites are ignored).<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>

@ -4,64 +4,63 @@ var useragent_options = ['', 'googlebot', 'bingbot'];
var referer_options = ['', 'facebook', 'google', 'twitter'];
function capitalize(str) {
if (typeof str !== 'string') return '';
return str.charAt(0).toUpperCase() + str.slice(1);
return (typeof str === 'string') ? str.charAt(0).toUpperCase() + str.slice(1) : '';
}
function sortJson(json) {
return Object.keys(json)
.sort().reduce(function (Obj, key) {
Obj[key] = json[key];
return Obj;
}, {});
return Object.keys(json)
.sort().reduce(function (Obj, key) {
Obj[key] = json[key];
return Obj;
}, {});
}
// Saves options to ext_api.storage
function save_options() {
var textareaEl = document.querySelector('#bypass_sites textarea');
var sites_custom = {};
if (textareaEl.value !== '')
var sites_custom = JSON.parse(textareaEl.value);
ext_api.storage.local.set({
sites_custom: sites_custom
}, function () {
// Update status to let user know custom sites were saved.
var status = document.getElementById('status');
status.textContent = 'Custom sites saved.';
setTimeout(function () {
status.textContent = '';
location.href = 'options.html';
//window.close();
}, 800);
});
var textareaEl = document.querySelector('#bypass_sites textarea');
var sites_custom = {};
if (textareaEl.value !== '')
var sites_custom = JSON.parse(textareaEl.value);
ext_api.storage.local.set({
sites_custom: sites_custom
}, function () {
// Update status to let user know custom sites were saved.
var status = document.getElementById('status');
status.textContent = 'Custom sites saved.';
setTimeout(function () {
status.textContent = '';
location.href = 'options.html';
//window.close();
}, 800);
});
}
// Sort json by key in textarea
function sort_options() {
var textareaEl = document.querySelector('#bypass_sites textarea');
var sites_custom = {};
if (textareaEl.value !== '') {
var sites_custom = JSON.parse(textareaEl.value);
var sites_custom_sorted = sortJson(sites_custom);
textareaEl.value = JSON.stringify(sites_custom_sorted);
}
var textareaEl = document.querySelector('#bypass_sites textarea');
var sites_custom = {};
if (textareaEl.value !== '') {
var sites_custom = JSON.parse(textareaEl.value);
var sites_custom_sorted = sortJson(sites_custom);
textareaEl.value = JSON.stringify(sites_custom_sorted);
}
}
// Export custom sites to file
function export_options() {
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
var result = JSON.stringify(items.sites_custom);
var a = document.createElement("a");
var file = new Blob([result], {type: "text/plain"});
a.href = window.URL.createObjectURL(file);
let date = new Date();
let dateStr = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().split("T")[0];
a.download = 'bypass_paywalls_clean_custom_' + dateStr + '.txt';
a.click();
});
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
var result = JSON.stringify(items.sites_custom);
var a = document.createElement("a");
var file = new Blob([result], {type: "text/plain"});
a.href = window.URL.createObjectURL(file);
let date = new Date();
let dateStr = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().split("T")[0];
a.download = 'bypass_paywalls_clean_custom_' + dateStr + '.txt';
a.click();
});
}
// Import custom sites from file
@ -73,266 +72,269 @@ function import_options(e) {
}
function _imp() {
let sites_custom = JSON.parse(this.result);
var result = this.result;
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
var sites_custom = items.sites_custom;
var sites_custom_new = JSON.parse(result);
for (let site in sites_custom_new)
sites_custom[site] = sites_custom_new[site];
ext_api.storage.local.set({
sites_custom: sites_custom
sites_custom: sites_custom
}, function () {
// Update status to let user know custom sites were imported.
var status = document.getElementById('status');
status.textContent = 'Custom sites imported.';
setTimeout(function () {
//status.textContent = '';
importInput.value = '';
renderOptions();
}, 800);
// Update status to let user know custom sites were imported.
var status = document.getElementById('status');
status.textContent = 'Custom sites imported.';
setTimeout(function () {
//status.textContent = '';
importInput.value = '';
renderOptions();
}, 800);
});
});
}
// Add custom site to ext_api.storage
function add_options() {
var inputEls = document.querySelectorAll('#add_site input, #add_site select');
var sites_custom = {};
for (let i = 0; i < inputEls.length; i++) {
if (inputEls[i].dataset.key === 'title') {
var title = capitalize(inputEls[i].value);
if (title === '')
break;
sites_custom[title] = {};
} else {
if (inputEls[i].dataset.value) {
if (inputEls[i].checked)
sites_custom[title][inputEls[i].dataset.key] = inputEls[i].dataset.value;
} else if (inputEls[i].value)
sites_custom[title][inputEls[i].dataset.key] = inputEls[i].value;
}
}
if (title && sites_custom[title]['domain']) {
sites_custom[title]['domain'] = sites_custom[title]['domain'].replace(/(http(s)?:\/\/(www\.)?|^www\.|\/$)/g, '').toLowerCase();
// add new site to local storage
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
var sites_custom_old = items.sites_custom;
for (var key in sites_custom) {
sites_custom_old[key] = sites_custom[key];
}
ext_api.storage.local.set({
sites_custom: sites_custom_old
}, function () {
// Update status to let user know new custom site was added.
var status_add = document.getElementById('status_add');
status_add.textContent = 'Site added.';
setTimeout(function () {
//status.textContent = '';
renderOptions();
}, 800);
});
});
var inputEls = document.querySelectorAll('#add_site input, #add_site select');
var sites_custom = {};
for (let elem of inputEls) {
if (elem.dataset.key === 'title') {
var title = capitalize(elem.value);
if (title === '')
break;
sites_custom[title] = {};
} else {
if (elem.dataset.value) {
if (elem.checked)
sites_custom[title][elem.dataset.key] = elem.dataset.value;
} else if (elem.value)
sites_custom[title][elem.dataset.key] = elem.value;
}
}
if (title && sites_custom[title]['domain']) {
sites_custom[title]['domain'] = sites_custom[title]['domain'].replace(/(http(s)?:\/\/(www\.)?|^www\.|\/$)/g, '').toLowerCase();
// add new site to local storage
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
var sites_custom_old = items.sites_custom;
for (var key in sites_custom) {
sites_custom_old[key] = sites_custom[key];
}
ext_api.storage.local.set({
sites_custom: sites_custom_old
}, function () {
// Update status to let user know new custom site was added.
var status_add = document.getElementById('status_add');
status_add.textContent = 'Site added.';
setTimeout(function () {
//status.textContent = '';
renderOptions();
}, 800);
});
});
}
}
// Delete custom site from ext_api.storage
function delete_options() {
var selectEl = document.querySelector('#custom_sites select');
var sites_custom = {};
var remove_key = selectEl.value;
// delete site from local storage
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
var sites_custom_old = items.sites_custom;
delete sites_custom_old[remove_key];
ext_api.storage.local.set({
sites_custom: sites_custom_old
}, function () {
// Update status to let user know custom site was deleted.
var status_delete = document.getElementById('status_delete');
status_delete.textContent = 'Site deleted.';
setTimeout(function () {
//status.textContent = '';
renderOptions();
}, 800);
});
var selectEl = document.querySelector('#custom_sites select');
var sites_custom = {};
var remove_key = selectEl.value;
// delete site from local storage
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
var sites_custom_old = items.sites_custom;
delete sites_custom_old[remove_key];
ext_api.storage.local.set({
sites_custom: sites_custom_old
}, function () {
// Update status to let user know custom site was deleted.
var status_delete = document.getElementById('status_delete');
status_delete.textContent = 'Site deleted.';
setTimeout(function () {
//status.textContent = '';
renderOptions();
}, 800);
});
});
}
// Edit custom site (copy to add)
function edit_options() {
var selectEl = document.querySelector('#custom_sites select');
var sites_custom = {};
var title = selectEl.value;
// copy site to add-fields
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
sites_custom = items.sites_custom;
var edit_site = sites_custom[title];
document.querySelector('input[data-key="title"]').value = title;
document.querySelector('input[data-key="domain"]').value = edit_site.domain;
document.querySelector('select[data-key="useragent"]').selectedIndex = (edit_site.googlebot > 0) ? 1 : useragent_options.indexOf(edit_site.useragent);
document.querySelector('input[data-key="allow_cookies"]').checked = (edit_site.allow_cookies > 0);
document.querySelector('input[data-key="block_javascript"]').checked = (edit_site.block_javascript > 0);
document.querySelector('input[data-key="block_javascript_ext"]').checked = (edit_site.block_javascript_ext > 0);
document.querySelector('select[data-key="referer"]').selectedIndex = referer_options.indexOf(edit_site.referer);
});
var selectEl = document.querySelector('#custom_sites select');
var sites_custom = {};
var title = selectEl.value;
// copy site to add-fields
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
sites_custom = items.sites_custom;
var edit_site = sites_custom[title];
document.querySelector('input[data-key="title"]').value = title;
document.querySelector('input[data-key="domain"]').value = edit_site.domain;
document.querySelector('select[data-key="useragent"]').selectedIndex = (edit_site.googlebot > 0) ? 1 : useragent_options.indexOf(edit_site.useragent);
document.querySelector('input[data-key="allow_cookies"]').checked = (edit_site.allow_cookies > 0);
document.querySelector('input[data-key="block_javascript"]').checked = (edit_site.block_javascript > 0);
document.querySelector('input[data-key="block_javascript_ext"]').checked = (edit_site.block_javascript_ext > 0);
document.querySelector('input[data-key="block_regex"]').value = edit_site.block_regex ? edit_site.block_regex : '';
document.querySelector('select[data-key="referer"]').selectedIndex = referer_options.indexOf(edit_site.referer);
});
}
// request permissions for custom sites (in list only)
function request_permissions() {
var perm_custom = document.getElementById('perm-custom');
ext_api.permissions.request({
origins: perm_origins
}, function (granted) {
if (granted) {
perm_custom.innerText = 'YES';
} else {
perm_custom.innerText = 'NO';
}
});
var perm_custom = document.getElementById('perm-custom');
ext_api.permissions.request({
origins: perm_origins
}, function (granted) {
if (granted) {
perm_custom.innerText = 'YES';
} else {
perm_custom.innerText = 'NO';
}
});
}
// remove permissions for custom sites
function remove_permissions() {
var perm_custom = document.getElementById('perm-custom');
ext_api.permissions.remove({
origins: perm_origins
}, function (removed) {
if (removed) {
perm_custom.innerText = 'NO';
}
});
var perm_custom = document.getElementById('perm-custom');
ext_api.permissions.remove({
origins: perm_origins
}, function (removed) {
if (removed) {
perm_custom.innerText = 'NO';
}
});
}
var perm_origins;
// Restores checkbox input states using the preferences stored in ext_api.storage.
function renderOptions() {
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
var sites_custom = items.sites_custom;
var sitesEl = document.getElementById('bypass_sites');
sitesEl.innerHTML = '';
var labelEl = document.createElement('label');
var textareaEl = document.createElement('textarea');
textareaEl.value = JSON.stringify(sites_custom);
textareaEl.rows = 12;
textareaEl.cols = 40;
labelEl.appendChild(textareaEl);
sitesEl.appendChild(labelEl);
// add site
var add_sitesEl = document.getElementById('add_site');
add_sitesEl.innerHTML = '';
var inputEl;
var add_checkboxes = {
'title': 0,
'domain': 0,
'allow_cookies': 1,
'block_javascript': 1,
'block_javascript_ext': 1
};
for (var key in add_checkboxes) {
labelEl = document.createElement('label');
inputEl = document.createElement('input');
inputEl.dataset.key = key;
labelEl.appendChild(inputEl);
if (add_checkboxes[key]) {
inputEl.type = 'checkbox';
inputEl.dataset.value = 1;
} else if (key === 'title') {
inputEl.placeholder = 'Example';
} else if (key === 'domain')
inputEl.placeholder = 'example.com';
labelEl.appendChild(document.createTextNode(' ' + key));
add_sitesEl.appendChild(labelEl);
}
labelEl = document.createElement('label');
labelEl.appendChild(document.createTextNode('useragent '));
inputEl = document.createElement('select');
inputEl.dataset.key = 'useragent';
labelEl.appendChild(inputEl);
for (var i = 0; i < useragent_options.length; i++) {
var option = document.createElement("option");
option.value = useragent_options[i];
option.text = useragent_options[i];
inputEl.appendChild(option);
}
add_sitesEl.appendChild(labelEl);
labelEl = document.createElement('label');
labelEl.appendChild(document.createTextNode('referer '));
inputEl = document.createElement('select');
inputEl.dataset.key = 'referer';
labelEl.appendChild(inputEl);
for (var i = 0; i < referer_options.length; i++) {
var option = document.createElement("option");
option.value = referer_options[i];
option.text = referer_options[i];
inputEl.appendChild(option);
}
add_sitesEl.appendChild(labelEl);
// list of custom sites
var custom_sitesEl = document.getElementById('custom_sites');
custom_sitesEl.innerHTML = '';
labelEl = document.createElement('label');
var selectEl = document.createElement('select');
selectEl.id = 'sites';
selectEl.size = 6;
var optionEl;
perm_origins = [];
for (var key in sites_custom) {
optionEl = document.createElement('option');
let domain = sites_custom[key]['domain'];
perm_origins.push('*://*.' + domain + '/*');
let isDefaultSite = defaultSites_domains.includes(domain);
optionEl.text = isDefaultSite ? '*' : '';
optionEl.text += key + ': ' + domain +
(sites_custom[key]['googlebot']>0 ? ' | googlebot' : '') +
(sites_custom[key]['allow_cookies']>0 ? ' | allow_cookies' : '') +
(sites_custom[key]['block_javascript']>0 ? ' | block javascript' : '') +
(sites_custom[key]['block_javascript_ext']>0 ? ' | block javascript ext' : '') +
(sites_custom[key]['useragent'] ? ' | useragent: ' + sites_custom[key]['useragent'] : '') +
(sites_custom[key]['referer'] ? ' | referer: ' + sites_custom[key]['referer'] : '');
optionEl.value = key;
selectEl.add(optionEl);
}
labelEl.appendChild(selectEl);
custom_sitesEl.appendChild(labelEl);
var perm_custom = document.getElementById('perm-custom');
ext_api.permissions.contains({
origins: perm_origins
}, function (result) {
if (result) {
perm_custom.innerText = 'YES';
} else {
perm_custom.innerText = 'NO';
}
});
});
var custom_enabled = document.getElementById('custom-enabled');
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
var sites_custom = items.sites_custom;
var sitesEl = document.getElementById('bypass_sites');
sitesEl.innerHTML = '';
var labelEl = document.createElement('label');
var textareaEl = document.createElement('textarea');
textareaEl.value = JSON.stringify(sites_custom);
textareaEl.rows = 12;
textareaEl.cols = 40;
labelEl.appendChild(textareaEl);
sitesEl.appendChild(labelEl);
// add site
var add_sitesEl = document.getElementById('add_site');
add_sitesEl.innerHTML = '';
var inputEl;
var add_checkboxes = {
'title': 0,
'domain': 0,
'allow_cookies': 1,
'block_javascript': 1,
'block_javascript_ext': 1,
'block_regex': 0
};
for (var key in add_checkboxes) {
labelEl = document.createElement('label');
inputEl = document.createElement('input');
inputEl.dataset.key = key;
labelEl.appendChild(inputEl);
if (add_checkboxes[key]) {
inputEl.type = 'checkbox';
inputEl.dataset.value = 1;
} else if (key === 'title') {
inputEl.placeholder = 'Example';
} else if (key === 'domain')
inputEl.placeholder = 'example.com';
labelEl.appendChild(document.createTextNode(' ' + key));
add_sitesEl.appendChild(labelEl);
}
var add_options = {
useragent: useragent_options,
referer: referer_options
};
for (let key in add_options) {
labelEl = document.createElement('label');
labelEl.appendChild(document.createTextNode(key + ' '));
inputEl = document.createElement('select');
inputEl.dataset.key = key;
labelEl.appendChild(inputEl);
for (let elem of add_options[key]) {
let option = document.createElement("option");
option.value = elem;
option.text = elem;
inputEl.appendChild(option);
}
add_sitesEl.appendChild(labelEl);
}
// list of custom sites
var custom_sitesEl = document.getElementById('custom_sites');
custom_sitesEl.innerHTML = '';
labelEl = document.createElement('label');
var selectEl = document.createElement('select');
selectEl.id = 'sites';
selectEl.size = 6;
var optionEl;
perm_origins = [];
for (let key in sites_custom) {
optionEl = document.createElement('option');
let domain = sites_custom[key]['domain'];
perm_origins.push('*://*.' + domain + '/*');
let isDefaultSite = defaultSites_domains.includes(domain);
optionEl.text = isDefaultSite ? '*' : '';
optionEl.text += key + ': ' + domain +
(sites_custom[key]['googlebot'] > 0 ? ' | googlebot' : '') +
(sites_custom[key]['allow_cookies'] > 0 ? ' | allow_cookies' : '') +
(sites_custom[key]['block_javascript'] > 0 ? ' | block javascript' : '') +
(sites_custom[key]['block_javascript_ext'] > 0 ? ' | block javascript ext' : '') +
(sites_custom[key]['block_regex'] ? ' | block regex' : '') +
(sites_custom[key]['useragent'] ? ' | useragent: ' + sites_custom[key]['useragent'] : '') +
(sites_custom[key]['referer'] ? ' | referer: ' + sites_custom[key]['referer'] : '');
optionEl.value = key;
selectEl.add(optionEl);
}
labelEl.appendChild(selectEl);
custom_sitesEl.appendChild(labelEl);
var perm_custom = document.getElementById('perm-custom');
ext_api.permissions.contains({
origins: ["<all_urls>"]
origins: perm_origins
}, function (result) {
if (result) {
custom_enabled.innerText = 'YES';
} else {
custom_enabled.innerText = 'NO';
}
if (result) {
perm_custom.innerText = 'YES';
} else {
perm_custom.innerText = 'NO';
}
});
});
var custom_enabled = document.getElementById('custom-enabled');
ext_api.permissions.contains({
origins: ["<all_urls>"]
}, function (result) {
if (result) {
custom_enabled.innerText = 'YES';
} else {
custom_enabled.innerText = 'NO';
}
});
}
document.addEventListener('DOMContentLoaded', renderOptions);
@ -345,4 +347,4 @@ document.getElementById('add').addEventListener('click', add_options);
document.getElementById('delete').addEventListener('click', delete_options);
document.getElementById('edit').addEventListener('click', edit_options);
document.getElementById('perm_request').addEventListener('click', request_permissions);
document.getElementById('perm_remove').addEventListener('click', remove_permissions);
document.getElementById('perm_remove').addEventListener('click', remove_permissions);
Loading…
Cancel
Save