diff --git a/background.js b/background.js index 5b6354bc..301954c8 100644 --- a/background.js +++ b/background.js @@ -144,6 +144,7 @@ var blockedRegexes = { 'americanbanker.com': /.+\.tinypass\.com\/.+/, 'barrons.com': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/, 'belfasttelegraph.co.uk': /cdn\.flip-pay\.com\/clients\/inm\/flip-pay\.js/, +'bizjournals.com': /(assets\.bizjournals\.com\/static\/js\/app\/cxense\.js|cdn\.cxense\.com)/, 'bloomberg.com': /.+\.tinypass\.com\/.+/, 'bostonglobe.com': /meter\.bostonglobe\.com\/js\/.+/, 'businessinsider.com': /.+\.tinypass\.com\/.+/, @@ -700,6 +701,26 @@ ext_api.webRequest.onCompleted.addListener(function (details) { urls: [""] }); +ext_api.runtime.onMessage.addListener(function (message, sender) { + // check storage for opt in + ext_api.storage.sync.get("optIn", function (result) { + // send message back to content script with value of opt in + ext_api.tabs.sendMessage( + sender.tab.id, { + "optIn": (true == result.optIn) + }); + }); +}); + +// show the tab if we haven't registered the user reacting to the prompt. +ext_api.storage.sync.get("optInShown", function (result) { + if (!result.optInShown) { + ext_api.tabs.create({ + url: "optin/opt-in.html" + }); + } +}); + function isSiteEnabled(details) { var enabledSite = matchUrlDomain(enabledSites, details.url); if (enabledSite in restrictions) { diff --git a/contentScript.js b/contentScript.js index 0dbbe576..845a2f57 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1,9 +1,38 @@ +"use strict"; +var ext_api = (typeof browser === 'object') ? browser : chrome; +var domain; + // clean local storage of sites (with an exemption for hold-list) var arr_localstorage_hold = ['seekingalpha.com', 'sfchronicle.com']; if (!matchDomain(arr_localstorage_hold)){ window.localStorage.clear(); } +// listen to responses from background script +ext_api.runtime.onMessage.addListener(function (message, sender) { + // setCookie opt-in + if (message.optIn) { + // Australian Provincial Newspapers + if (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); + } + } + } +}); + +// ask for opt-in confirmation +ext_api.runtime.sendMessage({}); + // Content workarounds/domain if (matchDomain("thesaturdaypaper.com.au")) { @@ -11,13 +40,6 @@ if (matchDomain("thesaturdaypaper.com.au")) { removeDOMElement(paywall); } -// Australian Provincial Newspapers -else if (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); - } -} - // Australian Community Media newspapers else if (window.location.hostname.endsWith(".com.au") || window.location.hostname.endsWith(".net.au")) { 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']; @@ -277,18 +299,6 @@ else if (matchDomain("economist.com")) { }); } -else if (matchDomain("bizjournals.com")) { - const sheet_overlay = document.querySelector('.sheet-overlay'); - const chunk_paywall = document.querySelector('.chunk--paywall'); - removeDOMElement(sheet_overlay, chunk_paywall); - const overlaids = document.querySelectorAll('.is-overlaid'); - for (let overlaid of overlaids) { - overlaid.classList.remove('is-overlaid'); - } - const body_hidden = document.querySelector('.js-pre-chunks__story-body'); - body_hidden.removeAttribute('style'); -} - else if (matchDomain("the-tls.co.uk")) { const paywall = document.querySelector('.tls-subscriptions-banner__closed-skin'); removeDOMElement(paywall); @@ -694,13 +704,6 @@ else if (matchDomain('spectator.co.uk')) { }, 500); // Delay (in milliseconds) } -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 (matchDomain('historyextra.com')) { let article_masked = document.querySelector('.template-article__masked'); if (article_masked) { @@ -712,12 +715,6 @@ else if (matchDomain('historyextra.com')) { removeDOMElement(ad_banner); } -else if (domain = matchDomain(['independent.ie', 'belfasttelegraph.co.uk'])) { - if (!cookieExists('subscriber')) { - setCookie('subscriber', '{"subscriptionStatus": true}', domain, '/', 14); - } -} - else if (matchDomain('republic.ru')) { let paywall = document.querySelector('.paywall-section'); removeDOMElement(paywall); diff --git a/lp/manifest.json b/lp/manifest.json index 34fa5010..348a52a0 100644 --- a/lp/manifest.json +++ b/lp/manifest.json @@ -305,5 +305,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.8.4.0" + "version": "1.8.4.2" } \ No newline at end of file diff --git a/manifest.json b/manifest.json index 6fa5b8e1..90a45835 100644 --- a/manifest.json +++ b/manifest.json @@ -40,5 +40,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.8.4.0" + "version": "1.8.4.2" } \ No newline at end of file diff --git a/optin/opt-in.css b/optin/opt-in.css new file mode 100644 index 00000000..0203d7fb --- /dev/null +++ b/optin/opt-in.css @@ -0,0 +1,9 @@ +html, body { + width: 20em; + padding-left: 0.5em; + padding-right: 0.5em; +} + +button { + margin: 0.2em 0.2em 0.5em 0; +} diff --git a/optin/opt-in.html b/optin/opt-in.html new file mode 100644 index 00000000..3aee92db --- /dev/null +++ b/optin/opt-in.html @@ -0,0 +1,30 @@ + + + + + + Bypass Paywalls Clean (setCookie opt-in) + + + + + +
+

Bypass Paywalls Clean (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/optin/opt-in.js b/optin/opt-in.js new file mode 100644 index 00000000..428c21cd --- /dev/null +++ b/optin/opt-in.js @@ -0,0 +1,38 @@ +"use strict"; +var ext_api = chrome || browser; + +window.addEventListener("load", function () { + ext_api.storage.sync.get("optIn", function (result) { + var opt_in_enabled = document.getElementById('opt-in-enabled'); + opt_in_enabled.appendChild(document.createTextNode('SetCookie opt-in enabled: ' + (result.optIn ? 'YES' : 'NO'))); + //console.log("Setting up UI. result.optIn:" + result.optIn); + }); + + document.getElementById("button-enable").addEventListener( + "click", + function () { + ext_api.storage.sync.set({ + "optIn": true, + "optInShown": true + }); + window.close(); + }); + + document.getElementById("button-cancel").addEventListener( + "click", + function () { + ext_api.storage.sync.set({ + "optIn": false, + "optInShown": true + }); + window.close(); + }); +/** + // set up the appearance of the popup depending on the outcome of the opt-in + ext_api.storage.sync.get("optInShown", function (result) { + console.log("Setting up UI. result.optInShown:" + result.optInShown); + document.getElementById("opt-in-prompt").hidden = result.optInShown; + document.getElementById("after-opt-in").hidden = !result.optInShown; + }); +**/ +}); \ No newline at end of file diff --git a/options.html b/options.html index 1c0a40ce..55571ad2 100644 --- a/options.html +++ b/options.html @@ -17,11 +17,13 @@

Options |

Selected sites will have their cookies cleared and referer set to Google. - You should uncheck sites you have an account with or else you will be logged out at every visit. + You should uncheck sites you have an account with or else you will be logged out at every visit.
+ For some sites (check list) a necessary cookie has to be set; enable in opt-in.

+
diff --git a/sites.js b/sites.js index 5d1a4138..0d67b98f 100644 --- a/sites.js +++ b/sites.js @@ -9,11 +9,11 @@ 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", - "Belfast Telegraph": "belfasttelegraph.co.uk", + "Belfast Telegraph (opt-in)": "belfasttelegraph.co.uk", "Bloomberg": "bloomberg.com", "Bloomberg Quint (free articles only)": "bloombergquint.com", "Brisbane Times": "brisbanetimes.com.au", @@ -73,7 +73,7 @@ var defaultSites = "Inc.com": "inc.com", "Inkl": "inkl.com", "Intelligent Investor": "intelligentinvestor.com.au", - "Irish Independent": "independent.ie", + "Irish Independent (opt-in)": "independent.ie", "Knack.be": "knack.be", "L'Écho": "lecho.be", "L'Opinion": "lopinion.fr", @@ -149,7 +149,7 @@ var defaultSites = "The Athletic UK": "theathletic.co.uk", "The Atlantic": "theatlantic.com", "The Australian Financial Review": "afr.com", - "The Boston Globe": "bostonglobe.com", + "The Boston Globe (opt-in)": "bostonglobe.com", "The Business Journals": "bizjournals.com", "The Christian Science Monitor": "csmonitor.com", "The Daily Beast (free articles only)": "thedailybeast.com",