Fix Business-standard.com (ld_json_next)

Update popup (toggle for custom flex sites)
merge-requests/16/head
magnolia1234 7 months ago
parent c40ec3e3a8
commit df8f1840a6

@ -1288,10 +1288,13 @@ function site_switch() {
isDefaultSite = isUpdatedSite;
}
let defaultSite_title = isDefaultSite ? Object.keys(defaultSites).find(key => defaultSites[key].domain === isDefaultSite) : '';
let isCustomSite = matchUrlDomain(Object.values(customSites_domains), currentUrl);
let isCustomSite = matchUrlDomain(customSites_domains, currentUrl);
let customSite_title = isCustomSite ? Object.keys(customSites).find(key => customSites[key].domain === isCustomSite || (customSites[key].group && customSites[key].group.split(',').includes(isCustomSite))) : '';
let site_title = defaultSite_title || customSite_title;
let domain = isDefaultSite || isCustomSite;
let isCustomFlexSite = matchUrlDomain(custom_flex_domains, currentUrl);
let isCustomFlexGroupSite = isCustomFlexSite ? Object.keys(custom_flex).find(key => custom_flex[key].includes(isCustomFlexSite)) : '';
let customFlexSite_title = isCustomFlexGroupSite ? Object.keys(defaultSites).find(key => defaultSites[key].domain === isCustomFlexGroupSite) : '';
let site_title = defaultSite_title || customSite_title || customFlexSite_title;
let domain = isDefaultSite || isCustomSite || isCustomFlexGroupSite;
if (domain && site_title) {
let added_site = [];
let removed_site = [];
@ -1408,7 +1411,11 @@ ext_api.runtime.onMessage.addListener(function (message, sender) {
if (group) {
let nofix_groups = ['###_ch_tamedia', '###_fi_alma_talent', '###_it_citynews', '###_nl_vmnmedia', '###_substack_custom', '###_uk_delinian'];
if (!custom_flex_domains.includes(custom_domain)) {
custom_flex[group] = custom_flex[group] ? custom_flex[group].push(custom_domain) : [custom_domain];
custom_flex_domains.push(custom_domain);
if (enabledSites.includes(group)) {
if (!enabledSites.includes(custom_domain))
enabledSites.push(custom_domain);
let rules = Object.values(defaultSites).filter(x => x.domain === group)[0];
if (rules) {
if (group === '###_de_madsack') {
@ -1421,14 +1428,12 @@ ext_api.runtime.onMessage.addListener(function (message, sender) {
} else
rules = Object.values(customSites).filter(x => x.domain === group)[0];
if (rules) {
custom_flex_domains.push(custom_domain);
if (!enabledSites.includes(custom_domain))
enabledSites.push(custom_domain);
customFlexAddRules(custom_domain, rules);
}
} else if (disabledSites.includes(group))
custom_flex_not_domains.push(custom_domain);
else if (nofix_groups.includes(group))
} else if (disabledSites.includes(group)) {
if (!disabledSites.includes(custom_domain))
disabledSites.push(custom_domain);
} else if (nofix_groups.includes(group))
nofix_sites.push(custom_domain);
}
} else
@ -1454,9 +1459,10 @@ ext_api.runtime.onMessage.addListener(function (message, sender) {
let isExcludedSite = matchUrlDomain(excludedSites, currentUrl);
if (!isExcludedSite) {
let isDefaultSite = matchUrlDomain(defaultSites_domains, currentUrl);
let isCustomSite = matchUrlDomain(Object.values(customSites_domains), currentUrl);
let isCustomSite = matchUrlDomain(customSites_domains, currentUrl);
let isUpdatedSite = matchUrlDomain(updatedSites_domains_new, currentUrl);
domain = isDefaultSite || isCustomSite || isUpdatedSite;
let isCustomFlexSite = matchUrlDomain(custom_flex_domains, currentUrl);
domain = isDefaultSite || isCustomSite || isUpdatedSite || isCustomFlexSite;
if (domain)
ext_api.runtime.sendMessage({
msg: "popup_show_toggle",

@ -9,6 +9,8 @@ Remove Observador.pt (fix obsolete)
Remove Schwarzwaelder-bote.de (fix obsolete)
Fix Belfast Telegraph/Independent.ie
Fix Bloomberg (overlay)
Fix Business-standard.com (ld_json_next)
Fix GauchaZH (refresh)
Fix Groupe Rossel (link to archive.is)
Fix Italian.tech (GEDI.it)
Fix Telegraaf.nl (images)
@ -17,6 +19,7 @@ Fix The Globe and Mail (css)
Update block general paywall script (fix TownNews)
Update custom sites (delete default sites)
Update Leaky Paywall (identify more sites)
Update popup (toggle for custom flex sites)
* v3.4.1.0 (2023-11-05)
Add Jane's Defence Weekly

@ -781,9 +781,8 @@ else if (matchDomain('faz.net')) {
if (json_text && article_text) {
let pars = article_text.querySelectorAll('p.atc-TextParagraph');
removeDOMElement(...pars);
json_text = breakText(json_text);
json_text.split("\n\n").forEach(
(p_text) => {
json_text = breakText_faz(json_text).split("\n\n");
for (let p_text of json_text) {
let elem;
if (p_text.length < 80) {
elem = document.createElement("h2");
@ -794,7 +793,7 @@ else if (matchDomain('faz.net')) {
};
elem.innerText = p_text;
article_text.appendChild(elem);
});
};
} else {
let json_script = getArticleJsonScript();
if (json_script) {
@ -3286,10 +3285,10 @@ else if (matchDomain('blogfolha.uol.com.br')) {
else if (matchDomain('gauchazh.clicrbs.com.br')) {
window.setTimeout(function () {
let blink = document.querySelector('div.body.blink');
let blink = document.querySelector('div:not(.hidden) > div.body.blink');
if (blink) {
csDoneOnce = true;
refreshCurrentTab_bg();
refreshCurrentTab();
}
}, 2000);
let ads = document.querySelectorAll('div.ad-banner, div.ad-container');
@ -3454,6 +3453,9 @@ else if (matchDomain('barandbench.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);
@ -3557,23 +3559,39 @@ else if (matchDomain('bqprime.com')) {
}
else if (matchDomain('business-standard.com')) {
if (!window.location.pathname.startsWith('/amp/')) {
let paywall = document.querySelector('div.subscribe-page');
if (paywall) {
removeDOMElement(paywall);
let json_script = getArticleJsonScript();
if (json_script) {
function bs_main(node) {
removeDOMElement(node);
let json_script = document.querySelector('script#__NEXT_DATA__');
if (json_script) {
try {
let json = JSON.parse(json_script.text);
if (json) {
let json_text = breakText(parseHtmlEntities(json.articleBody));
if (json && json.props.pageProps.data.htmlContent) {
let json_text = json.props.pageProps.data.htmlContent;
let content = document.querySelector('div.storycontent');
if (json_text && content) {
content.innerHTML = '';
let article_new = document.createElement('p');
article_new.innerText = json_text;
content.appendChild(article_new);
let intro = content.querySelectorAll('div:not([class]');
removeDOMElement(...intro);
let parser = new DOMParser();
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize(json_text) + '</div>', 'text/html');
let content_new = doc.querySelector('div');
content.firstChild.before(content_new);
}
}
} else
refreshCurrentTab();
} catch (err) {
console.log(err);
}
}
}
if (!window.location.pathname.startsWith('/amp/')) {
if (dompurify_loaded) {
let paywall_sel = 'div.subscribe-page';
let paywall = document.querySelector(paywall_sel);
if (paywall) {
bs_main(paywall)
} else {
csDoneOnce = true;
waitDOMElement(paywall_sel, 'DIV', bs_main, false);
}
}
let banner = document.querySelector('section.sbcrbtmlfull');
@ -5086,6 +5104,9 @@ 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);
@ -6069,10 +6090,15 @@ function pageContains(selector, text) {
function breakText(str) {
str = str.replace(/(?:^|[A-Za-z\"\“\)])(\.|\?|!)(?=[A-ZÖÜ\„\d][A-Za-zÀ-ÿ\„\d]{1,})/gm, "$&\n\n");
str = str.replace(/(([a-z]{2,}|[\"\“]))(?=[A-Z](?=[A-Za-zÀ-ÿ]+))/gm, "$&\n\n");
return str;
}
function breakText_faz(str) {
str = breakText(str);
// exceptions: names with alternating lower/uppercase (no general fix)
let str_rep_arr = ['AstraZeneca', 'BaFin', 'BerlHG', 'BfArM', 'BilMoG', 'BioNTech', 'DiGA', 'EuGH', 'FinTechRat', 'GlaxoSmithKline', 'IfSG', 'medRxiv', 'mmHg', 'PlosOne', 'StVO'];
let str_rep_split,
str_rep_src;
let str_rep_arr = ['AstraZeneca', 'BaFin', 'BerlHG', 'BfArM', 'BilMoG', 'BioNTech', 'ChatGPT', 'DiGA', 'EuGH', 'FinTechRat', 'GlaxoSmithKline', 'IfSG', 'medRxiv', 'mmHg', 'OpenAI', 'PlosOne', 'StVO'];
let str_rep_split;
let str_rep_src;
for (let str_rep of str_rep_arr) {
str_rep_split = str_rep.split(/([a-z]+)(?=[A-Z](?=[A-Za-z]+))/);
str_rep_src = str_rep_split.reduce(function (accumulator, currentValue) {

@ -51,5 +51,5 @@
"webRequestBlocking",
"*://*/*"
],
"version": "3.4.1.6"
"version": "3.4.1.7"
}

@ -805,5 +805,5 @@
"*://*.wyleex.com/*",
"*://webcache.googleusercontent.com/*"
],
"version": "3.4.1.6"
"version": "3.4.1.7"
}

@ -312,7 +312,8 @@ var defaultSites = {
},
"Business Standard": {
domain: "business-standard.com",
allow_cookies: 1
allow_cookies: 1,
cs_dompurify: 1
},
"California Business Journals": {
domain: "###_usa_cbj",
@ -2842,10 +2843,12 @@ var custom_flex_not = {
"###_usa_townnews": ["bloxdigital.com", "townnews.com"],
"thewest.com.au": ["perthnow.com.au"]
}
var custom_flex;
var custom_flex_domains;
var custom_flex_not_domains;
function init_custom_flex_domains() {
custom_flex = {};
custom_flex_domains = [];
custom_flex_not_domains = [].concat.apply([], Object.values(custom_flex_not));
}

@ -74,7 +74,7 @@
"allow_cookies": 1,
"block_regex": "(\\.piano\\.io\\/api\\/tinypass\\.min\\.js|\\.clicrbs\\.com\\.br\\/paywall-api\\/count\\/)",
"cs_block": 1,
"upd_version": "3.3.9.8"
"upd_version": "3.4.1.7"
},
"Groupe Rossel": {
"domain": "###_fr_be_groupe_rossel",

Loading…
Cancel
Save