Fix Madsack Mediengruppe

Plus fix custom sites (block_regex)
This commit is contained in:
magnolia1234 2022-11-17 17:20:50 +01:00
parent 7bb5b18685
commit f3f614823e
5 changed files with 30 additions and 21 deletions

View File

@ -6,6 +6,7 @@ var ext_name = manifestData.name;
var ext_version = manifestData.version; var ext_version = manifestData.version;
var navigator_ua = navigator.userAgent; var navigator_ua = navigator.userAgent;
var navigator_ua_mobile = navigator_ua.toLowerCase().includes('mobile'); var navigator_ua_mobile = navigator_ua.toLowerCase().includes('mobile');
var kiwi_browser = navigator_ua_mobile && (url_loc === 'chrome') && !navigator_ua.toLowerCase().includes('yabrowser');
const dompurify_sites = ['arcinfo.ch', 'asiatimes.com', 'bloomberg.com', 'cicero.de', 'ilmanifesto.it', 'iltalehti.fi', 'iltirreno.it', 'ipolitics.ca', 'italiaoggi.it', 'lanuovasardegna.it', 'lequipe.fr', 'lesechos.fr', 'marianne.net', 'mediapart.fr', 'newleftreview.org', 'newscientist.com', 'nzherald.co.nz', 'outlookbusiness.com', 'prospectmagazine.co.uk', 'stratfor.com', 'techinasia.com', 'timesofindia.com', 'valor.globo.com', 'vn.nl'].concat(nl_mediahuis_region_domains, no_nhst_media_domains); const dompurify_sites = ['arcinfo.ch', 'asiatimes.com', 'bloomberg.com', 'cicero.de', 'ilmanifesto.it', 'iltalehti.fi', 'iltirreno.it', 'ipolitics.ca', 'italiaoggi.it', 'lanuovasardegna.it', 'lequipe.fr', 'lesechos.fr', 'marianne.net', 'mediapart.fr', 'newleftreview.org', 'newscientist.com', 'nzherald.co.nz', 'outlookbusiness.com', 'prospectmagazine.co.uk', 'stratfor.com', 'techinasia.com', 'timesofindia.com', 'valor.globo.com', 'vn.nl'].concat(nl_mediahuis_region_domains, no_nhst_media_domains);
var optin_setcookie = false; var optin_setcookie = false;
@ -21,7 +22,6 @@ var restrictions = {
'elespanol.com': /^((?!\/cronicaglobal\.elespanol\.com\/).)*$/, 'elespanol.com': /^((?!\/cronicaglobal\.elespanol\.com\/).)*$/,
'espn.com': /^((?!espn\.com\/watch).)*$/, 'espn.com': /^((?!espn\.com\/watch).)*$/,
'esquire.com': /^((?!\/classic\.esquire\.com\/).)*$/, 'esquire.com': /^((?!\/classic\.esquire\.com\/).)*$/,
'faz.net': /^((?!\.faz\.net\/aktuell\/(\?switchfaznet)?$).)*$/,
'lastampa.it': /^((?!\/video\.lastampa\.it\/).)*$/, 'lastampa.it': /^((?!\/video\.lastampa\.it\/).)*$/,
'lequipe.fr': /^((?!\.lequipe\.fr\/.+\/les-notes\/).)*$/, 'lequipe.fr': /^((?!\.lequipe\.fr\/.+\/les-notes\/).)*$/,
'nknews.org': /^((?!nknews\.org\/pro\/).)*$/, 'nknews.org': /^((?!nknews\.org\/pro\/).)*$/,
@ -157,6 +157,12 @@ function check_sites_updated() {
}); });
} }
function prep_regex_str(str, domain = '') {
if (domain)
str = str.replace(/{domain}/g, domain.replace(/\./g, '\\.'));
return str.replace(/^\//, '').replace(/\/\//g, '/').replace(/([^\\])\/$/, "$1")
}
function set_rules(sites, sites_updated, sites_custom) { function set_rules(sites, sites_updated, sites_custom) {
initSetRules(); initSetRules();
for (let site in sites) { for (let site in sites) {
@ -212,7 +218,7 @@ function set_rules(sites, sites_updated, sites_custom) {
if (rule.hasOwnProperty('block_regex')) { if (rule.hasOwnProperty('block_regex')) {
if (block_regex_default instanceof RegExp) if (block_regex_default instanceof RegExp)
block_regex_default = block_regex_default.source; block_regex_default = block_regex_default.source;
rule.block_regex = '(' + block_regex_default + '|' + rule.block_regex.replace(/(^\/|\/$)/g, '') + ')'; rule.block_regex = '(' + block_regex_default + '|' + prep_regex_str(rule.block_regex, domain) + ')';
} else } else
rule.block_regex = block_regex_default; rule.block_regex = block_regex_default;
} }
@ -237,9 +243,9 @@ function set_rules(sites, sites_updated, sites_custom) {
blockedRegexes[domain] = rule.block_regex; blockedRegexes[domain] = rule.block_regex;
else { else {
try { try {
blockedRegexes[domain] = new RegExp(rule.block_regex.replace(/{domain}/g, domain.replace(/\./g, '\\.')).replace(/(^\/|\/$)/g, '')); blockedRegexes[domain] = new RegExp(prep_regex_str(rule.block_regex, domain));
} catch (e) { } catch (e) {
false; console.log(`regex not valid, error: ${e}`);
} }
} }
} }
@ -248,9 +254,9 @@ function set_rules(sites, sites_updated, sites_custom) {
blockedRegexesGeneral[domain] = {block_regex: rule.block_regex_general}; blockedRegexesGeneral[domain] = {block_regex: rule.block_regex_general};
else { else {
try { try {
blockedRegexesGeneral[domain] = {block_regex: new RegExp(rule.block_regex_general.replace(/(^\/|\/$)/g, ''))}; blockedRegexesGeneral[domain] = {block_regex: new RegExp(prep_regex_str(rule.block_regex_general, domain))};
} catch (e) { } catch (e) {
false; console.log(`regex not valid, error: ${e}`);
} }
} }
blockedRegexesGeneral[domain]['excluded_domains'] = rule.excluded_domains ? rule.excluded_domains : []; blockedRegexesGeneral[domain]['excluded_domains'] = rule.excluded_domains ? rule.excluded_domains : [];
@ -260,9 +266,9 @@ function set_rules(sites, sites_updated, sites_custom) {
blockedJsInline[domain] = rule.block_js_inline; blockedJsInline[domain] = rule.block_js_inline;
else { else {
try { try {
blockedJsInline[domain] = new RegExp(rule.block_js_inline.replace(/{domain}/g, domain.replace(/\./g, '\\.')).replace(/(^\/|\/$)/g, '')); blockedJsInline[domain] = new RegExp(prep_regex_str(rule.block_js_inline, domain));
} catch (e) { } catch (e) {
false; console.log(`regex not valid, error: ${e}`);
} }
} }
} }
@ -781,7 +787,7 @@ if (typeof browser !== 'object') {
ext_api.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { ext_api.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
let tab_status = changeInfo.status; let tab_status = changeInfo.status;
if ((tab_status && tab_status === 'complete') || (!tab_status && changeInfo.url)) { if ((tab_status && tab_status === 'complete') || (!tab_status && changeInfo.url) || kiwi_browser) {
if (/^http/.test(tab.url) && matchUrlDomain(enabledSites, tab.url)) { if (/^http/.test(tab.url) && matchUrlDomain(enabledSites, tab.url)) {
runOnTab(tab); runOnTab(tab);
} }

View File

@ -4,7 +4,9 @@ Changelog Bypass Paywalls Clean - Firefox
Post-release Post-release
Add CNBC (Pro text) Add CNBC (Pro text)
Add Project Syndicate (link to archive.is) Add Project Syndicate (link to archive.is)
Fix Madsack Mediengruppe
Fix The Hill Times (text) Fix The Hill Times (text)
Fix custom sites (block_regex)
* v2.9.3.0 (2022-11-13) * v2.9.3.0 (2022-11-13)
Add Ad.nl (+ regional) & Hln.be (link to archive.is) Add Ad.nl (+ regional) & Hln.be (link to archive.is)

View File

@ -623,7 +623,8 @@ else if (matchDomain('faz.net')) {
} }
} }
let lay_paysocial = document.querySelector('div.lay-PaySocial'); let lay_paysocial = document.querySelector('div.lay-PaySocial');
removeDOMElement(lay_paysocial); let ads = document.querySelectorAll('div.iqadtile_wrapper');
removeDOMElement(lay_paysocial, ...ads);
} }
} }
@ -775,17 +776,17 @@ else if (matchDomain(de_madsack_domains) || matchDomain(de_madsack_custom_domain
let paidcontent_reg = document.querySelector('div.pdb-article-paidcontent-registration'); let paidcontent_reg = document.querySelector('div.pdb-article-paidcontent-registration');
removeDOMElement(paidcontent_reg); removeDOMElement(paidcontent_reg);
} else { } else {
let paywall = document.querySelector('div.paywall'); let paywall = document.querySelector('div.paywalledContent');
if (paywall) { if (paywall) {
paywall.removeAttribute('class');
let gradient = document.querySelector('div[class^="ArticleContentLoaderstyled__Gradient"]'); let gradient = document.querySelector('div[class^="ArticleContentLoaderstyled__Gradient"]');
let loading = document.querySelector('#article > svg'); let loading = document.querySelector('#article > svg');
removeDOMElement(paywall, gradient, loading); removeDOMElement(gradient, loading);
let article = document.querySelector('div[class*="ArticleTeaserContainer"] > div:not([class])'); let article = paywall.querySelector('div:not([class])');
let json_script = getArticleJsonScript(); let json_script = getArticleJsonScript();
if (json_script) { if (json_script) {
let json = JSON.parse(json_script.text); let json = JSON.parse(json_script.text);
if (article && json) { if (article && json) {
article.parentNode.removeAttribute('class');
let json_text = json.articleBody; let json_text = json.articleBody;
let article_new = document.createElement('span'); let article_new = document.createElement('span');
let par = article.querySelector('p'); let par = article.querySelector('p');

View File

@ -145,7 +145,7 @@
}, },
"Lyrik.fr": { "Lyrik.fr": {
"allow_cookies": 1, "allow_cookies": 1,
"block_regex": "\\.qiota\\.com", "block_regex": "\\.qiota\\.com\\/",
"domain": "lyrik.fr" "domain": "lyrik.fr"
}, },
"Mailplus.co.uk": { "Mailplus.co.uk": {
@ -181,7 +181,7 @@
}, },
"Odt.co.nz": { "Odt.co.nz": {
"allow_cookies": 1, "allow_cookies": 1,
"block_regex": "my\\.odt\\.co\\.nz\\/bwtw\\/scripts\\/tw\\.js", "block_regex": "my\\.odt\\.co\\.nz\\/bwtw\\/api\\/TheWall\\/",
"domain": "odt.co.nz" "domain": "odt.co.nz"
}, },
"Physicsworld.com": { "Physicsworld.com": {
@ -194,22 +194,22 @@
}, },
"Pressherald.com": { "Pressherald.com": {
"allow_cookies": 1, "allow_cookies": 1,
"block_regex": "loader-cdn\\.azureedge\\.net", "block_regex": "loader-cdn\\.azureedge\\.net\\/",
"domain": "pressherald.com" "domain": "pressherald.com"
}, },
"Reviewjournal.com": { "Reviewjournal.com": {
"allow_cookies": 1, "allow_cookies": 1,
"block_regex": "js\\.matheranalytics\\.com", "block_regex": "js\\.matheranalytics\\.com\\/",
"domain": "reviewjournal.com" "domain": "reviewjournal.com"
}, },
"Siliconrepublic.com": { "Siliconrepublic.com": {
"allow_cookies": 1, "allow_cookies": 1,
"block_regex": "js\\.pelcro\\.com", "block_regex": "js\\.pelcro\\.com\\/",
"domain": "siliconrepublic.com" "domain": "siliconrepublic.com"
}, },
"Sltrib.com": { "Sltrib.com": {
"allow_cookies": 1, "allow_cookies": 1,
"block_regex": "\\.tinypass\\.com", "block_regex": "\\.tinypass\\.com\\/",
"domain": "sltrib.com" "domain": "sltrib.com"
}, },
"Speld.nl": { "Speld.nl": {

View File

@ -731,5 +731,5 @@
"*://gcm.omerlocdn.com/*", "*://gcm.omerlocdn.com/*",
"*://webcache.googleusercontent.com/*" "*://webcache.googleusercontent.com/*"
], ],
"version": "2.9.3.3" "version": "2.9.3.4"
} }