mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-10 06:27:48 +01:00
Update custom sites: allow_cookies
This commit is contained in:
parent
7a5c38eca0
commit
786bf277ce
8 changed files with 52 additions and 30 deletions
|
@ -23,7 +23,7 @@ const restrictions = {
|
|||
|
||||
// Don't remove cookies before page load
|
||||
// allow_cookies are completed with domains in sites.js (default allow/remove_cookies)
|
||||
var allow_cookies = [
|
||||
var allow_cookies_default = [
|
||||
'abc.es',
|
||||
'aftonbladet.se',
|
||||
'belfasttelegraph.co.uk',
|
||||
|
@ -95,7 +95,8 @@ var allow_cookies = [
|
|||
'wp.de',
|
||||
'wr.de',
|
||||
'zeit.de',
|
||||
]
|
||||
];
|
||||
var allow_cookies = allow_cookies_default.slice();
|
||||
|
||||
// Removes cookies after page load
|
||||
// remove_cookies are completed with domains of sites.js (default allow/remove_cookies)
|
||||
|
@ -157,8 +158,7 @@ var use_google_bot_default = [
|
|||
'wsj.com',
|
||||
'zeit.de',
|
||||
];
|
||||
var use_google_bot_custom = [];
|
||||
var use_google_bot = use_google_bot_default.concat(use_google_bot_custom);
|
||||
var use_google_bot = use_google_bot_default.slice();
|
||||
|
||||
// Override User-Agent with Bingbot
|
||||
var use_bing_bot = [
|
||||
|
@ -332,6 +332,9 @@ ext_api.storage.local.get({
|
|||
if (sites_custom[key]['googlebot'] > 0 && !use_google_bot.includes(domainVar)) {
|
||||
use_google_bot.push(domainVar);
|
||||
}
|
||||
if (sites_custom[key]['allow_cookies'] > 0 && !allow_cookies.includes(domainVar)) {
|
||||
allow_cookies.push(domainVar);
|
||||
}
|
||||
if (sites_custom[key]['block_javascript'] > 0) {
|
||||
block_js_custom.push(domainVar);
|
||||
}
|
||||
|
@ -399,7 +402,7 @@ ext_api.storage.local.get({
|
|||
ext_api.storage.onChanged.addListener(function (changes, namespace) {
|
||||
if (namespace === 'sync')
|
||||
return;
|
||||
for (var key in changes) {
|
||||
for (let key in changes) {
|
||||
var storageChange = changes[key];
|
||||
if (key === 'sites') {
|
||||
var sites = storageChange.newValue;
|
||||
|
@ -429,6 +432,12 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
|
|||
enabledSites = enabledSites.concat(au_prov_news_domains);
|
||||
else
|
||||
disabledSites = disabledSites.concat(au_prov_news_domains);
|
||||
for (let domainVar of enabledSites) {
|
||||
if (!allow_cookies.includes(domainVar) && !remove_cookies.includes(domainVar)) {
|
||||
allow_cookies.push(domainVar);
|
||||
remove_cookies.push(domainVar);
|
||||
}
|
||||
}
|
||||
// reset disableJavascriptOnListedSites eventListener
|
||||
ext_api.webRequest.onBeforeRequest.removeListener(disableJavascriptOnListedSites);
|
||||
ext_api.webRequest.handlerBehaviorChanged();
|
||||
|
@ -447,9 +456,9 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
|
|||
sites: {}
|
||||
}, function (items) {
|
||||
var sites = items.sites;
|
||||
for (var key of sites_custom_added)
|
||||
for (let key of sites_custom_added)
|
||||
sites[key] = sites_custom[key].domain;
|
||||
for (var key of sites_custom_removed)
|
||||
for (let key of sites_custom_removed)
|
||||
delete sites[key];
|
||||
|
||||
ext_api.storage.local.set({
|
||||
|
@ -459,6 +468,17 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
|
|||
});
|
||||
});
|
||||
|
||||
// restore cookie-settings for removed custom (& also default) domain
|
||||
var sites_custom_default_domain_removed = Object.values(sites_custom_old).map(function (site_old) {
|
||||
return site_old.domain;
|
||||
}).filter(x => !Object.values(sites_custom).map(function (site_new) {
|
||||
return site_new.domain;
|
||||
}).includes(x) && defaultSites_domains.includes(x));
|
||||
for (let domain of sites_custom_default_domain_removed) {
|
||||
if (!allow_cookies_default.includes(domain) && !remove_cookies.includes(domain))
|
||||
remove_cookies.push(domain);
|
||||
}
|
||||
|
||||
use_google_bot = use_google_bot_default.slice();
|
||||
block_js_custom = [];
|
||||
block_js_custom_ext = [];
|
||||
|
@ -467,6 +487,14 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
|
|||
if (sites_custom[key]['googlebot'] > 0 && !use_google_bot.includes(domainVar)) {
|
||||
use_google_bot.push(domainVar);
|
||||
}
|
||||
if (sites_custom[key]['allow_cookies'] > 0) {
|
||||
if (allow_cookies.includes(domainVar)) {
|
||||
if (remove_cookies.includes(domainVar))
|
||||
remove_cookies.splice(remove_cookies.indexOf(domainVar), 1);
|
||||
} else
|
||||
allow_cookies.push(domainVar);
|
||||
} else if (!allow_cookies_default.includes(domainVar) && allow_cookies.includes(domainVar) && !remove_cookies.includes(domainVar))
|
||||
remove_cookies.push(domainVar);
|
||||
if (sites_custom[key]['block_javascript'] > 0) {
|
||||
block_js_custom.push(domainVar);
|
||||
}
|
||||
|
@ -601,7 +629,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
|||
var requestHeaders = details.requestHeaders;
|
||||
|
||||
var header_referer = '';
|
||||
for (var n in requestHeaders) {
|
||||
for (let n in requestHeaders) {
|
||||
if (requestHeaders[n].name.toLowerCase() == 'referer') {
|
||||
header_referer = requestHeaders[n].value;
|
||||
continue;
|
||||
|
@ -854,9 +882,9 @@ function site_switch() {
|
|||
sites: {}
|
||||
}, function (items) {
|
||||
var sites = items.sites;
|
||||
for (var key of added_site)
|
||||
for (let key of added_site)
|
||||
sites[key] = domain;
|
||||
for (var key of removed_site)
|
||||
for (let key of removed_site)
|
||||
delete sites[key];
|
||||
|
||||
ext_api.storage.local.set({
|
||||
|
|
|
@ -14,6 +14,7 @@ Fix-update Telegraph.co.uk (overlay)
|
|||
Fix Chrome-icon for dark/incognito mode (all permitted sites)
|
||||
Fix clearCookies (Chrome .domain cookies)
|
||||
Fix updateBadge (grouped sites)
|
||||
Update custom sites: allow_cookies
|
||||
Update options/popup layout (+ mobile)
|
||||
|
||||
* v1.9.3.0 (2020-11-01)
|
||||
|
|
|
@ -341,5 +341,5 @@
|
|||
"webRequest",
|
||||
"webRequestBlocking"
|
||||
],
|
||||
"version": "1.9.4.0"
|
||||
"version": "1.9.4.1"
|
||||
}
|
|
@ -34,7 +34,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<p>
|
||||
<div style='float:left'>
|
||||
<div style='float:left;padding-bottom:50px'>
|
||||
<small><button><a href="../options.html" style="text-decoration:none;color:inherit">Options</a></button></small>
|
||||
<small><button><a href="../options_custom.html" style="text-decoration:none;color:inherit">Custom sites</a></button></small>
|
||||
<small><button id="button-close">Close</button></small>
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
<button id="select-all">Select all</button>
|
||||
<button id="select-none">Select none</button>
|
||||
<button><a href="options_custom.html" style="text-decoration:none;color:inherit">Custom sites</a></button>
|
||||
<button id="button-close">Close</button>
|
||||
</span>
|
||||
<script src="sites.js"></script>
|
||||
<script src="options.js"></script>
|
||||
|
|
21
options.js
21
options.js
|
@ -21,22 +21,6 @@ function save_options() {
|
|||
// Update status to let user know options were saved.
|
||||
var status = document.getElementById('status');
|
||||
status.textContent = 'Options saved.';
|
||||
setTimeout(function() {
|
||||
status.textContent = '';
|
||||
window.close();
|
||||
}, 800);
|
||||
});
|
||||
|
||||
// Refresh the current tab
|
||||
ext_api.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true
|
||||
}, function (tabs) {
|
||||
if (tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
||||
ext_api.tabs.update(tabs[0].id, {
|
||||
url: tabs[0].url
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -109,7 +93,12 @@ function selectNone() {
|
|||
});
|
||||
}
|
||||
|
||||
function closeButton() {
|
||||
window.close();
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', renderOptions);
|
||||
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);
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
<h2>Custom Sites</h2>
|
||||
<div style="width:90%;">
|
||||
To add a new site, enter an unique title/domain (without www.) and select options for Googlebot/block Javascript (block on (sub)domain(s) of site and/or external domains).<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).<br>
|
||||
If you want to use custom sites enable it in <small><button><a href="optin/opt-in.html" style="text-decoration:none;color:inherit">Opt-in</a></button></small><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).<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><br>
|
||||
<strong>Custom sites enabled: <span id="custom-enabled"></span></strong>
|
||||
<br><br>
|
||||
</div>
|
||||
|
|
|
@ -175,6 +175,7 @@ function edit_options() {
|
|||
document.querySelector('input[data-key="title"]').value = title;
|
||||
document.querySelector('input[data-key="domain"]').value = edit_site.domain;
|
||||
document.querySelector('input[data-key="googlebot"]').checked = (edit_site.googlebot > 0);
|
||||
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);
|
||||
});
|
||||
|
@ -204,6 +205,7 @@ function renderOptions() {
|
|||
'title': 0,
|
||||
'domain': 0,
|
||||
'googlebot': 1,
|
||||
'allow_cookies': 1,
|
||||
'block_javascript': 1,
|
||||
'block_javascript_ext': 1
|
||||
};
|
||||
|
@ -238,6 +240,7 @@ function renderOptions() {
|
|||
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' : '');
|
||||
optionEl.value = key;
|
||||
|
|
Loading…
Reference in a new issue