mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-04 12:00:10 +00:00
Fix-update Australia News Corp (amp)
This commit is contained in:
parent
4e1d0e0a43
commit
e271e2a615
@ -12,10 +12,10 @@
|
|||||||
### Installation
|
### Installation
|
||||||
You can install the add-on from Mozilla add-ons (AMO): [Bypass Paywalls Clean](https://addons.mozilla.org/en-US/firefox/addon/bypass-paywalls-clean)
|
You can install the add-on from Mozilla add-ons (AMO): [Bypass Paywalls Clean](https://addons.mozilla.org/en-US/firefox/addon/bypass-paywalls-clean)
|
||||||
Or download and install the latest version from [BitBucket](https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/downloads)
|
Or download and install the latest version from [BitBucket](https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/downloads)
|
||||||
By default BPC has limited permissions, but you can opt-in to enable custom sites (and also clear cookies for non-listed sites).
|
By default BPC has limited permissions, but you can opt-in to enable custom sites (and also clear cookies/block general paywall-scripts for non-listed sites).
|
||||||
Install add-on by downloading xpi-file.
|
Install add-on by downloading xpi-file.
|
||||||
On Android this add-on only works with Firefox 68 (Fennec); Firefox 79 (Fenix) only supports 9 add-ons (for now).
|
On Android this add-on only works with Firefox 68 (Fennec); Firefox 79 (Fenix) only supports 9 add-ons (for now).
|
||||||
So don't update to Firefox 79 or use F-droid's [Fennec-release](https://f-droid.org/en/packages/org.mozilla.fennec_fdroid/)
|
So don't update to Firefox 79 or use Firefox Nightly (and load BPC from a custom add-on collection).
|
||||||
|
|
||||||
### List of supported websites
|
### List of supported websites
|
||||||
|
|
||||||
|
@ -322,6 +322,7 @@ ext_api.storage.sync.get({
|
|||||||
for (let domain of au_news_corp_domains) {
|
for (let domain of au_news_corp_domains) {
|
||||||
allow_cookies.push(domain);
|
allow_cookies.push(domain);
|
||||||
use_google_bot.push(domain);
|
use_google_bot.push(domain);
|
||||||
|
blockedRegexes[domain] = /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
disabledSites = disabledSites.concat(au_news_corp_domains);
|
disabledSites = disabledSites.concat(au_news_corp_domains);
|
||||||
@ -573,9 +574,10 @@ 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 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 bloomberg_site = (matchUrlDomain('assets.bwbx.io', details.url) && matchUrlDomain('bloomberg.com', header_referer) && isSiteEnabled({url: header_referer}));
|
||||||
|
let au_nc_amp_site = (matchUrlDomain('cdn.ampproject.org', details.url) && matchUrlDomain(au_news_corp_domains, 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/'));
|
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/'));
|
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)) {
|
if (!isSiteEnabled(details) && !(inkl_site) && !(bloomberg_site) && !(au_nc_amp_site) && !(au_apn_site) && !(au_swm_site)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ Post-release
|
|||||||
Add NYmag-sites Grub Street, The Cut & Vulture
|
Add NYmag-sites Grub Street, The Cut & Vulture
|
||||||
Add Quotidiano.net (Italy)
|
Add Quotidiano.net (Italy)
|
||||||
Add The West Australian (+ regional)
|
Add The West Australian (+ regional)
|
||||||
|
Fix-update Australia News Corp (amp)
|
||||||
Fix-update Inkl (disable newsletter login)
|
Fix-update Inkl (disable newsletter login)
|
||||||
Fix-update Toronto Star (external cookie-script)
|
Fix-update Toronto Star (external cookie-script)
|
||||||
Update opt-in tab (default settings)
|
Update opt-in tab (default settings)
|
||||||
|
158
contentScript.js
158
contentScript.js
@ -65,9 +65,9 @@ else if (domain = matchDomain(["brisbanetimes.com.au", "smh.com.au", "theage.com
|
|||||||
|
|
||||||
else if (window.location.hostname.endsWith(".com.au") || window.location.hostname.endsWith(".net.au")) {
|
else if (window.location.hostname.endsWith(".com.au") || window.location.hostname.endsWith(".net.au")) {
|
||||||
// Australian Community Media newspapers
|
// 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_cm_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"]');
|
let au_piano_script = document.querySelector('script[src="https://cdn-au.piano.io/api/tinypass.min.js"]');
|
||||||
if (matchDomain(au_sites) || au_piano_script) {
|
if (matchDomain(au_cm_sites) || au_piano_script) {
|
||||||
const subscribe_truncate = document.querySelector('.subscribe-truncate');
|
const subscribe_truncate = document.querySelector('.subscribe-truncate');
|
||||||
if (subscribe_truncate)
|
if (subscribe_truncate)
|
||||||
subscribe_truncate.classList.remove('subscribe-truncate');
|
subscribe_truncate.classList.remove('subscribe-truncate');
|
||||||
@ -76,85 +76,93 @@ else if (window.location.hostname.endsWith(".com.au") || window.location.hostnam
|
|||||||
subscriber_hider.classList.remove('subscriber-hider');
|
subscriber_hider.classList.remove('subscriber-hider');
|
||||||
}
|
}
|
||||||
} else if (window.location.hostname.endsWith(".com.au")) {
|
} else if (window.location.hostname.endsWith(".com.au")) {
|
||||||
// Australian Seven West Media
|
// Australia News Corp
|
||||||
let swm_script = document.querySelector('script[src^="https://s.thewest.com.au"]');
|
let au_nc_sites = ['adelaidenow.com.au', 'cairnspost.com.au', 'couriermail.com.au', 'dailytelegraph.com.au', 'geelongadvertiser.com.au', 'goldcoastbulletin.com.au', 'heraldsun.com.au', 'ntnews.com.au', 'theaustralian.com.au', 'themercury.com.au', 'townsvillebulletin.com.au', 'weeklytimesnow.com.au'];
|
||||||
if (matchDomain("thewest.com.au") || swm_script) {
|
if (matchDomain(au_nc_sites) && window.location.hostname.startsWith('amp.')) {
|
||||||
window.setTimeout(function () {
|
let div_hidden_all = document.querySelectorAll('div[amp-access="access AND subscriber"]');
|
||||||
let breach_screen = document.querySelector('div[data-testid*="BreachScreen"]');
|
for (let div_hidden of div_hidden_all)
|
||||||
if (breach_screen) {
|
div_hidden.removeAttribute('amp-access-hide');
|
||||||
let scripts = document.querySelectorAll('script');
|
} else {
|
||||||
let json_script;
|
// Australian Seven West Media
|
||||||
for (let script of scripts) {
|
let swm_script = document.querySelector('script[src^="https://s.thewest.com.au"]');
|
||||||
if (script.innerText.includes('window.PAGE_DATA ='))
|
if (matchDomain("thewest.com.au") || swm_script) {
|
||||||
json_script = script;
|
window.setTimeout(function () {
|
||||||
continue;
|
let breach_screen = document.querySelector('div[data-testid*="BreachScreen"]');
|
||||||
}
|
if (breach_screen) {
|
||||||
if (json_script) {
|
let scripts = document.querySelectorAll('script');
|
||||||
let json_text = json_script.innerHTML.split('window.PAGE_DATA =')[1].split('</script')[0];
|
let json_script;
|
||||||
json_text = json_text.replace(/undefined/g, '"undefined"');
|
for (let script of scripts) {
|
||||||
let json_article = JSON.parse(json_text);
|
if (script.innerText.includes('window.PAGE_DATA ='))
|
||||||
let json_pub = Object.entries(json_article)[0][1].data.result.resolution.publication;
|
json_script = script;
|
||||||
let json_content = json_pub.content.blocks;
|
continue;
|
||||||
//let json_video = json_pub.mainVideo;
|
}
|
||||||
let url = window.location.href;
|
if (json_script) {
|
||||||
let url_loaded = json_pub._self;
|
let json_text = json_script.innerHTML.split('window.PAGE_DATA =')[1].split('</script')[0];
|
||||||
if (!url.includes(url_loaded.slice(-10)))
|
json_text = json_text.replace(/undefined/g, '"undefined"');
|
||||||
document.location.reload(true);
|
let json_article = JSON.parse(json_text);
|
||||||
let article = '';
|
let json_pub = Object.entries(json_article)[0][1].data.result.resolution.publication;
|
||||||
let div_content = document.createElement('div');
|
let json_content = json_pub.content.blocks;
|
||||||
for (let par of json_content) {
|
//let json_video = json_pub.mainVideo;
|
||||||
if (par.kind === 'text') {
|
let url = window.location.href;
|
||||||
article = article + '<p>' + par.text + '</p>';
|
let url_loaded = json_pub._self;
|
||||||
} else if (par.kind === 'subhead') {
|
if (!url.includes(url_loaded.slice(-10)))
|
||||||
article = article + '<h2>' + par.text + '</h2>';
|
document.location.reload(true);
|
||||||
} else if (par.kind === 'pull-quote') {
|
let article = '';
|
||||||
article = article + '<i>' + (par.attribution ? par.attribution + ': ' : '') + par.text + '</i>';
|
let div_content = document.createElement('div');
|
||||||
} else if (par.kind === 'embed') {
|
for (let par of json_content) {
|
||||||
if (par.reference.includes('https://omny.fm/') || par.reference.includes('https://docdro.id/')) {
|
if (par.kind === 'text') {
|
||||||
article = article + '<embed src="' + par.reference + '" style="height:500px; width:100%" frameborder="0"></embed>';
|
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 {
|
} else {
|
||||||
article = article + 'Embed: ' + '<a href="' + par.reference + '" target="_blank">' + par.reference + '</a>';
|
article = article + '<p>' + par.text + '</p>';
|
||||||
console.log('embed: ' + par.reference);
|
console.log(par.kind);
|
||||||
}
|
|
||||||
} 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>';
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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 {
|
} else {
|
||||||
article = article + '<p>' + par.text + '</p>';
|
par_dom.setAttribute('style', 'margin: 20px;');
|
||||||
console.log(par.kind);
|
breach_screen.parentElement.insertBefore(par_dom, breach_screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let content = document.querySelector('div[class*="StyledArticleContent"]');
|
removeDOMElement(breach_screen);
|
||||||
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');
|
||||||
}, 1000); // Delay (in milliseconds)
|
if (header_advert)
|
||||||
let header_advert = document.querySelector('.headerAdvertisement');
|
header_advert.setAttribute('style', 'display: none;');
|
||||||
if (header_advert)
|
}
|
||||||
header_advert.setAttribute('style', 'display: none;');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user