mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-10 03:21:58 +01:00
Update custom sites (load text from Google webcache)
This commit is contained in:
parent
5da69179db
commit
ea940f905e
7 changed files with 58 additions and 32 deletions
|
@ -798,7 +798,7 @@ 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 (or `clear cookies` (BPC-icon) to ask for permission for current site).
|
||||
|
||||
By default sites' cookies/local storage are removed after page loads (to bypass article limit).
|
||||
Also you can enable Googlebot/Bingbot user-agent, set referer (to Facebook, Google or Twitter; ignored when Googlebot is set), set random ip-address, disable Javascript for (sub)domain(s) and/or external domains, block regular expression, unhide text on (or when paywall(selector) redirect to) amp-page and/or load text from json (paywall|article selector).
|
||||
Also you can enable Googlebot/Bingbot user-agent, set referer (to Facebook, Google or Twitter; ignored when Googlebot is set), set random ip-address, disable Javascript for (sub)domain(s) and/or external domains, block regular expression, unhide text on (or when paywall(selector) redirect to) amp-page and/or load text from json or Google webcache (paywall|article selector).
|
||||
|
||||
[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)
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ var amp_redirect;
|
|||
var cs_code;
|
||||
// load text from json
|
||||
var ld_json;
|
||||
// load text from Google webcache
|
||||
var ld_google_webcache;
|
||||
|
||||
// custom: block javascript
|
||||
var block_js_custom = [];
|
||||
|
@ -91,6 +93,7 @@ function initSetRules() {
|
|||
amp_redirect = {};
|
||||
cs_code = {};
|
||||
ld_json = {};
|
||||
ld_google_webcache = {};
|
||||
block_js_custom = [];
|
||||
block_js_custom_ext = [];
|
||||
blockedRegexes = {};
|
||||
|
@ -278,6 +281,11 @@ function set_rules(sites, sites_updated, sites_custom) {
|
|||
if (!dompurify_sites.includes(domain))
|
||||
dompurify_sites.push(domain);
|
||||
}
|
||||
if (rule.ld_google_webcache) {
|
||||
ld_google_webcache[domain] = rule.ld_google_webcache;
|
||||
if (!dompurify_sites.includes(domain))
|
||||
dompurify_sites.push(domain);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1103,6 +1111,9 @@ if (matchUrlDomain(change_headers, details.url) && !['font', 'image', 'styleshee
|
|||
let ld_json_domain = '';
|
||||
if (ld_json_domain = matchUrlDomain(Object.keys(ld_json), currentTabUrl))
|
||||
bg2csData.ld_json = ld_json[ld_json_domain];
|
||||
let ld_google_webcache_domain = '';
|
||||
if (ld_google_webcache_domain = matchUrlDomain(Object.keys(ld_google_webcache), currentTabUrl))
|
||||
bg2csData.ld_google_webcache = ld_google_webcache[ld_google_webcache_domain];
|
||||
ext_api.tabs.executeScript(tabId, {
|
||||
code: 'var bg2csData = ' + JSON.stringify(bg2csData) + ';'
|
||||
}, function () {
|
||||
|
|
|
@ -5,6 +5,7 @@ Post-release
|
|||
Add Tagesspiegel.de
|
||||
Redirect Google AMP cache (opt-in to custom sites)
|
||||
Update block general paywall script (limit Evolok WordPress)
|
||||
Update custom sites (load text from Google webcache)
|
||||
|
||||
* v2.7.8.0 (2022-07-31)
|
||||
Add Crusoe (Brazil)
|
||||
|
|
|
@ -60,24 +60,44 @@ var bg2csData;
|
|||
// custom/updated sites: load text from json
|
||||
if ((bg2csData !== undefined) && bg2csData.ld_json && dompurify_loaded) {
|
||||
if (bg2csData.ld_json.includes('|')) {
|
||||
let ld_json_split = bg2csData.ld_json.split('|');
|
||||
let paywall_sel = ld_json_split[0];
|
||||
let article_sel = ld_json_split[1];
|
||||
let paywall = document.querySelector(paywall_sel);
|
||||
if (paywall) {
|
||||
removeDOMElement(paywall);
|
||||
let json_script = getArticleJsonScript();
|
||||
if (json_script) {
|
||||
let json_text = parseHtmlEntities(JSON.parse(json_script.text).articleBody);
|
||||
let content = document.querySelector(article_sel);
|
||||
if (json_text && content) {
|
||||
let parser = new DOMParser();
|
||||
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text) + '</div>', 'text/html');
|
||||
let content_new = doc.querySelector('div');
|
||||
content.parentNode.replaceChild(content_new, content);
|
||||
window.setTimeout(function () {
|
||||
let ld_json_split = bg2csData.ld_json.split('|');
|
||||
let paywall_sel = ld_json_split[0];
|
||||
let article_sel = ld_json_split[1];
|
||||
let paywall = document.querySelector(paywall_sel);
|
||||
if (paywall) {
|
||||
removeDOMElement(paywall);
|
||||
let json_script = getArticleJsonScript();
|
||||
if (json_script) {
|
||||
let json_text = parseHtmlEntities(JSON.parse(json_script.text).articleBody);
|
||||
let content = document.querySelector(article_sel);
|
||||
if (json_text && content) {
|
||||
let parser = new DOMParser();
|
||||
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text) + '</div>', 'text/html');
|
||||
let content_new = doc.querySelector('div');
|
||||
content.parentNode.replaceChild(content_new, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// custom/updated sites: load text from Google webcache
|
||||
if ((bg2csData !== undefined) && bg2csData.ld_google_webcache && dompurify_loaded) {
|
||||
if (bg2csData.ld_google_webcache.includes('|')) {
|
||||
window.setTimeout(function () {
|
||||
let url = window.location.href;
|
||||
let ld_google_webcache_split = bg2csData.ld_google_webcache.split('|');
|
||||
let paywall_sel = ld_google_webcache_split[0];
|
||||
let article_sel = ld_google_webcache_split[1];
|
||||
let paywall = document.querySelector(paywall_sel);
|
||||
if (paywall) {
|
||||
removeDOMElement(paywall);
|
||||
let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url;
|
||||
replaceDomElementExt(url_cache, true, false, article_sel);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -667,7 +667,6 @@
|
|||
"*://*.weborama.fr/*",
|
||||
"*://*.zephr.com/*",
|
||||
"*://*.amazonaws.com/*",
|
||||
"*://*.apnarm.net.au/*",
|
||||
"*://*.bntech.io/*",
|
||||
"*://*.bwbx.io/*",
|
||||
"*://*.cedsdigital.it/*",
|
||||
|
@ -698,5 +697,5 @@
|
|||
"*://gcm.omerlocdn.com/*",
|
||||
"*://webcache.googleusercontent.com/*"
|
||||
],
|
||||
"version": "2.7.8.1"
|
||||
"version": "2.7.8.2"
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<h2>Custom Sites</h2>
|
||||
<div style="width:90%;">
|
||||
To add a new site, enter an unique title/domain (without www.).<br>
|
||||
Select options for useragent (like Googlebot), set referer (ignored when Googlebot is set), set random ip-address, block Javascript, block regular expression, unhide text on (or when paywall(selector) redirect to) amp-page and/or load text from json (paywall|article selector).<br>
|
||||
Select options for useragent (like Googlebot), set referer (ignored when Googlebot is set), set random ip-address, block Javascript, block regular expression, unhide text on (or when paywall(selector) redirect to) amp-page and/or load text from json or Google webcache (paywall|article selector).<br>
|
||||
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>
|
||||
|
|
|
@ -66,15 +66,6 @@ function export_options() {
|
|||
}
|
||||
|
||||
function import_json(result) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ext_api.storage.local.get({
|
||||
sites_custom: {}
|
||||
}, function (items) {
|
||||
|
@ -224,6 +215,7 @@ function edit_options() {
|
|||
document.querySelector('input[data-key="amp_unhide"]').checked = (edit_site.amp_unhide > 0);
|
||||
document.querySelector('input[data-key="amp_redirect"]').value = edit_site.amp_redirect ? edit_site.amp_redirect : '';
|
||||
document.querySelector('input[data-key="ld_json"]').value = edit_site.ld_json ? edit_site.ld_json : '';
|
||||
document.querySelector('input[data-key="ld_google_webcache"]').value = edit_site.ld_google_webcache ? edit_site.ld_google_webcache : '';
|
||||
document.querySelector('select[data-key="referer"]').selectedIndex = referer_options.indexOf(edit_site.referer);
|
||||
document.querySelector('select[data-key="random_ip"]').selectedIndex = random_ip_options.indexOf(edit_site.random_ip);
|
||||
});
|
||||
|
@ -288,7 +280,8 @@ function renderOptions() {
|
|||
'block_regex': 0,
|
||||
'amp_unhide': 1,
|
||||
'amp_redirect': 0,
|
||||
'ld_json': 0
|
||||
'ld_json': 0,
|
||||
'ld_google_webcache': 0
|
||||
};
|
||||
for (var key in add_checkboxes) {
|
||||
labelEl = document.createElement('label');
|
||||
|
@ -304,7 +297,8 @@ function renderOptions() {
|
|||
domain: 'example.com',
|
||||
block_regex: '\\.example\\.com\\/js\\/',
|
||||
amp_redirect: 'div.paywall',
|
||||
ld_json: 'div.paywall|div.article'
|
||||
ld_json: 'div.paywall|div.article',
|
||||
ld_google_webcache: 'div.paywall|div.article',
|
||||
};
|
||||
if (placeholders[key])
|
||||
inputEl.placeholder = placeholders[key];
|
||||
|
@ -360,7 +354,8 @@ function renderOptions() {
|
|||
(sites_custom[key]['random_ip'] ? ' | random_ip: ' + sites_custom[key]['random_ip'] : '') +
|
||||
(sites_custom[key]['amp_unhide'] > 0 ? ' | amp_unhide' : '') +
|
||||
(sites_custom[key]['amp_redirect'] ? ' | amp_redirect' : '') +
|
||||
(sites_custom[key]['ld_json'] ? ' | ld_json' : '');
|
||||
(sites_custom[key]['ld_json'] ? ' | ld_json' : '') +
|
||||
(sites_custom[key]['ld_google_webcache'] ? ' | ld_google_webcache' : '');
|
||||
optionEl.value = key;
|
||||
selectEl.add(optionEl);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue