Add Frankfurter Allgemeine (Faz.net)
Updated script from paywallr (@tobimori).
This commit is contained in:
parent
162c90ed23
commit
97867b3b08
@ -196,6 +196,7 @@ Visit the [Firefox repository](https://github.com/magnolia1234-new/bypass-paywal
|
||||
[Science & Vie](https://www.science-et-vie.com) -
|
||||
[Valeurs Actuelles](https://www.valeursactuelles.com)
|
||||
##### Germany/Austria
|
||||
[Frankfurter Allgemeine Zeitung](https://www.faz.net) -
|
||||
[Handelsblatt](https://www.handelsblatt.com) -
|
||||
[Kleine Zeitung](https://www.kleinezeitung.at)
|
||||
##### Italy
|
||||
|
@ -30,6 +30,7 @@ var allow_cookies = [
|
||||
'dvhn.nl',
|
||||
'elmercurio.com',
|
||||
'eurekareport.com.au',
|
||||
'faz.net',
|
||||
'folha.uol.com.br',
|
||||
'gestion.pe',
|
||||
'goldcoastbulletin.com.au',
|
||||
@ -330,6 +331,22 @@ ext_api.webRequest.onBeforeRequest.addListener(function (details) {
|
||||
["blocking"]
|
||||
);
|
||||
|
||||
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";
|
||||
ext_api.webRequest.onBeforeSendHeaders.addListener(
|
||||
function (details) {
|
||||
let headers = details.requestHeaders;
|
||||
headers.forEach(function (header, i) {
|
||||
if (header.name.toLowerCase() == 'user-agent')
|
||||
header.value = faz_uaMobile;
|
||||
});
|
||||
if (!details.originUrl && details.type == "xmlhttprequest" ||
|
||||
details.initiator == "https://www.faz.net" && details.type == "xmlhttprequest")
|
||||
return { requestHeaders: headers };
|
||||
}, {
|
||||
urls: ["*://m.faz.net/*"]
|
||||
},
|
||||
["blocking", "requestHeaders"]);
|
||||
|
||||
var block_js_default = ["*://*.tinypass.com/*", "*://*.poool.fr/*", "*://*.piano.io/*", "*://*.outbrain.com/*"];
|
||||
var block_js_custom = [];
|
||||
var block_js = block_js_default.concat(block_js_custom);
|
||||
|
@ -464,7 +464,7 @@ else if (matchDomain('ladepeche.fr')) {
|
||||
});
|
||||
}
|
||||
|
||||
else if (window.location.href.indexOf("barrons.com") !== -1) {
|
||||
else if (matchDomain('barrons.com')) {
|
||||
var href = '';
|
||||
const signin_links = document.querySelectorAll('a.primary-button--link');
|
||||
for (let i = 0; i < signin_links.length; i++) {
|
||||
@ -491,6 +491,55 @@ else if (matchDomain('lescienze.it')) {
|
||||
}
|
||||
}
|
||||
|
||||
else if (matchDomain('faz.net')) {
|
||||
let paywall = document.querySelector('#paywall-form-container-outer,.atc-ContainerPaywall');
|
||||
if (paywall) {
|
||||
removeDOMElement(paywall);
|
||||
let url = new URL(window.location.href);
|
||||
let mUrl = new URL(url.pathname, "https://m.faz.net/");
|
||||
fetch(mUrl)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
response.text().then(html => {
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(html, 'text/html');
|
||||
let json = doc.querySelector('script[id="schemaOrgJson"]');
|
||||
if (json) {
|
||||
var json_text = JSON.parse(json.text).ArticleBody;
|
||||
let article_text = document.querySelector('.art_txt.paywall,.atc-Text.js-atc-Text');
|
||||
article_text.innerText = '';
|
||||
|
||||
const breakText = (str) => {
|
||||
str = str.replace(/(?:^|[\w\"\“])(\.|\?|!)(?=[A-Za-zÀ-ÿ\„]{2,})/gm, "$&\n\n");
|
||||
str = str.replace(/([a-z\"\“])(?=[A-Z])/gm, "$&\n\n");
|
||||
// exceptions: names with alternating lower/uppercase (no general fix)
|
||||
str = str.replace(/Glaxo\n\nSmith\n\nKline/g, "GlaxoSmithKline");
|
||||
str = str.replace(/If\n\nSG/g, "IfSG");
|
||||
str = str.replace(/La\n\nPierre/g, "LaPierre");
|
||||
return str;
|
||||
};
|
||||
|
||||
json_text = breakText(json_text);
|
||||
json_text.split("\n\n").forEach(
|
||||
(p_text) => {
|
||||
let elem;
|
||||
if (p_text.length < 80) {
|
||||
elem = document.createElement("h2");
|
||||
elem.setAttribute('class', 'atc-SubHeadline');
|
||||
} else {
|
||||
elem = document.createElement("p");
|
||||
elem.setAttribute('class', 'atc-TextParagraph');
|
||||
};
|
||||
elem.innerText = p_text;
|
||||
article_text.appendChild(elem);
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// General Functions
|
||||
function removeDOMElement(...elements) {
|
||||
for (let element of elements) {
|
||||
|
1
sites.js
1
sites.js
@ -41,6 +41,7 @@ var defaultSites =
|
||||
"Folha de S. Paulo": "folha.uol.com.br",
|
||||
"Foreign Policy": "foreignpolicy.com",
|
||||
"Fortune": "fortune.com",
|
||||
"Frankfurter Allgemeine Zeitung": "faz.net",
|
||||
"Gestión": "gestion.pe",
|
||||
"Glassdoor": "glassdoor.com",
|
||||
"Gold Coast Bulletin": "goldcoastbulletin.com.au",
|
||||
|
Loading…
x
Reference in New Issue
Block a user