Fix custom sites (block Javascript)

master
magnolia1234 2020-08-22 13:52:26 +02:00
parent 28c106bde5
commit f8a15ecef6
2 changed files with 24 additions and 24 deletions

View File

@ -470,7 +470,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
}
// block external javascript for custom sites (optional)
var domain_blockjs_ext = matchUrlDomain([block_js_custom_ext], header_referer);
var domain_blockjs_ext = matchUrlDomain(block_js_custom_ext, header_referer);
if (domain_blockjs_ext && !matchUrlDomain(domain_blockjs_ext, details.url) && details.url.match(/(\.js$|\.js\?|\/json\?)/) && isSiteEnabled({url: header_referer})) {
return { cancel: true };
}
@ -488,7 +488,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
}
// block javascript of (sub)domain for custom sites (optional)
var domain_blockjs = matchUrlDomain([block_js_custom], details.url);
var domain_blockjs = matchUrlDomain(block_js_custom, details.url);
if (domain_blockjs && matchUrlDomain(domain_blockjs, details.url) && details.url.match(/(\.js$|\.js\?|\/json\?)/)) {
return { cancel: true };
}

View File

@ -104,33 +104,33 @@ function add_options() {
sites_custom[title][inputEls[i].dataset.key] = inputEls[i].value;
}
}
if (sites_custom[title]['domain'] === '')
sites_custom = {};
else
if (title && sites_custom[title]['domain']) {
sites_custom[title]['domain'] = sites_custom[title]['domain'].replace('www.', '').toLowerCase();
// add new site to local storage
ext_api.storage.sync.get({
sites_custom: {}
}, function (items) {
var sites_custom_old = items.sites_custom;
// add new site to local storage
ext_api.storage.sync.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];
}
for (var key in sites_custom) {
sites_custom_old[key] = sites_custom[key];
}
ext_api.storage.sync.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);
ext_api.storage.sync.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