From 8bdd8e163491db6a1625eeffd56a09b80f13b120 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Wed, 4 Nov 2020 08:19:51 +0100 Subject: [PATCH] Fix-update Australian Provincial Newspapers --- README.md | 3 ++- background.js | 5 +++-- changelog.txt | 1 + contentScript.js | 25 +++++++++++++++++-------- manifest.json | 2 +- optin/opt-in.html | 1 + sites.js | 2 +- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7b11eb5..1a73351 100644 --- a/README.md +++ b/README.md @@ -269,7 +269,8 @@ So don't update to Firefox 79 or use Firefox Nightly (and load BPC from a custom [The Standard](https://www.standard.net.au) - [Western Advocate](https://www.westernadvocate.com.au) -#### > Australian Provincial Newspapers (daily, grouped in options) +#### > Australian Provincial Newspapers (all, grouped in options) +For example: [Bundaberg News Mail](https://www.news-mail.com.au) - [Fraser Coast Chronicle](https://www.frasercoastchronicle.com.au) - [Gladstone Observer](https://www.gladstoneobserver.com.au) - diff --git a/background.js b/background.js index 0c3f25b..6b65aa6 100644 --- a/background.js +++ b/background.js @@ -665,9 +665,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 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_swm_site = (header_referer && urlHost(header_referer).endsWith('com.au') && details.url.includes('https://s.thewest.com.au/')); let sz_amp_site = (matchUrlDomain('cdn.ampproject.org', details.url) && matchUrlDomain('sueddeutsche.de', header_referer) && isSiteEnabled({url: header_referer})); - if (!isSiteEnabled(details) && !inkl_site && !bloomberg_site && !au_nc_amp_site && !au_swm_site && !sz_amp_site) { + if (!isSiteEnabled(details) && !inkl_site && !bloomberg_site && !au_nc_amp_site && !au_apn_site && !au_swm_site && !sz_amp_site) { return; } @@ -749,7 +750,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { if (tabId !== -1) { ext_api.tabs.get(tabId, function (currentTab) { - if ((currentTab && isSiteEnabled(currentTab)) || medium_custom_domain || au_swm_site || sz_amp_site) { + if ((currentTab && isSiteEnabled(currentTab)) || medium_custom_domain || au_apn_site || au_swm_site || sz_amp_site) { ext_api.tabs.executeScript(tabId, { file: 'contentScript.js', runAt: 'document_start' diff --git a/changelog.txt b/changelog.txt index db3b522..090e3e0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Changelog Bypass Paywalls Clean - Firefox Post-release +Fix-update Australian Provincial Newspapers Fix-update Haaretz/TheMarker (Bingbot) Fix-update Telegraph.co.uk (overlay) Fix Chrome-icon for dark/incognito mode (all permitted sites) diff --git a/contentScript.js b/contentScript.js index 543bb0a..e1fb09f 100644 --- a/contentScript.js +++ b/contentScript.js @@ -12,14 +12,23 @@ if (!matchDomain(arr_localstorage_hold)){ ext_api.runtime.onMessage.addListener(function (message, sender) { // setCookie opt-in if (message.optIn) { - if (matchDomain('bostonglobe.com')) { - if (!cookieExists('s_fid')) { - let s_fid = genHexString(16) + '-' + genHexString(16); - setCookie('s_fid', s_fid, 'bostonglobe.com', '/', 14); - } - } else if (domain = matchDomain(['independent.ie', 'belfasttelegraph.co.uk'])) { - if (!cookieExists('subscriber')) { - setCookie('subscriber', '{"subscriptionStatus": true}', domain, '/', 14); + let hostname = window.location.hostname; + if (hostname.endsWith(".com.au") || hostname.endsWith(".net.au")) { + // Australian Provincial Newspapers + domain = window.location.hostname.replace('www.', ''); + let au_apn_script = document.querySelector('script[src^="https://media.apnarm.net.au/"]'); + if (au_apn_script || (domain = matchDomain(['news-mail.com.au', 'frasercoastchronicle.com.au', 'gladstoneobserver.com.au', 'dailyexaminer.com.au', 'dailymercury.com.au', 'themorningbulletin.com.au', 'sunshinecoastdaily.com.au', 'gympietimes.com.au', 'northernstar.com.au', 'qt.com.au', 'thechronicle.com.au', 'warwickdailynews.com.au']))) + if (!cookieExists('subscribed')) + setCookie('subscribed', 'true', domain, '/', 14); + } else { + if (matchDomain('bostonglobe.com')) { + if (!cookieExists('s_fid')) { + let s_fid = genHexString(16) + '-' + genHexString(16); + setCookie('s_fid', s_fid, 'bostonglobe.com', '/', 14); + } + } else if (domain = matchDomain(['independent.ie', 'belfasttelegraph.co.uk'])) { + if (!cookieExists('subscriber')) + setCookie('subscriber', '{"subscriptionStatus": true}', domain, '/', 14); } } } diff --git a/manifest.json b/manifest.json index 1564bc1..bf9be1b 100644 --- a/manifest.json +++ b/manifest.json @@ -339,5 +339,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.9.3.2" + "version": "1.9.3.3" } \ No newline at end of file diff --git a/optin/opt-in.html b/optin/opt-in.html index 21a6919..04f71ef 100644 --- a/optin/opt-in.html +++ b/optin/opt-in.html @@ -13,6 +13,7 @@

Bypass Paywalls Clean
- setCookie/custom sites opt-in

setCookie opt-in

For some sites (check list in options) a necessary cookie has to be set (this cookie doesn't contain any personal information about the user or device):

+ Australian Provincial Newspapers
Boston Globe
Irish Independent
The Belfast Telegraph

diff --git a/sites.js b/sites.js index d4be860..9484dac 100644 --- a/sites.js +++ b/sites.js @@ -9,7 +9,7 @@ var defaultSites = "Atavist Magazine": "atavist.com", "Australia News Corp": "###_au_news_corp", "Australian Community Media (daily)": "###_au_comm_media", - "Australian Provincial Newspapers (daily)": "###_au_prov_news", + "Australian Provincial Newspapers (daily) (opt-in)": "###_au_prov_news", "Baltimore Sun": "baltimoresun.com", "Barron's": "barrons.com", "BBC History Extra": "historyextra.com",