mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-10 01:11:04 +00:00
Fix Stratfor (forecasts)
This commit is contained in:
parent
de15785ec8
commit
37c929c9bf
@ -1300,6 +1300,8 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
||||
!(matchUrlDomain('barrons.com', details.url) && enabledSites.includes('#options_disable_gb_barrons')) &&
|
||||
!(matchUrlDomain('theaustralian.com.au', details.url) && enabledSites.includes('#options_disable_gb_theaustralian')) &&
|
||||
!(matchUrlDomain('wsj.com', details.url) && enabledSites.includes('#options_disable_gb_wsj'));
|
||||
var bingbotEnabled = matchUrlDomain(use_bing_bot, details.url) &&
|
||||
!(matchUrlDomain('stratfor.com', details.url) && details.url.match(/(\/(\d){4}-([a-z]||-)+-forecast(-([a-z]|-)+)?|-forecast-(\d){4}-([a-z]|[0-9]||-)+)$/));
|
||||
|
||||
if (matchUrlDomain(change_headers, details.url) && (!['font', 'image', 'stylesheet'].includes(details.type) || matchUrlDomain(['thetimes.co.uk'], details.url))) {
|
||||
// if referer exists, set it
|
||||
@ -1353,7 +1355,7 @@ if (matchUrlDomain(change_headers, details.url) && (!['font', 'image', 'styleshe
|
||||
}
|
||||
|
||||
// override User-Agent to use Bingbot
|
||||
if (matchUrlDomain(use_bing_bot, details.url)) {
|
||||
if (bingbotEnabled) {
|
||||
requestHeaders.push({
|
||||
"name": "User-Agent",
|
||||
"value": useUserAgentMobile ? userAgentMobileB : userAgentDesktopB
|
||||
@ -1388,7 +1390,7 @@ if (matchUrlDomain(change_headers, details.url) && (!['font', 'image', 'styleshe
|
||||
}
|
||||
if ((!['font', 'stylesheet'].includes(details.type) || matchUrlDomain(cs_limit_except, currentTabUrl)) && !csDone) {
|
||||
let lib_file = 'lib/empty.js';
|
||||
if (matchUrlDomain(['bloomberg.com', 'cicero.de', 'economictimes.com', 'lesechos.fr', 'marianne.net', 'newleftreview.org', 'newyorker.com', 'nzherald.co.nz', 'prospectmagazine.co.uk', 'sudouest.fr', 'techinasia.com', 'valor.globo.com', 'washingtonpost.com'].concat(nl_mediahuis_region_domains, no_nhst_media_domains, usa_theathletic_domains), currentTabUrl))
|
||||
if (matchUrlDomain(['bloomberg.com', 'cicero.de', 'economictimes.com', 'lesechos.fr', 'marianne.net', 'newleftreview.org', 'newyorker.com', 'nzherald.co.nz', 'prospectmagazine.co.uk', 'stratfor.com', 'sudouest.fr', 'techinasia.com', 'valor.globo.com', 'washingtonpost.com'].concat(nl_mediahuis_region_domains, no_nhst_media_domains, usa_theathletic_domains), currentTabUrl))
|
||||
lib_file = 'lib/purify.min.js';
|
||||
var bg2csData = {
|
||||
optin_setcookie: optin_setcookie,
|
||||
|
@ -2,6 +2,7 @@
|
||||
Changelog Bypass Paywalls Clean - Firefox
|
||||
|
||||
Post-release
|
||||
Fix Stratfor (forecasts)
|
||||
|
||||
* v2.4.1.0 (2021-10-24)
|
||||
Add Elle.fr
|
||||
|
@ -2436,6 +2436,41 @@ else if (matchDomain('stratfor.com')) {
|
||||
let hidden_images = document.querySelectorAll('img[src^="data:image/gif"][data-src]');
|
||||
for (let hidden_image of hidden_images)
|
||||
hidden_image.setAttribute('src', hidden_image.getAttribute('data-src'));
|
||||
let url = window.location.href.split('?')[0];
|
||||
if (url.match(/(\/(\d){4}-([a-z]|-)+-forecast(-([a-z]|-)+)?|-forecast-(\d){4}-([a-z]|[0-9]|-)+)$/)) {
|
||||
json_script = document.querySelector('script#__NEXT_DATA__');
|
||||
if (json_script && dompurify_loaded) {
|
||||
let json = JSON.parse(json_script.innerText);
|
||||
if (json && json.props.pageProps.data) {
|
||||
let overview_div = document.querySelector('div[class^="overview_overview__"] > div');
|
||||
if (overview_div) {
|
||||
let data = json.props.pageProps.data;
|
||||
let parser = new DOMParser();
|
||||
let doc = parser.parseFromString('<div>' + DOMPurify.sanitize('<p>' + data.teaser_body + '</p>' + data.overview + '<p><h2>Sections</h2></p>' ) + '</div>', 'text/html');
|
||||
let content_new = doc.querySelector('div');
|
||||
let sections = data.section;
|
||||
for (let section of sections) {
|
||||
let section_link = document.createElement('a');
|
||||
section_link.innerText = section.title;
|
||||
section_link.href = 'https://' + window.location.hostname + '/' + section.path_alias;
|
||||
content_new.appendChild(section_link);
|
||||
content_new.appendChild(document.createElement('br'));
|
||||
}
|
||||
overview_div.parentNode.replaceChild(content_new, overview_div);
|
||||
csDoneOnce = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
waitDOMElement('div.paywall-banner', 'DIV', removeDOMElement, false);
|
||||
} else if (url.match(/\/article\/.+-forecast(-.+)?\//)) {
|
||||
let next_section_buttons = document.querySelectorAll('div[class^="nextSection_nextSection__"] > button');
|
||||
for (let elem of next_section_buttons) {
|
||||
let section_link = document.createElement('a');
|
||||
section_link.innerText = elem.innerText;
|
||||
section_link.href = url.replace(/[^\/]+$/, '') + elem.innerText.split(': ')[1].toLowerCase().split(' ').filter(x => !['a', 'an', 'of', 'the'].includes(x)).join('-');
|
||||
elem.parentNode.replaceChild(section_link, elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (matchDomain('study.com')) {
|
||||
|
@ -556,5 +556,5 @@
|
||||
"*://*.wallkit.net/*",
|
||||
"*://*.wsj.net/*"
|
||||
],
|
||||
"version": "2.4.1.0"
|
||||
"version": "2.4.1.1"
|
||||
}
|
Loading…
Reference in New Issue
Block a user