Add The West Australian (+ regional)

master
magnolia1234 2020-10-15 17:10:49 +02:00
parent 9a27c995e1
commit 831ab04c71
6 changed files with 93 additions and 5 deletions

View File

@ -262,6 +262,7 @@ Visit the [Firefox repository](https://bitbucket.org/magnolia1234/bypass-paywall
[The Saturday Paper](https://www.thesaturdaypaper.com.au) -
[The Spectator Australia](https://www.spectator.com.au) -
[The Sydney Morning Herald](https://www.smh.com.au)
[The West Australian (+ regional)](https://thewest.com.au) -
[WAtoday](https://www.watoday.com.au)
##### > News Corp Australia

View File

@ -78,6 +78,7 @@ var allow_cookies = [
'the-american-interest.com',
'thehindu.com',
'themarker.com',
'thewest.com.au',
'timeshighereducation.com',
'trouw.nl',
'variety.com',
@ -540,8 +541,9 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
let inkl_site = (matchUrlDomain('cdn.jsdelivr.net', details.url) && matchUrlDomain('inkl.com', header_referer) && isSiteEnabled({url: header_referer}));
let bloomberg_site = (matchUrlDomain('assets.bwbx.io', details.url) && matchUrlDomain('bloomberg.com', header_referer) && isSiteEnabled({url: header_referer}));
let au_apn_site = (header_referer && (urlHost(header_referer).endsWith('com.au') || urlHost(header_referer).endsWith('net.au'))) && details.url.includes('https://media.apnarm.net.au/');
if (!isSiteEnabled(details) && !(inkl_site) && !(bloomberg_site) && !(au_apn_site)) {
let au_apn_site = (header_referer && (urlHost(header_referer).endsWith('com.au') || urlHost(header_referer).endsWith('net.au')) && details.url.includes('https://media.apnarm.net.au/'));
let au_swm_site = (header_referer && urlHost(header_referer).endsWith('com.au') && details.url.includes('https://s.thewest.com.au/'));
if (!isSiteEnabled(details) && !(inkl_site) && !(bloomberg_site) && !(au_apn_site) && !(au_swm_site)) {
return;
}
@ -616,7 +618,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
if (tabId !== -1) {
ext_api.tabs.get(tabId, function (currentTab) {
if (isSiteEnabled(currentTab) || medium_custom_domain || au_apn_site) {
if (isSiteEnabled(currentTab) || medium_custom_domain || au_apn_site || au_swm_site) {
ext_api.tabs.executeScript(tabId, {
file: 'contentScript.js',
runAt: 'document_start'

View File

@ -2,6 +2,8 @@
Changelog Bypass Paywalls Clean - Chrome
Post-release
Add The West Australian (+ regional)
Update opt-in tab (default settings)
* v1.9.0.2 (2020-10-14)
Fix-update MIT Sloan Management Review (modal)

View File

@ -63,8 +63,8 @@ else if (domain = matchDomain(["brisbanetimes.com.au", "smh.com.au", "theage.com
}
}
// Australian Community Media newspapers
else if (window.location.hostname.endsWith(".com.au") || window.location.hostname.endsWith(".net.au")) {
// Australian Community Media newspapers
let au_sites = ['bendigoadvertiser.com.au', 'bordermail.com.au', 'canberratimes.com.au', 'centralwesterndaily.com.au', 'dailyadvertiser.com.au', 'dailyliberal.com.au', 'examiner.com.au', 'illawarramercury.com.au', 'newcastleherald.com.au', 'northerndailyleader.com.au', 'portnews.com.au', 'standard.net.au', 'theadvocate.com.au', 'thecourier.com.au', 'westernadvocate.com.au'];
let au_piano_script = document.querySelector('script[src="https://cdn-au.piano.io/api/tinypass.min.js"]');
if (matchDomain(au_sites) || au_piano_script) {
@ -75,6 +75,87 @@ else if (window.location.hostname.endsWith(".com.au") || window.location.hostnam
for (let subscriber_hider of subscriber_hiders) {
subscriber_hider.classList.remove('subscriber-hider');
}
} else if (window.location.hostname.endsWith(".com.au")) {
// Australian Seven West Media
let swm_script = document.querySelector('script[src^="https://s.thewest.com.au"]');
if (matchDomain("thewest.com.au") || swm_script) {
window.setTimeout(function () {
let breach_screen = document.querySelector('div[data-testid*="BreachScreen"]');
if (breach_screen) {
let scripts = document.querySelectorAll('script');
let json_script;
for (let script of scripts) {
if (script.innerText.includes('window.PAGE_DATA ='))
json_script = script;
continue;
}
if (json_script) {
let json_text = json_script.innerHTML.split('window.PAGE_DATA =')[1].split('</script')[0];
json_text = json_text.replace(/undefined/g, '"undefined"');
let json_article = JSON.parse(json_text);
let json_pub = Object.entries(json_article)[0][1].data.result.resolution.publication;
let json_content = json_pub.content.blocks;
//let json_video = json_pub.mainVideo;
let url = window.location.href;
let url_loaded = json_pub._self;
if (!url.includes(url_loaded.slice(-10)))
document.location.reload(true);
let article = '';
let div_content = document.createElement('div');
for (let par of json_content) {
if (par.kind === 'text') {
article = article + '<p>' + par.text + '</p>';
} else if (par.kind === 'subhead') {
article = article + '<h2>' + par.text + '</h2>';
} else if (par.kind === 'pull-quote') {
article = article + '<i>' + (par.attribution ? par.attribution + ': ' : '') + par.text + '</i>';
} else if (par.kind === 'embed') {
if (par.reference.includes('https://omny.fm/') || par.reference.includes('https://docdro.id/')) {
article = article + '<embed src="' + par.reference + '" style="height:500px; width:100%" frameborder="0"></embed>';
} else {
article = article + 'Embed: ' + '<a href="' + par.reference + '" target="_blank">' + par.reference + '</a>';
console.log('embed: ' + par.reference);
}
} else if (par.kind === 'unordered-list') {
if (par.items) {
article = article + '<ul>';
for (let item of par.items)
if (item.text && item.intentions[0].href) {
article = article + '<li><a href="' + item.intentions[0].href + '">' + item.text + '</a></li>';
}
article = article + '</ul>';
}
} else if (par.kind === 'inline') {
if (par.asset.kind === 'image') {
article = article + '<figure><img src="' + par.asset.original.reference + '" style="width:100%">';
article = article + '<figcaption>' +
par.asset.captionText + ' ' + par.asset.copyrightByline +
((par.asset.copyrightCredit && par.asset.captionText !== par.asset.copyrightByline) ? '/' + par.asset.copyrightCredit : '') +
'<figcaption></figure>';
}
} else {
article = article + '<p>' + par.text + '</p>';
console.log(par.kind);
}
}
let content = document.querySelector('div[class*="StyledArticleContent"]');
let parser = new DOMParser();
let par_html = parser.parseFromString('<div>' + article + '</div>', 'text/html');
let par_dom = par_html.querySelector('div');
if (content) {
content.appendChild(par_dom);
} else {
par_dom.setAttribute('style', 'margin: 20px;');
breach_screen.parentElement.insertBefore(par_dom, breach_screen);
}
}
removeDOMElement(breach_screen);
}
}, 1000); // Delay (in milliseconds)
let header_advert = document.querySelector('.headerAdvertisement');
if (header_advert)
header_advert.setAttribute('style', 'display: none;');
}
}
}

View File

@ -246,6 +246,7 @@
"*://*.thesaturdaypaper.com.au/*",
"*://*.thestar.com/*",
"*://*.thetimes.co.uk/*",
"*://*.thewest.com.au/*",
"*://*.tijd.be/*",
"*://*.timeshighereducation.com/*",
"*://*.towardsdatascience.com/*",
@ -309,5 +310,5 @@
"webRequest",
"webRequestBlocking"
],
"version": "1.9.0.2"
"version": "1.9.0.3"
}

View File

@ -191,6 +191,7 @@ var defaultSites =
"The Toronto Star": "thestar.com",
"The Wall Street Journal (not Chinese)": "wsj.com",
"The Washington Post": "washingtonpost.com",
"The West Australian (+ regional)": "thewest.com.au",
"Times Higher Education": "timeshighereducation.com",
"Towards Data Science": "towardsdatascience.com",
"Trouw": "trouw.nl",