Fix BusinessPost.ie (link to archive.is)

Maintenance contentScript (sanitize html-input)
This commit is contained in:
magnolia1234 2023-05-08 20:05:06 +02:00
parent 41e40e1d04
commit 9e1e2fd135
12 changed files with 209 additions and 114 deletions

View file

@ -400,7 +400,7 @@ Grouped in options:\
##### United Kingdom/Ireland
[Belfast Telegraph](https://www.belfasttelegraph.co.uk) -
[Business Post](https://www.businesspost.ie) -
[Business Post (link to archive.is)](https://www.businesspost.ie) -
[Citywire](https://www.citywire.com) -
[Euromoney](https://www.euromoney.com) -
[Evening Standard](https://www.standard.co.uk) -

View file

@ -12,6 +12,8 @@ if (typeof ext_api.action !== 'object') {
ext_api.action = ext_api.browserAction;
}
const dompurify_sites = ['arcinfo.ch', 'belfasttelegraph.co.uk', 'bloomberg.com', 'cicero.de', 'defector.com', 'ilmanifesto.it', 'iltirreno.it', 'inc42.com', 'independent.ie', 'ipolitics.ca', 'italiaoggi.it', 'jacobin.de', 'lanuovasardegna.it', 'lecourrierdesstrateges.fr', 'lesechos.fr', 'marianne.net', 'newleftreview.org', 'newscientist.com', 'outlookbusiness.com', 'prospectmagazine.co.uk', 'sloanreview.mit.edu', 'stratfor.com', 'techinasia.com', 'thebulletin.org', 'vn.nl', 'zerohedge.com'].concat(nl_mediahuis_noord_domains, nl_mediahuis_region_domains, no_nhst_media_domains);
var optin_setcookie = false;
var optin_update = true;
var blocked_referer = false;
@ -347,6 +349,9 @@ function set_rules(sites, sites_updated, sites_custom) {
ld_json_next[domain] = rule.ld_json_next;
if (rule.ld_google_webcache)
ld_google_webcache[domain] = rule.ld_google_webcache;
if (rule.ld_json || rule.ld_json_next || rule.ld_google_webcache)
if (!dompurify_sites.includes(domain))
dompurify_sites.push(domain);
if (rule.add_ext_link && rule.add_ext_link_type)
add_ext_link[domain] = {css: rule.add_ext_link, type: rule.add_ext_link_type};
}
@ -383,6 +388,7 @@ ext_api.storage.local.get({
sites_updated: {},
sites_excluded: [],
ext_version_old: '2.3.9.0',
optIn: false,
optInUpdate: true
}, function (items) {
var sites = items.sites;
@ -393,6 +399,7 @@ ext_api.storage.local.get({
updatedSites = items.sites_updated;
updatedSites_domains_new = Object.values(updatedSites).filter(x => (x.domain && !defaultSites_domains.includes(x.domain) || x.group)).map(x => x.group ? x.group.filter(y => !defaultSites_domains.includes(y)) : x.domain).flat();
var ext_version_old = items.ext_version_old;
optin_setcookie = items.optIn;
optin_update = items.optInUpdate;
excludedSites = items.sites_excluded;
@ -532,6 +539,9 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
if (key === 'ext_version_new') {
ext_version_new = storageChange.newValue;
}
if (key === 'optIn') {
optin_setcookie = storageChange.newValue;
}
if (key === 'optInUpdate') {
optin_update = storageChange.newValue;
}
@ -698,6 +708,8 @@ ext_api.webRequest.onHeadersReceived.addListener(function (details) {
function blockJsInlineListener(details) {
let domain = matchUrlDomain(blockedJsInlineDomains, details.url);
let matched = domain && details.url.match(blockedJsInline[domain]);
if (matched && optin_setcookie && ['uol.com.br'].includes(domain))
matched = false;
if (!isSiteEnabled(details) || !matched)
return;
var headers = details.responseHeaders;
@ -737,7 +749,12 @@ if (typeof browser !== 'object') {
let url = tab.url;
let rc_domain = matchUrlDomain(remove_cookies, url);
let rc_domain_enabled = rc_domain && enabledSites.includes(rc_domain);
let lib_file = 'lib/empty.js';
if (matchUrlDomain(dompurify_sites, url))
lib_file = 'lib/purify.min.js';
var bg2csData = {};
if (optin_setcookie && matchUrlDomain(['crusoe.uol.com.br'], url))
bg2csData.optin_setcookie = 1;
if (matchUrlDomain(amp_unhide, url))
bg2csData.amp_unhide = 1;
let amp_redirect_domain = '';
@ -763,12 +780,19 @@ if (typeof browser !== 'object') {
setTimeout(function () {
// run contentScript.js on page
ext_api.tabs.executeScript(tabId, {
file: 'contentScript.js',
file: lib_file,
runAt: 'document_start'
}, function (res) {
if (ext_api.runtime.lastError || res[0]) {
if (ext_api.runtime.lastError)
return;
}
ext_api.tabs.executeScript(tabId, {
file: 'contentScript.js',
runAt: 'document_start'
}, function (res) {
if (ext_api.runtime.lastError || res[0]) {
return;
}
})
});
// send bg2csData to contentScript.js
if (Object.keys(bg2csData).length) {
@ -1277,19 +1301,19 @@ function clear_cookies() {
});
}
function customAddRules(custom_domain, rules) {
if (rules.allow_cookies && !allow_cookies.includes(custom_domain))
function customAddRules(custom_domain, rule) {
if (rule.allow_cookies && !allow_cookies.includes(custom_domain))
allow_cookies.push(custom_domain);
if (rules.remove_cookies && !remove_cookies.includes(custom_domain))
if (rule.remove_cookies && !remove_cookies.includes(custom_domain))
remove_cookies.push(custom_domain);
let custom_block_regex = rules.block_regex;
let custom_block_regex = rule.block_regex;
if (custom_block_regex) {
if ((typeof custom_block_regex === 'string') && custom_block_regex.includes('{domain}'))
custom_block_regex = new RegExp(custom_block_regex.replace('{domain}', custom_domain.replace(/\./g, '\\.')));
blockedRegexes[custom_domain] = custom_block_regex;
blockedRegexesDomains = Object.keys(blockedRegexes);
}
let custom_useragent = rules.useragent;
let custom_useragent = rule.useragent;
if (custom_useragent) {
if (custom_useragent === 'googlebot') {
if (!use_google_bot.includes(custom_domain))
@ -1297,7 +1321,7 @@ function clear_cookies() {
change_headers.push(custom_domain);
}
}
let custom_referer = rules.referer;
let custom_referer = rule.referer;
if (custom_referer) {
if (custom_referer === 'twitter') {
if (!use_twitter_referer.includes(custom_domain))
@ -1305,16 +1329,21 @@ function clear_cookies() {
change_headers.push(custom_domain);
}
}
if (rules.amp_unhide) {
if (rule.amp_unhide) {
if (!amp_unhide.includes(custom_domain))
amp_unhide.push(custom_domain);
}
if (rules.ld_json)
ld_json[custom_domain] = rules.ld_json;
if (rules.ld_json_next)
ld_json_next[custom_domain] = rules.ld_json_next;
if (rules.add_ext_link && rules.add_ext_link_type)
add_ext_link[custom_domain] = {css: rules.add_ext_link, type: rules.add_ext_link_type};
if (rule.ld_json)
ld_json[custom_domain] = rule.ld_json;
if (rule.ld_json_next)
ld_json_next[custom_domain] = rule.ld_json_next;
if (rule.ld_google_webcache)
ld_google_webcache[domain] = rule.ld_google_webcache;
if (rule.ld_json || rule.ld_json_next || rule.ld_google_webcache)
if (!dompurify_sites.includes(custom_domain))
dompurify_sites.push(custom_domain);
if (rule.add_ext_link && rule.add_ext_link_type)
add_ext_link[custom_domain] = {css: rule.add_ext_link, type: rule.add_ext_link_type};
ext_api.tabs.reload({bypassCache: true});
}
@ -1443,6 +1472,19 @@ ext_api.runtime.onMessage.addListener(function (message, sender) {
}
});
// show the opt-in tab on installation
ext_api.storage.local.get(["optInShown", "customShown"], function (result) {
if (!result.optInShown || !result.customShown) {
ext_api.tabs.create({
url: "options/optin/opt-in.html"
});
ext_api.storage.local.set({
"optInShown": true,
"customShown": true
});
}
});
function filterObject(obj, filterFn, mapFn = function (val, key) {
return [key, val];
}) {

View file

@ -37,4 +37,8 @@ function currentDateStr() {
}
var last_date_str = currentDateStr();
var daily_users;
bpc_count_daily_users(last_date_str);
ext_api.storage.local.get({counter: true}, function (result) {
if (result.counter)
bpc_count_daily_users(last_date_str);
});

View file

@ -4,6 +4,8 @@ Updates (install signed xpi-file): https://gitlab.com/magnolia1234/bypass-paywal
Post-release
Remove Medienhaus Aachen (fix obsolete)
Fix BusinessPost.ie (link to archive.is)
Maintenance contentScript (sanitize html-input)
* v3.1.7.0 (2023-05-07)
Add Cairns Post, Geelong Advertiser & Townsville Bulletin (Australia News Corp)

View file

@ -3,6 +3,7 @@ var ext_api = (typeof browser === 'object') ? browser : chrome;
var domain;
var csDone = false;
var csDoneOnce = false;
var dompurify_loaded = (typeof DOMPurify === 'function');
var ar_grupo_clarin_domains = ['clarin.com', 'lavoz.com.ar', 'losandes.com.ar'];
var be_groupe_ipm_domains = ['dhnet.be', 'lalibre.be', 'lavenir.net'];
@ -52,9 +53,9 @@ if (!matchDomain(arr_localstorage_hold)) {
window.localStorage.clear();
}
function runOnMessage(bg2csData) {
function runOnMessage(bg2csData, dompurify_loaded) {
// custom/updated sites: load text from json
if (bg2csData.ld_json) {
if (bg2csData.ld_json && dompurify_loaded) {
if (bg2csData.ld_json.includes('|')) {
window.setTimeout(function () {
let ld_json_split = bg2csData.ld_json.split('|');
@ -80,7 +81,7 @@ if (bg2csData.ld_json) {
}
if (json_text && article.parentNode) {
let parser = new DOMParser();
let doc = parser.parseFromString('<div style="margin: 25px 0px">' + json_text + '</div>', 'text/html');
let doc = parser.parseFromString('<div style="margin: 25px 0px">' + DOMPurify.sanitize(json_text) + '</div>', 'text/html');
let article_new = doc.querySelector('div');
if (article_append || !article.parentNode) {
article.innerHTML = '';
@ -97,7 +98,7 @@ if (bg2csData.ld_json) {
}
}
if (bg2csData.ld_json_next) {
if (bg2csData.ld_json_next && dompurify_loaded) {
if (bg2csData.ld_json_next.includes('|')) {
window.setTimeout(function () {
let ld_json_next_split = bg2csData.ld_json_next.split('|');
@ -117,7 +118,7 @@ if (bg2csData.ld_json_next) {
let json_text = parseHtmlEntities(findKeyJson(json, ['body', 'content', 'description'], 500));
if (json_text && article.parentNode) {
let parser = new DOMParser();
let doc = parser.parseFromString('<div>' + json_text + '</div>', 'text/html');
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text) + '</div>', 'text/html');
let article_new = doc.querySelector('div');
if (article_append || !article.parentNode) {
article.innerHTML = '';
@ -132,7 +133,7 @@ if (bg2csData.ld_json_next) {
}
// custom/updated sites: load text from Google webcache
if (bg2csData.ld_google_webcache) {
if (bg2csData.ld_google_webcache && dompurify_loaded) {
if (bg2csData.ld_google_webcache.includes('|')) {
window.setTimeout(function () {
let url = window.location.href;
@ -184,6 +185,14 @@ if (bg2csData.add_ext_link) {
}
}
// check for opt-in confirmation (from background.js)
if (bg2csData.optin_setcookie) {
if (matchDomain(['crusoe.uol.com.br'])) {
if (!cookieExists('crs_subscriber'))
setCookie('crs_subscriber', 1, 'crusoe.uol.com.br', '/', 14);
}
}
// custom/updated sites: try to unhide text on amp-page
if (bg2csData.amp_unhide) {
window.setTimeout(function () {
@ -255,7 +264,7 @@ if (ext_api.runtime) {
function (request, sender) {
if (request.msg === 'bg2cs' && !msg_once) {
msg_once = true;
runOnMessage(request.data);
runOnMessage(request.data, dompurify_loaded);
}
})
}
@ -560,7 +569,7 @@ else if (matchDomain('allgaeuer-zeitung.de')) {
else if (matchDomain('arcinfo.ch')) {
let paywall = document.querySelector('section#paywall-articles');
if (paywall) {
if (paywall && dompurify_loaded) {
removeDOMElement(paywall);
let url_id = window.location.pathname.match(/\d+$/).pop();
let html = document.documentElement.outerHTML;
@ -589,7 +598,7 @@ else if (matchDomain('arcinfo.ch')) {
if (content) {
content = content.replace(/\\u003C/g, '<').replace(/\\u003E/g, '>').replace(/\\u002F/g, '/').replace(/\\"/g, '"').replace(/\\r\\n/g, '');
let parser = new DOMParser();
let content_new = parser.parseFromString('<div class="html-content">' + content + '</div>', 'text/html');
let content_new = parser.parseFromString('<div class="html-content">' + DOMPurify.sanitize(content) + '</div>', 'text/html');
let article_top;
if (!no_intro) {
article_top = article.parentNode.parentNode;
@ -773,7 +782,7 @@ else if (matchDomain('jacobin.de')) {
}
let content = par.text.replace(/&nbsp;/g, '');
let parser = new DOMParser();
let content_new = parser.parseFromString('<' + elem_type + ' class="' + elem_class + (elem_style ? '" style="' + elem_style : '') + '">' + content + '</' + elem_type + 'p>', 'text/html');
let content_new = parser.parseFromString('<' + elem_type + ' class="' + elem_class + (elem_style ? '" style="' + elem_style : '') + '">' + DOMPurify.sanitize(content) + '</' + elem_type + 'p>', 'text/html');
article.appendChild(content_new.querySelector(elem_type));
} else
console.log(par);
@ -1046,7 +1055,6 @@ else if (matchDomain(de_vrm_domains) || document.querySelector('meta[name^="cXen
let pars = json_text.split(/(?=<p>)/);
let page_items = json.contentPage.data.context.elements;
if (json_text && page_items) {
let parser = new DOMParser();
let n = 0;
let new_article = document.createElement('div');
new_article.setAttribute('style', 'font-size: 17px; font-family:Calibri, Helvetica, Arial; margin: auto; max-width: 620px;');
@ -1565,7 +1573,7 @@ else if (matchDomain('lanouvellerepublique.fr')) {
else if (matchDomain('lecourrierdesstrateges.fr')) {
window.setTimeout(function () {
let paywall = document.querySelector('div.jpw-truncate-btn');
if (paywall) {
if (paywall && dompurify_loaded) {
removeDOMElement(paywall);
let json_script = getArticleJsonScript();
if (json_script) {
@ -1575,7 +1583,7 @@ else if (matchDomain('lecourrierdesstrateges.fr')) {
let content = document.querySelector('div.content-inner');
if (json_text && content) {
let parser = new DOMParser();
let doc = parser.parseFromString('<div>' + json_text + '</div>', 'text/html');
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text) + '</div>', 'text/html');
let content_new = doc.querySelector('div');
content.parentNode.replaceChild(content_new, content);
let hidden_images = document.querySelectorAll('img[src][srcset]');
@ -1668,7 +1676,7 @@ else if (matchDomain('lesechos.fr')) {
let abo_banner = document.querySelector('div[class*="pgxf3b-2"]');
let ad_blocks = document.querySelectorAll('[class*="jzxvkd"]');
hideDOMElement(...ad_blocks);
if (abo_banner) {
if (abo_banner && dompurify_loaded) {
removeDOMElement(abo_banner);
let url = window.location.href;
let html = document.documentElement.outerHTML;
@ -1686,7 +1694,7 @@ else if (matchDomain('lesechos.fr')) {
if (paywallNode) {
let contentNode = document.createElement('div');
let parser = new DOMParser();
let article_html = parser.parseFromString('<div>' + article + '</div>', 'text/html');
let article_html = parser.parseFromString('<div>' + DOMPurify.sanitize(article) + '</div>', 'text/html');
let article_par = article_html.querySelector('div');
if (article_par) {
contentNode.appendChild(article_par);
@ -1740,12 +1748,12 @@ else if (matchDomain('loeildelaphotographie.com')) {
else if (matchDomain('marianne.net')) {
let paywall = document.querySelector('div.paywall');
if (paywall) {
if (paywall && dompurify_loaded) {
let article_source = document.querySelector('div.article-body[data-content-src]');
if (article_source) {
let article_text = decode_utf8(atob(article_source.getAttribute('data-content-src')));
let parser = new DOMParser();
let html = parser.parseFromString('<div>' + article_text + '</div>', 'text/html');
let html = parser.parseFromString('<div>' + DOMPurify.sanitize(article_text) + '</div>', 'text/html');
let article = html.querySelector('div');
article_source.innerHTML = '';
article_source.appendChild(article);
@ -1904,7 +1912,7 @@ else if (matchDomain('ilmanifesto.it')) {
window.setTimeout(function () {
if (window.location.pathname.match(/((\w)+(\-)+){3,}/)) {
let paywall = document.querySelector('div[class^="PostPaywall_PostPaywall__"]');
if (paywall) {
if (paywall && dompurify_loaded) {
removeDOMElement(paywall);
let json_script = document.querySelector('script#__NEXT_DATA__');
if (json_script) {
@ -1915,7 +1923,7 @@ else if (matchDomain('ilmanifesto.it')) {
if (article) {
article.innerHTML = '';
let parser = new DOMParser();
let doc = parser.parseFromString('<div>' + article_new + '</div>', 'text/html');
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(article_new) + '</div>', 'text/html');
let content_new = doc.querySelector('div');
article.appendChild(content_new);
}
@ -1936,7 +1944,7 @@ else if (matchDomain('ilmanifesto.it')) {
else if (matchDomain(['iltirreno.it', 'lanuovasardegna.it'])) {
if (window.location.pathname.includes('/news/')) {
let paywall = document.querySelector('div.MuiBox-root > h4.MuiTypography-h4');
if (paywall) {
if (paywall && dompurify_loaded) {
let article = document.querySelector('div.MuiGrid-root.MuiGrid-grid-sm-7 > div');
if (article) {
removeDOMElement(paywall.parentNode);
@ -1952,7 +1960,7 @@ else if (matchDomain(['iltirreno.it', 'lanuovasardegna.it'])) {
let article_new = JSON.parse(json.text).props.pageProps.article.content;
if (article_new) {
let parser = new DOMParser();
let doc = parser.parseFromString('<div>' + article_new + '</div>', 'text/html');
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(article_new) + '</div>', 'text/html');
let content_new = doc.querySelector('div');
article.innerHTML = '';
article.appendChild(content_new);
@ -1999,7 +2007,7 @@ else if (matchDomain(it_quotidiano_domains)) {
else if (matchDomain('italiaoggi.it')) {
let paywall = document.querySelector('div.boxAbb');
if (paywall) {
if (paywall && dompurify_loaded) {
let overlay = document.querySelector('div.article-locked-overlay');
removeDOMElement(paywall, overlay);
let article_locked = document.querySelector('div.article-locked');
@ -2014,7 +2022,7 @@ else if (matchDomain('italiaoggi.it')) {
if (json_text && content) {
let parser = new DOMParser();
json_text = json_text.replace(/&amp;apos;/g, "'").replace(/;/g, '');
let doc = parser.parseFromString('<div><section>' + json_text + '</section></div>', 'text/html');
let doc = parser.parseFromString('<div><section>' + DOMPurify.sanitize(json_text) + '</section></div>', 'text/html');
let content_new = doc.querySelector('div');
content.parentNode.replaceChild(content_new, content);
}
@ -2138,7 +2146,7 @@ else if (matchDomain(be_roularta_domains)) {
else if (matchDomain(['lc.nl', 'dvhn.nl'])) {
if (true) {
let paywall = document.querySelector('div.signupPlus, div.pw-wrapper');
if (paywall) {
if (paywall && dompurify_loaded) {
let intro = document.querySelector('div.startPayWall');
removeDOMElement(paywall, intro);
let html = document.documentElement.outerHTML;
@ -2170,7 +2178,7 @@ else if (matchDomain(['lc.nl', 'dvhn.nl'])) {
if (par.typename === 'HTMLCustomEmbed') {
if (par.code) {
let parser = new DOMParser();
let article_html = parser.parseFromString('<div>' + par.code + '</div>', 'text/html');
let article_html = parser.parseFromString('<div>' + DOMPurify.sanitize(par.code) + '</div>', 'text/html');
elem = article_html.querySelector('div');
}
} else if (par.insertbox_head || par.insertbox_text) {
@ -2251,7 +2259,7 @@ else if (matchDomain(nl_mediahuis_region_domains)) {
if (close_button)
close_button.click();
let premium = document.querySelector('div.common-components-plus_pluslabel--container');
if (premium) {
if (premium && dompurify_loaded) {
let hidden_article = document.querySelector('div[data-auth-body="article"]');
if (hidden_article)
hidden_article.removeAttribute('style');
@ -2275,7 +2283,7 @@ else if (matchDomain(nl_mediahuis_region_domains)) {
par_elem = '';
par_key = par[key];
if (key === 'subhead') {
par_html = parser.parseFromString('<div><strong>' + par_key + '</strong></div>', 'text/html');
par_html = parser.parseFromString('<div><strong>' + DOMPurify.sanitize(par_key) + '</strong></div>', 'text/html');
par_elem = par_html.querySelector('div');
} else if (key === 'twitter' || key === 'instagram') {
par_elem = document.createElement('a');
@ -2313,7 +2321,7 @@ else if (matchDomain(nl_mediahuis_region_domains)) {
par_div.innerText += par[key].credit ? '\n' + par[key].credit : '';
par_elem.appendChild(par_div);
} else {
par_html = parser.parseFromString('<p style="font-size: 18px; line-height: 1.625;">' + par_key + '</div>', 'text/html');
par_html = parser.parseFromString('<p style="font-size: 18px; line-height: 1.625;">' + DOMPurify.sanitize(par_key) + '</div>', 'text/html');
par_elem = par_html.querySelector('p');
}
if (par_elem)
@ -2424,7 +2432,7 @@ else if (matchDomain('telegraaf.nl')) {
else if (matchDomain('vn.nl')) {
let paywall = document.querySelector('div.content__message-no-access-container');
if (paywall) {
if (paywall && dompurify_loaded) {
let content_restriction = document.querySelector('div.content__restriction');
removeDOMElement(paywall, content_restriction);
let body = document.querySelector('body');
@ -2444,7 +2452,7 @@ else if (matchDomain('vn.nl')) {
let content = document.querySelector('div[data-article-content-target]');
if (json_text && content) {
let parser = new DOMParser();
let doc = parser.parseFromString('<div data-article-content-target>' + json_text + '</div>', 'text/html');
let doc = parser.parseFromString('<div data-article-content-target>' + DOMPurify.sanitize(json_text, {ADD_TAGS: ['iframe'], ADD_ATTR: ['frameborder']}) + '</div>', 'text/html');
let content_new = doc.querySelector('div');
content.parentNode.replaceChild(content_new, content);
}
@ -2462,7 +2470,7 @@ else
if (matchDomain(['belfasttelegraph.co.uk', 'independent.ie'])) {
let flip_pay = document.querySelector('div#flip-pay[style]');
if (flip_pay) {
if (flip_pay && dompurify_loaded) {
let content = document.querySelector('script[data-fragment-type="ArticleContent"]');
if (content) {
removeDOMElement(flip_pay);
@ -2511,7 +2519,7 @@ if (matchDomain(['belfasttelegraph.co.uk', 'independent.ie'])) {
}
}
} else if (type !== 'ad') {
let html = parser.parseFromString('<p style="font-size: 18px; font-family: Georgia, serif; margin: 10px;">' + item + '</p>', 'text/html');
let html = parser.parseFromString('<p style="font-size: 18px; font-family: Georgia, serif; margin: 10px;">' + DOMPurify.sanitize(item, {ADD_TAGS: ['iframe']}) + '</p>', 'text/html');
elem = html.querySelector('p');
if (!['p', 'subhead', 'legacy-ml'].includes(type)) {
console.log(type);
@ -2538,47 +2546,14 @@ if (matchDomain(['belfasttelegraph.co.uk', 'independent.ie'])) {
}
else if (matchDomain('businesspost.ie')) {
function bpie_main() {
if ($) {
let article_id_dom = document.querySelector('article[id]');
let article_id;
if (article_id_dom)
article_id = article_id_dom.id;
if (article_id) {
let bp_ajaxurl = 'https://www.businesspost.ie/wp-admin/admin-ajax.php';
let data_ajax = {
action: 'fetch_article_content',
type: 'POST',
data: {
id: article_id
},
dataType: 'json',
contentType: 'application/json'
};
$.ajax({
type: 'POST',
url: bp_ajaxurl,
data: data_ajax,
success: function (data) {
$('main article .article-body-section').html(data);
}
});
}
} else
window.location.reload(true);
let url = window.location.href;
let paywall = document.querySelector('div#bp_paywall_content');
if (paywall) {
removeDOMElement(paywall);
let article = document.querySelector('div.article-body-section');
if (article)
article.firstChild.before(archiveLink(url));
}
csDoneOnce = true;
window.setTimeout(function () {
let paywall = document.querySelector('div#bp_paywall_content');
let article_id_dom = document.querySelector('article[id]');
let article_id;
if (article_id_dom)
article_id = article_id_dom.id;
if (paywall || article_id) {
removeDOMElement(paywall);
insert_script(bpie_main);
}
}, 500);
}
else if (matchDomain('citywire.com')) {
@ -2740,8 +2715,6 @@ else if (matchDomain(ar_grupo_clarin_domains)) {
}
else if (matchDomain('crusoe.uol.com.br')) {
if (!cookieExists('crs_subscriber'))
setCookie('crs_subscriber', 1, 'crusoe.uol.com.br', '/', 14);
let paywall = document.querySelector('#wallcontent');
let ads = document.querySelectorAll('#gpt-leaderboard, .ads_desktop, .catchment-box');
removeDOMElement(paywall, ...ads);
@ -3064,7 +3037,7 @@ else if (matchDomain('bloomberg.com')) {
}
let shimmering_content = document.querySelectorAll('div.shimmering-text');
let body_transparent = document.querySelector('div[class*="nearly-transparent-text-blur"]');
if (shimmering_content.length || body_transparent) {
if ((shimmering_content.length || body_transparent) && dompurify_loaded) {
removeDOMElement(...shimmering_content);
if (body_transparent)
removeClassesByPrefix(body_transparent, 'nearly-transparent-text-blur');
@ -3092,7 +3065,7 @@ else if (matchDomain('bloomberg.com')) {
if (article) {
article_class += ' art_done';
let parser = new DOMParser();
let doc = parser.parseFromString('<div class="' + article_class + '">' + json_text + '</div>', 'text/html');
let doc = parser.parseFromString('<div class="' + article_class + '">' + DOMPurify.sanitize(json_text, {ADD_TAGS: ['iframe', 'script']}) + '</div>', 'text/html');
let article_new = doc.querySelector('div');
if (article_new) {
article.parentNode.replaceChild(article_new, article);
@ -3255,7 +3228,7 @@ else if (matchDomain('dallasnews.com')) {
else if (matchDomain('defector.com')) {
let paywall = document.querySelector('[class^="ContentGate_wrapper__"]');
if (paywall) {
if (paywall && dompurify_loaded) {
removeDOMElement(paywall);
let url = window.location.href;
try {
@ -3268,7 +3241,7 @@ else if (matchDomain('defector.com')) {
let article_new = doc.querySelector('div[class^="PostContent_wrapper__"]');
let article = document.querySelector('div[class^="PostContent_wrapper__"]');
if (article && article_new)
article.parentNode.replaceChild(article_new, article);
article.parentNode.replaceChild(DOMPurify.sanitize(article_new), article);
});
}
});
@ -3659,7 +3632,7 @@ else if (matchDomain('inkl.com')) {
else if (matchDomain('ipolitics.ca')) {
let login = document.querySelector('div.login');
if (login) {
if (login && dompurify_loaded) {
removeDOMElement(login);
let json_script = document.querySelector('script#__NEXT_DATA__');
if (json_script) {
@ -3675,7 +3648,7 @@ else if (matchDomain('ipolitics.ca')) {
article.innerHTML = '';
article.classList.remove('locked');
let parser = new DOMParser();
let doc = parser.parseFromString('<div>' + article_new + '</div>', 'text/html');
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(article_new) + '</div>', 'text/html');
let content_new = doc.querySelector('div');
article.appendChild(content_new);
}
@ -3910,7 +3883,7 @@ else if (matchDomain('nzherald.co.nz')) {
else if (matchDomain('outlookbusiness.com')) {
let paywall = document.querySelector('div#csc-paywall');
if (paywall) {
if (paywall && dompurify_loaded) {
removeDOMElement(paywall);
let json_script = document.querySelector('script#__NEXT_DATA__');
if (json_script) {
@ -3921,7 +3894,7 @@ else if (matchDomain('outlookbusiness.com')) {
if (article) {
article.innerHTML = '';
let parser = new DOMParser();
let doc = parser.parseFromString('<div>' + article_new + '</div>', 'text/html');
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(article_new) + '</div>', 'text/html');
let content_new = doc.querySelector('div');
article.appendChild(content_new);
}
@ -4156,7 +4129,7 @@ else if (matchDomain('stratfor.com')) {
hidden_image.setAttribute('src', hidden_image.getAttribute('data-src'));
if (window.location.pathname.match(/(\/(\d){4}-([a-z]|-)+-forecast(-([a-z]|-)+)?|-forecast-(\d){4}-([a-z]|[0-9]|-)+)$/)) {
let json_script = document.querySelector('script#__NEXT_DATA__');
if (json_script) {
if (json_script && dompurify_loaded) {
let json = JSON.parse(json_script.innerText);
if (json && json.props.pageProps.data) {
let overview_div = document.querySelector('div[class^="overview_overview__"] > div');
@ -4166,7 +4139,7 @@ else if (matchDomain('stratfor.com')) {
let data_overview = data.overview;
if (!parseHtmlEntities(data_overview).includes(data.teaser_body))
data_overview = '<p>' + data.teaser_body + '</p>' + data_overview;
let doc = parser.parseFromString('<div>' + data_overview + '<p><h2>Sections</h2></p>' + '</div>', 'text/html');
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(data_overview) + '<p><h2>Sections</h2></p>' + '</div>', 'text/html');
let content_new = doc.querySelector('div');
let sections = data.section;
for (let section of sections) {
@ -4215,7 +4188,7 @@ else if (matchDomain('studocu.com')) {
else if (matchDomain('techinasia.com')) {
let paywall = document.querySelector('.paywall-content');
if (paywall) {
if (paywall && dompurify_loaded) {
paywall.classList.remove('paywall-content');
let url = window.location.href;
let url_xhr = url.replace('.com/', '.com/wp-json/techinasia/2.0/posts/').replace('/visual-story/', '/');
@ -4228,7 +4201,7 @@ else if (matchDomain('techinasia.com')) {
let content = document.querySelector('div.content');
if (json_text && content) {
let parser = new DOMParser();
let doc = parser.parseFromString('<div class="jsx-1794864983 content">' + json_text + '</div>', 'text/html');
let doc = parser.parseFromString('<div class="jsx-1794864983 content">' + DOMPurify.sanitize(json_text) + '</div>', 'text/html');
let content_new = doc.querySelector('div.content');
content.parentNode.replaceChild(content_new, content);
}
@ -4639,7 +4612,7 @@ else if (matchDomain(no_nhst_media_domains)) {
} else {
window.setTimeout(function () {
let paywall = document.querySelector('iframe#paywall-iframe');
if (paywall) {
if (paywall && dompurify_loaded) {
let intro = document.querySelector('div.global-article-selector');
let article = paywall.parentNode;
removeDOMElement(paywall, intro);
@ -4654,7 +4627,7 @@ else if (matchDomain(no_nhst_media_domains)) {
if (json) {
let json_text = json.article.body;
let parser = new DOMParser();
let doc = parser.parseFromString('<div>' + json_text + '</div>', 'text/html');
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text, {ADD_ATTR: ['itemprop'], ADD_TAGS: ['link']}) + '</div>', 'text/html');
let article_new = doc.querySelector('div');
if (article_new) {
if (article)
@ -4785,7 +4758,7 @@ else if (matchDomain('wsj.com')) {
else if (matchDomain('zerohedge.com')) {
window.setTimeout(function () {
let paywall = document.querySelector('div[class^="PremiumOverlay_container__"]');
if (paywall) {
if (paywall && dompurify_loaded) {
removeDOMElement(paywall);
let json_script = document.querySelector('script#__NEXT_DATA__');
if (json_script) {
@ -4797,7 +4770,7 @@ else if (matchDomain('zerohedge.com')) {
if (article) {
article.innerHTML = '';
let parser = new DOMParser();
let doc = parser.parseFromString('<div>' + article_new + '</div>', 'text/html');
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(article_new) + '</div>', 'text/html');
let content_new = doc.querySelector('div');
article.appendChild(content_new);
}
@ -5012,7 +4985,8 @@ function replaceDomElementExtSrc(url, html, proxy, base64, selector, text_fail =
}
let parser = new DOMParser();
window.setTimeout(function () {
let doc = parser.parseFromString(html, 'text/html');
let doc = parser.parseFromString(DOMPurify.sanitize(html, {ADD_ATTR: ['layout', 'itemprop'], ADD_TAGS: ['amp-img', 'iframe']}), 'text/html');
//console.log(DOMPurify.removed);
let article_new = doc.querySelector(selector_source);
if (article_new) {
if (article && article.parentNode)

View file

@ -51,5 +51,5 @@
"webRequestBlocking",
"*://*/*"
],
"version": "3.1.7.1"
"version": "3.1.7.2"
}

0
lib/empty.js Normal file
View file

3
lib/purify.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -754,5 +754,5 @@
"*://html.onlineviewer.net/*",
"*://webcache.googleusercontent.com/*"
],
"version": "3.1.7.1"
"version": "3.1.7.2"
}

View file

@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bypass Paywalls Clean (setCookie/custom sites opt-in)</title>
<title>Bypass Paywalls Clean (setCookie, custom sites & check update opt-in)</title>
<link rel="stylesheet" href="../options_all.css"/>
<link rel="stylesheet" href="opt-in.css"/>
<script src="opt-in.js"></script>
@ -12,9 +12,18 @@
<body>
<div>
<p><strong>Bypass Paywalls Clean<br> - custom sites/check update opt-in</strong></p>
<p><strong>Bypass Paywalls Clean<br> - setCookie, custom sites & check update opt-in</strong></p>
</div>
</div>
<div id="opt-in-prompt">
<p><strong>setCookie opt-in</strong></p>
<p>For some sites a necessary cookie has to be set (this cookie doesn't contain any personal information about the user or device):<br><br>
Crusoé</p>
<p>setCookie opt-in enabled: <span id="opt-in-enabled"></span></p>
<div id="optin-container">
<button id="optin-enable">Enable</button>
<button id="optin-disable">Disable</button>
</div>
<div id="custom-prompt">
<p><strong>custom sites opt-in</strong></p>
<p>If you want to enable custom sites and also have the option to remove cookies/block general paywall-scripts of 'unlisted' sites:</br>
@ -33,6 +42,15 @@
<button id="update-enable">Enable</button>
<button id="update-disable">Disable</button>
</div>
</div>
<div id="counter-prompt">
<p><strong>daily users counter opt-in</strong></p>
<p>Very basic daily users counter (by counting the download of an empty json-file (no personal information is shared)):</br>
<p>daily users counter enabled: <span id="counter-enabled"></span></p>
<div id="custom-container">
<button id="counter-enable">Enable</button>
<button id="counter-disable">Disable</button>
</div>
</div>
<p>
<div style='float:left;padding-bottom:50px'>

View file

@ -7,9 +7,34 @@ var custom_switch = ((manifestData.optional_permissions && manifestData.optional
window.addEventListener("load", function () {
document.getElementById("button-close").addEventListener("click", function () {
ext_api.storage.local.set({
"optInShown": true,
"customShown": true
});
window.close();
});
var opt_in_enabled = document.getElementById('opt-in-enabled');
ext_api.storage.local.get("optIn", function (result) {
opt_in_enabled.innerText = result.optIn ? 'YES' : 'NO';
});
document.getElementById("optin-enable").addEventListener("click", function () {
ext_api.storage.local.set({
"optIn": true,
"optInShown": true
});
opt_in_enabled.innerText = 'YES';
});
document.getElementById("optin-disable").addEventListener("click", function () {
ext_api.storage.local.set({
"optIn": false,
"optInShown": true
});
opt_in_enabled.innerText = 'NO';
});
var custom_enabled = document.getElementById('custom-enabled');
ext_api.permissions.contains({
origins: ["*://*/*"]
@ -35,6 +60,9 @@ window.addEventListener("load", function () {
} else {
custom_enabled.innerText = 'NO';
}
ext_api.storage.local.set({
"customShown": true
});
});
});
@ -48,6 +76,9 @@ window.addEventListener("load", function () {
"customOptIn": false
});
}
ext_api.storage.local.set({
"customShown": true
});
});
});
@ -71,4 +102,23 @@ window.addEventListener("load", function () {
});
update_enabled.innerText = 'NO';
});
var counter_enabled = document.getElementById('counter-enabled');
ext_api.storage.local.get({counter: true}, function (result) {
counter_enabled.innerText = result.counter ? 'YES' : 'NO';
});
document.getElementById("counter-enable").addEventListener("click", function () {
ext_api.storage.local.set({
"counter": true
});
counter_enabled.innerText = 'YES';
});
document.getElementById("counter-disable").addEventListener("click", function () {
ext_api.storage.local.set({
"counter": false
});
counter_enabled.innerText = 'NO';
});
});

View file

@ -270,7 +270,7 @@ var defaultSites = {
allow_cookies: 1,
block_regex: /(\.tinypass\.com\/|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/
},
"Business Post.ie": {
"Business Post.ie (link to archive.is)": {
domain: "businesspost.ie",
allow_cookies: 1,
block_regex: /\.piano\.io\//
@ -2198,6 +2198,7 @@ var defaultSites = {
"UOL.com.br": {
domain: "uol.com.br",
allow_cookies: 1,
block_js_inline: /crusoe\.uol\.com\.br\/(diario|edicoes)\/.+/,
block_regex: /(paywall\.folha\.uol\.com\.br\/|\.(tinypass|matheranalytics)\.com\/|cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js)/,
useragent: "googlebot"
},
@ -2512,6 +2513,7 @@ expandSiteRules(defaultSites);
var au_news_corp_domains = grouped_sites['###_au_news_corp'];
var de_madsack_domains = grouped_sites['###_de_madsack'];
var es_grupo_vocento_domains = grouped_sites['###_es_grupo_vocento'];
var nl_mediahuis_noord_domains = grouped_sites['###_nl_mediahuis_noord'];
var nl_mediahuis_region_domains = grouped_sites['###_nl_mediahuis_region'];
var no_nhst_media_domains = grouped_sites['###_no_nhst_media'];