Fix Bar and Bench & The News Minute

This commit is contained in:
magnolia1234 2024-03-21 20:32:49 +01:00
parent 137fcd525c
commit 3b337501d6
8 changed files with 92 additions and 46 deletions

View file

@ -5,10 +5,12 @@ Updates (install signed xpi-file): https://gitlab.com/magnolia1234/bypass-paywal
Post-release Post-release
Add Blick.ch (Ringier Gruppe) Add Blick.ch (Ringier Gruppe)
Add CNN (regwall) Add CNN (regwall)
Fix Bar and Bench (json)
Fix Expresso.pt (json) Fix Expresso.pt (json)
Fix Haaretz Group (anti-adblocker) Fix Haaretz Group (anti-adblocker)
Fix Newsweek.pl (css) Fix Newsweek.pl (css)
Fix The Athletic (scroll) Fix The Athletic (scroll)
Fix The News Minute (json)
* v3.6.0.0 (2024-03-17) * v3.6.0.0 (2024-03-17)
Add Courrier international Add Courrier international

View file

@ -3743,23 +3743,15 @@ else if (matchDomain('balkaninsight.com')) {
getJsonUrl('div.subscribeWrapper', '', 'div.post_teaser', {art_append: true, art_hold: true}); getJsonUrl('div.subscribeWrapper', '', 'div.post_teaser', {art_append: true, art_hold: true});
} }
else if (matchDomain('barandbench.com')) { else if (matchDomain(['barandbench.com', 'thenewsminute.com'])) {
let paywall = document.querySelector('div#paywall-banner'); let paywall = document.querySelector('div[id*="paywall-banner"]');
if (paywall) { if (paywall && dompurify_loaded) {
removeDOMElement(paywall); removeDOMElement(paywall);
let fade = document.querySelector('div[class^="paywall-story-styles-"]'); let article = document.querySelector('div[class^="paywall-story-"]');
if (fade) if (article) {
fade.removeAttribute('class'); let article_new = getArticleQuintype();
let json_script = getArticleJsonScript(); if (article_new && article.parentNode)
if (json_script) { article.parentNode.replaceChild(article_new, article);
let json = JSON.parse(json_script.text);
if (json) {
let json_text = json.articleBody;
let content = document.querySelector('div.arr--story-page-card-wrapper');
if (json_text && content) {
content.innerText = breakText(parseHtmlEntities(json_text));
}
}
} }
} }
} }
@ -5619,30 +5611,6 @@ else if (matchDomain('thenewatlantis.com')) {
article_gated.classList.remove('article-gated'); article_gated.classList.remove('article-gated');
} }
else if (matchDomain('thenewsminute.com')) {
let paywall = document.querySelector('div#paywall-banner');
if (paywall) {
removeDOMElement(paywall);
let fade = document.querySelector('div[class^="paywall-story-styles-"]');
if (fade)
fade.removeAttribute('class');
let json_script = getArticleJsonScript();
if (json_script) {
let json = JSON.parse(json_script.text);
if (json) {
let json_text = breakText(parseHtmlEntities(json.articleBody.replace(/\.\./g, '.\r\n\r\n')));
let article = document.querySelector('div.arr--story-page-card-wrapper');
if (json_text && article) {
article.innerHTML = '';
let article_new = document.createElement('p');
article_new.innerText = json_text;
article.appendChild(article_new);
}
}
}
}
}
else if (matchDomain('thepointmag.com')) { else if (matchDomain('thepointmag.com')) {
let overlay = document.querySelectorAll('div.overlay, div#tpopup-'); let overlay = document.querySelectorAll('div.overlay, div#tpopup-');
removeDOMElement(...overlay); removeDOMElement(...overlay);
@ -6762,6 +6730,64 @@ function getArticleJsonScript() {
return json_script; return json_script;
} }
function getArticleQuintype() {
let article_new;
let json_script = document.querySelector('script#static-page');
if (json_script) {
try {
article_new = document.createElement('div');
let parser = new DOMParser();
let json = JSON.parse(json_script.text);
let pars = json.qt.data.story.cards;
for (let par of pars) {
let story_elements = par['story-elements'];
for (let elem of story_elements) {
let par_elem;
if (elem.type === 'text' && elem.text && dompurify_loaded) {
let doc = parser.parseFromString('<div style="margin: 25px 0px">' + DOMPurify.sanitize(elem.text, dompurify_options) + '</div>', 'text/html');
par_elem = doc.querySelector('div');
} else if (elem.type === 'image') {
if (elem['image-s3-key']) {
par_elem = document.createElement('figure');
let img = document.createElement('img');
img.src = 'https://media.assettype.com/' + elem['image-s3-key'];
par_elem.appendChild(img);
if (elem.title) {
let caption = document.createElement('figcaption');
caption.innerText = elem.title;
par_elem.appendChild(caption);
}
}
} else if (elem.type === 'jsembed') {
if (elem.subtype === 'tweet') {
if (elem.metadata && elem.metadata['tweet-url']) {
par_elem = document.createElement('a');
par_elem.href = par_elem.innerText = elem.metadata['tweet-url'];
par_elem.target = '_blank';
} else
console.log(elem);
}
} else if (elem.type === 'youtube-video') {
if (elem['embed-url']) {
par_elem = document.createElement('iframe');
par_elem.src = elem['embed-url'];
par_elem.style = 'width: 100%; height: 400px;';
}
} else if (!['widget'].includes(elem.type))
console.log(elem);
if (par_elem)
article_new.appendChild(par_elem);
}
}
if (!article_new.hasChildNodes())
article_new = '';
} catch (err) {
console.log(err);
}
}
return article_new;
}
function findKeyJson(json, keys, min_val_len = 0) { function findKeyJson(json, keys, min_val_len = 0) {
let source = ''; let source = '';
if (Array.isArray(json)) { if (Array.isArray(json)) {
@ -6889,7 +6915,7 @@ function findOverlap(a, b) {
} }
function breakText(str, headers = false) { function breakText(str, headers = false) {
str = str.replace(/(?:^|[A-Za-z\"\“\)])(\.|\?|!)(?=[A-ZÖÜ\„\d][A-Za-zÀ-ÿ\„\d]{1,})/gm, "$&\n\n"); str = str.replace(/(?:^|[A-Za-z\"\“\)])(\.+|\?|!)(?=[A-ZÖÜ\„\d][A-Za-zÀ-ÿ\„\d]{1,})/gm, "$&\n\n");
if (headers) if (headers)
str = str.replace(/(([a-z]{2,}|[\"\“]))(?=[A-Z](?=[A-Za-zÀ-ÿ]+))/gm, "$&\n\n"); str = str.replace(/(([a-z]{2,}|[\"\“]))(?=[A-Z](?=[A-Za-zÀ-ÿ]+))/gm, "$&\n\n");
return str; return str;

View file

@ -51,5 +51,5 @@
"webRequestBlocking", "webRequestBlocking",
"*://*/*" "*://*/*"
], ],
"version": "3.6.0.4" "version": "3.6.0.5"
} }

View file

@ -357,6 +357,11 @@
"block_js_inline": "\\.heraldo\\.es\\/noticias", "block_js_inline": "\\.heraldo\\.es\\/noticias",
"domain": "heraldo.es" "domain": "heraldo.es"
}, },
"Himalmag.com": {
"allow_cookies": 1,
"domain": "himalmag.com",
"ld_json": "div#metered-paywall-banner|div[class^='paywall-story-']"
},
"Hochparterre.ch": { "Hochparterre.ch": {
"allow_cookies": 1, "allow_cookies": 1,
"cs_code": "[{\"cond\":\"div.pageWrapper\", \"rm_class\":\"pageWrapper\"}]", "cs_code": "[{\"cond\":\"div.pageWrapper\", \"rm_class\":\"pageWrapper\"}]",

4
lib/purify.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -862,5 +862,5 @@
"*://archive.vn/*", "*://archive.vn/*",
"*://webcache.googleusercontent.com/*" "*://webcache.googleusercontent.com/*"
], ],
"version": "3.6.0.4" "version": "3.6.0.5"
} }

View file

@ -2604,7 +2604,8 @@ var defaultSites = {
}, },
"The News Minute": { "The News Minute": {
domain: "thenewsminute.com", domain: "thenewsminute.com",
allow_cookies: 1 allow_cookies: 1,
cs_dompurify: 1
}, },
"The Philadelphia Inquirer": { "The Philadelphia Inquirer": {
domain: "inquirer.com", domain: "inquirer.com",

View file

@ -5,6 +5,12 @@
"block_regex": "\\.tinypass\\.com\\/", "block_regex": "\\.tinypass\\.com\\/",
"upd_version": "3.5.9.3" "upd_version": "3.5.9.3"
}, },
"Bar and Bench": {
"domain": "barandbench.com",
"allow_cookies": 1,
"ld_json": "div[id*='paywall-banner']|div[class^='paywall-story-']",
"upd_version": "3.6.0.5"
},
"Courrier international": { "Courrier international": {
"domain": "courrierinternational.com", "domain": "courrierinternational.com",
"allow_cookies": 1, "allow_cookies": 1,
@ -112,5 +118,11 @@
"add_ext_link_type": "archive.is", "add_ext_link_type": "archive.is",
"ld_archive_is": "aside.article-paywall|main>article", "ld_archive_is": "aside.article-paywall|main>article",
"upd_version": "3.5.8.9" "upd_version": "3.5.8.9"
},
"The News Minute": {
"domain": "thenewsminute.com",
"allow_cookies": 1,
"ld_json": "div[id*='paywall-banner']|div[class^='paywall-story-']",
"upd_version": "3.6.0.5"
} }
} }