Fix Business Standard

This commit is contained in:
magnolia1234 2022-06-24 11:46:16 +02:00
parent 19312b549a
commit 8b811af497
5 changed files with 17 additions and 38 deletions

View file

@ -501,7 +501,7 @@ ext_api.webRequest.onBeforeRequest.addListener(function (details) {
);
// m.faz.net set user-agent to mobile
const faz_uaMobile = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36";
const userAgentMobile = "Mozilla/5.0 (Linux; Android 12) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36";
ext_api.webRequest.onBeforeSendHeaders.addListener(function (details) {
if (!isSiteEnabled(details)) {
return;
@ -509,7 +509,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function (details) {
let headers = details.requestHeaders;
headers = headers.map(function (header) {
if (header.name.toLowerCase() === 'user-agent')
header.value = faz_uaMobile;
header.value = userAgentMobile;
return header;
});
return {
@ -521,20 +521,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function (details) {
},
["blocking", "requestHeaders"]);
// wap.business-standard.com (mobile) redirect to www (desktop)
ext_api.webRequest.onBeforeRequest.addListener(function (details) {
if (!isSiteEnabled(details)) {
return;
}
var updatedUrl = details.url.replace('/wap.', '/www.');
return { redirectUrl: updatedUrl };
},
{urls:["*://wap.business-standard.com/*"], types:["main_frame"]},
["blocking"]
);
// www.business-standard.com set user-agent to desktop
const business_standard_uaDesktop = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36";
// wap.business-standard.com/article-amp/ set user-agent to mobile
ext_api.webRequest.onBeforeSendHeaders.addListener(function (details) {
if (!isSiteEnabled(details)) {
return;
@ -542,14 +529,14 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function (details) {
let headers = details.requestHeaders;
headers = headers.map(function (header) {
if (header.name.toLowerCase() === 'user-agent')
header.value = business_standard_uaDesktop;
header.value = userAgentMobile;
return header;
});
return {
requestHeaders: headers
};
}, {
urls: ["*://www.business-standard.com/*"],
urls: ["*://wap.business-standard.com/article-amp/*"],
types: ["main_frame"]
},
["blocking", "requestHeaders"]);

View file

@ -2,6 +2,7 @@
Changelog Bypass Paywalls Clean - Firefox
Post-release
Fix Business Standard
Fix LesEchos.fr
* v2.7.2.0 (2022-06-06)

View file

@ -2612,25 +2612,15 @@ else if (matchDomain('business-standard.com')) {
let skip_button = document.querySelector('a.btn_skip');
if (skip_button)
skip_button.click();
let p_content = document.querySelector('span.p-content.paywall');
if (p_content) {
p_content.classList.remove('paywall');
let json_script = getArticleJsonScript();
if (json_script) {
let json_text = JSON.parse(json_script.text.replace(/(\r|\n|\t)/gm, ''))[0].articleBody;
json_text = parseHtmlEntities(json_text);
json_text = json_text.replace(/(?:^|[\w\"\'\])(\.|\?|!)(?=[A-Z\"\”\“\\\'][A-Za-zÀ-ÿ\"\”\“\\\']{1,})/gm, "$&\r\n\r\n") + '\r\n\r\n';
let article = document.createElement('div');
article.innerText = json_text;
if (article) {
let old_pars = p_content.querySelectorAll('p');
for (let old_par of old_pars) {
if (!old_par.querySelector('img'))
removeDOMElement(old_par);
}
p_content.appendChild(article);
}
if (!window.location.pathname.startsWith('/article-amp/')) {
let paywall = document.querySelector('span.p-content.paywall, main');
let amphtml = document.querySelector('link[rel="amphtml"]');
if (paywall && amphtml) {
removeDOMElement(paywall);
window.location.href = amphtml.href;
}
} else {
amp_unhide_subscr_section('amp-ad, amp-embed, .block-cont-amp, #divnonpaidcontent');
}
}

View file

@ -683,5 +683,5 @@
"*://*.wsj.net/*",
"*://webcache.googleusercontent.com/*"
],
"version": "2.7.2.1"
"version": "2.7.2.2"
}

View file

@ -216,7 +216,8 @@ var defaultSites = {
},
"Business Standard": {
domain: "business-standard.com",
allow_cookies: 1
allow_cookies: 1,
block_regex: /cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js/
},
"Causeur": {
domain: "causeur.fr",