From 34d8a2bb6071a408ae2ae6ea5ab077e330b40443 Mon Sep 17 00:00:00 2001 From: Tomas Cimermonas Date: Sun, 6 Oct 2019 20:28:18 +0300 Subject: [PATCH 01/32] Remove paywall from DOM --- contentScript.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/contentScript.js b/contentScript.js index 154c703..f8f821a 100644 --- a/contentScript.js +++ b/contentScript.js @@ -89,3 +89,15 @@ if (window.location.href.indexOf("bizjournals.com") !== -1) { }, 300); // Delay (in milliseconds) } } + +if (window.location.href.indexOf("bloombergquint.com") !== -1) { + const articlesLeftModal = document.getElementsByClassName('paywall-meter-module__story-paywall-container__1UgCE')[0]; + const paywall = document.getElementById('paywallDmp'); + removeDOMElement(articlesLeftModal, paywall); +} + +function removeDOMElement(...elements) { + for (let element of elements) { + if (element) element.remove(); + } +} From 6af0f1ab0b6535e0764f5c195363ac316bb2e304 Mon Sep 17 00:00:00 2001 From: Tomas Cimermonas Date: Sun, 6 Oct 2019 20:28:35 +0300 Subject: [PATCH 02/32] Add to options & update readme --- README.md | 1 + background.js | 2 ++ options.js | 1 + 3 files changed, 4 insertions(+) diff --git a/README.md b/README.md index da6ef1d..5eddf2f 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ [Baltimore Sun](https://www.baltimoresun.com)\ [Barron's](https://www.barrons.com)\ [Bloomberg](https://www.bloomberg.com)\ +[Bloomberg Quint]('https://www.bloombergquint.com)\ [Business Insider](https://www.businessinsider.com)\ [Caixin](https://www.caixinglobal.com)\ [Chemical & Engineering News](https://cen.acs.org)\ diff --git a/background.js b/background.js index 89e4f3a..1e90784 100644 --- a/background.js +++ b/background.js @@ -4,6 +4,7 @@ var defaultSites = { 'Baltimore Sun': 'baltimoresun.com', 'Barron\'s': 'barrons.com', 'Bloomberg': 'bloomberg.com', + 'Bloomberg Quint': 'bloombergquint.com', 'Business Insider': 'businessinsider.com', 'Caixin': 'caixinglobal.com', 'Chemical & Engineering News': 'cen.acs.org', @@ -147,6 +148,7 @@ const remove_cookies = [ 'theatlantic.com', 'chicagobusiness.com', 'qz.com', +'bloombergquint.com' ] // Override User-Agent with Googlebot diff --git a/options.js b/options.js index 694161e..699526c 100644 --- a/options.js +++ b/options.js @@ -2,6 +2,7 @@ var defaultSites = { 'Baltimore Sun': 'baltimoresun.com', 'Barron\'s': 'barrons.com', 'Bloomberg': 'bloomberg.com', + 'Bloomberg Quint': 'bloombergquint.com', 'Business Insider': 'businessinsider.com', 'Caixin': 'caixinglobal.com', 'Chemical & Engineering News': 'cen.acs.org', From 7ba7feebd2c26e3f310cc690e112d72c26114cb7 Mon Sep 17 00:00:00 2001 From: Tomas Cimermonas Date: Tue, 8 Oct 2019 18:41:09 +0300 Subject: [PATCH 03/32] Remove medium footer --- contentScript.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/contentScript.js b/contentScript.js index 154c703..fa57321 100644 --- a/contentScript.js +++ b/contentScript.js @@ -89,3 +89,25 @@ if (window.location.href.indexOf("bizjournals.com") !== -1) { }, 300); // Delay (in milliseconds) } } + +if (window.location.href.indexOf("medium.com") !== -1) { + const bottomMessageText = 'Get one more story in your member preview when you sign up. It’s free.'; + const DOMElementsToTextDiv = contains('div', bottomMessageText); + + + if(DOMElementsToTextDiv[2]) removeDOMElement(DOMElementsToTextDiv[2]); +} + +function removeDOMElement(...elements) { + for (let element of elements) { + if (element) element.remove(); + } +} + +function contains(selector, text) { + let elements = document.querySelectorAll(selector); + + return Array.prototype.filter.call(elements, function(element){ + return RegExp(text).test(element.textContent); + }); +} \ No newline at end of file From 11424f7eb235a34d6019af1fec4fef8e55389e14 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Mon, 28 Oct 2019 19:26:52 +0100 Subject: [PATCH 04/32] Cookie-fix for The Diplomat, Chicago Business, Chemical & Engineering News, The Age Cookie-fix for The Diplomat, Chicago Business, Chemical & Engineering News, The Age. Collatoral damage of my maintenance to background.js. Until a new release you can install the Cookie Remover Add-on: https://addons.mozilla.org/en-US/firefox/addon/cookie-remover for these sites. Btw theharald.com.au has changed to newcastleherald.com.au (not changed), centralwesterndaily.com.au has no cookie-fix --- background.js | 866 +++++++++++++++++++++++++------------------------- 1 file changed, 437 insertions(+), 429 deletions(-) diff --git a/background.js b/background.js index bcb58a8..e5e6c15 100644 --- a/background.js +++ b/background.js @@ -1,429 +1,437 @@ -'use strict'; - -var defaultSites = { - 'Algemeen Dagblad': 'ad.nl', - 'Baltimore Sun': 'baltimoresun.com', - 'Barron\'s': 'barrons.com', - 'Bloomberg': 'bloomberg.com', - 'Business Insider': 'businessinsider.com', - 'Caixin': 'caixinglobal.com', - 'Chemical & Engineering News': 'cen.acs.org', - 'Chicago Tribune': 'chicagotribune.com', - 'Central Western Daily': 'centralwesterndaily.com.au', - 'Crain\'s Chicago Business': 'chicagobusiness.com', - 'Corriere Della Sera': 'corriere.it', - 'Daily Press': 'dailypress.com', - 'Denver Post': 'denverpost.com', - 'De Tijd': 'tijd.be', - 'De Groene Amsterdammer': 'groene.nl', - 'de Volkskrant': 'volkskrant.nl', - 'The Economist': 'economist.com', - 'Eindhovens Dagblad': 'ed.nl', - 'Examiner': 'examiner.com.au', - 'Financial Times': 'ft.com', - 'Foreign Policy': 'foreignpolicy.com', - 'Glassdoor': 'glassdoor.com', - 'Haaretz': 'haaretz.co.il', - 'Haaretz English': 'haaretz.com', - 'Handelsblatt': 'handelsblatt.com', - 'Hartford Courant': 'courant.com', - 'Harvard Business Review': 'hbr.org', - 'Inc.com': 'inc.com', - 'Investors Chronicle': 'investorschronicle.co.uk', - 'La Repubblica': 'repubblica.it', - 'Le Monde': 'lemonde.fr', - 'Le Temps': 'letemps.ch', - 'Los Angeles Times': 'latimes.com', - 'Medium': 'medium.com', - 'Medscape': 'medscape.com', - 'MIT Technology Review': 'technologyreview.com', - 'Mountain View Voice': 'mv-voice.com', - 'National Post': 'nationalpost.com', - 'New Statesman': 'newstatesman.com', - 'New York Magazine': 'nymag.com', - 'Nikkei Asian Review': 'asia.nikkei.com', - 'NRC': 'nrc.nl', - 'New Zealand Herald': 'nzherald.co.nz', - 'Orange County Register': 'ocregister.com', - 'Orlando Sentinel': 'orlandosentinel.com', - 'Palo Alto Online': 'paloaltoonline.com', - 'Parool': 'parool.nl', - 'Quartz': 'qz.com', - 'Quora': 'quora.com', - 'Statista': 'statista.com', - 'Telegraaf': 'telegraaf.nl', - 'SunSentinel': 'sun-sentinel.com', - 'The Advocate': 'theadvocate.com.au', - 'The Age': 'theage.com.au', - 'The Atlantic': 'theatlantic.com', - 'The Australian': 'theaustralian.com.au', - 'The Australian Financial Review': 'afr.com', - 'The Boston Globe': 'bostonglobe.com', - 'The Business Journals': 'bizjournals.com', - 'The Diplomat': 'thediplomat.com', - 'The Globe and Mail': 'theglobeandmail.com', - 'The Herald': 'theherald.com.au', - 'The Japan Times': 'japantimes.co.jp', - 'TheMarker': 'themarker.com', - 'The Mercury News': 'mercurynews.com', - 'The Morning Call': 'mcall.com', - 'The Nation': 'thenation.com', - 'The New York Times': 'nytimes.com', - 'The New Yorker': 'newyorker.com', - 'The News-Gazette': 'news-gazette.com', - 'The Saturday Paper': 'thesaturdaypaper.com.au', - 'The Spectator': 'spectator.co.uk', - 'The Seattle Times': 'seattletimes.com', - 'The Sydney Morning Herald': 'smh.com.au', - 'The Telegraph': 'telegraph.co.uk', - 'The Times': 'thetimes.co.uk', - 'The Toronto Star': 'thestar.com', - 'The Washington Post': 'washingtonpost.com', - 'The Wall Street Journal': 'wsj.com', - 'Towards Data Science': 'towardsdatascience.com', - 'Trouw': 'trouw.nl', - 'Vanity Fair': 'vanityfair.com', - 'Vrij Nederland': 'vn.nl', - 'Wired': 'wired.com' -}; - -const restrictions = { - 'barrons.com': 'barrons.com/articles' -} - -// Don't remove cookies before page load -const allow_cookies = [ -'ad.nl', -'asia.nikkei.com', -'bostonglobe.com', -'denverpost.com', -'economist.com', -'ed.nl', -'examiner.com.au', -'ft.com', -'hacked.com', -'hbr.org', -'lemonde.fr', -'letemps.ch', -'medium.com', -'mercurynews.com', -'newstatesman.com', -'nymag.com', -'nytimes.com', -'ocregister.com', -'parool.nl', -'qz.com', -'spectator.co.uk', -'telegraaf.nl', -'theadvocate.com.au', -'theaustralian.com.au', -'thestar.com', -'towardsdatascience.com', -'trouw.nl', -'vn.nl', -'volkskrant.nl', -'washingtonpost.com', -'wsj.com', -] - -// Removes cookies after page load -const remove_cookies = [ -'ad.nl', -'asia.nikkei.com', -'bostonglobe.com', -'denverpost.com', -'economist.com', -'ed.nl', -'examiner.com.au', -'ft.com', -'hacked.com', -'hbr.org', -'letemps.ch', -'medium.com', -'mercurynews.com', -'newstatesman.com', -'nymag.com', -'nytimes.com', -'ocregister.com', -'qz.com', -'spectator.co.uk', -'telegraaf.nl', -'theadvocate.com.au', -'thestar.com', -'towardsdatascience.com', -'vn.nl', -'washingtonpost.com', -'wsj.com', -] - -// select specific cookie(s) to hold from remove_cookies domains -const remove_cookies_select_hold = { - '.nrc.nl': ['nmt_closed_cookiebar'], - '.washingtonpost.com': ['wp_gdpr'], - '.wsj.com': ['wsjregion'] -} - -// select only specific cookie(s) to drop from remove_cookies domains -const remove_cookies_select_drop = { - 'www.nrc.nl': ['counter'] -} - -// Override User-Agent with Googlebot -const use_google_bot = [ -'barrons.com', -'nytimes.com', -'telegraph.co.uk', -'theaustralian.com.au', -'thetimes.co.uk', -'wsj.com', -] - -function setDefaultOptions() { - browser.storage.sync.set({ - sites: defaultSites - }, function() { - browser.runtime.openOptionsPage(); - }); -} - -const blockedRegexes = [ -/.+:\/\/.+\.tribdss\.com\//, -/thenation\.com\/.+\/paywall-script\.php/, -/haaretz\.co\.il\/htz\/js\/inter\.js/, -/nzherald\.co\.nz\/.+\/headjs\/.+\.js/ -]; - -const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" -const userAgentMobile = "Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible ; Googlebot/2.1 ; +http://www.google.com/bot.html)" - -var enabledSites = []; - -// Get the enabled sites -browser.storage.sync.get({ - sites: {} -}, function(items) { - var sites = items.sites; - enabledSites = Object.keys(items.sites).map(function(key) { - return items.sites[key]; - }); -}); - -// Listen for changes to options -browser.storage.onChanged.addListener(function(changes, namespace) { - var key; - for (key in changes) { - var storageChange = changes[key]; - if (key === 'sites') { - var sites = storageChange.newValue; - enabledSites = Object.keys(sites).map(function(key) { - return sites[key]; - }); - } - } -}); - -// Set and show default options on install -browser.runtime.onInstalled.addListener(function(details) { - if (details.reason == "install") { - setDefaultOptions(); - } else if (details.reason == "update") { - // User updated extension - } -}); - -/** -// WSJ bypass -browser.webRequest.onBeforeSendHeaders.addListener(function(details) { - if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1 || details.url.indexOf("/print-edition/") !== -1) { - return; - } - - var param; - var updatedUrl; - - param = getParameterByName("mod", details.url); - - if (param === null) { - updatedUrl = stripQueryStringAndHashFromPath(details.url); - updatedUrl += "?mod=rsswn"; - } else { - updatedUrl = details.url.replace(param, "rsswn"); - } - return { redirectUrl: updatedUrl}; -}, -{urls:["*://*.wsj.com/*"], types:["main_frame"]}, -["blocking"] -); -**/ - -// Disable javascript for these sites -chrome.webRequest.onBeforeRequest.addListener(function(details) { - if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1) { - return; - } - return {cancel: true}; - }, - { - urls: ["*://*.theglobeandmail.com/*", "*://*.economist.com/*", "*://*.thestar.com/*", "*://*.newstatesman.com/*", "*://*.bostonglobe.com/*", "*://*.afr.com/*"], - types: ["script"] - }, - ["blocking"] -); - -browser.webRequest.onBeforeSendHeaders.addListener(function(details) { - if (!isSiteEnabled(details)) { - return; - } - - if (blockedRegexes.some(function(regex) { return regex.test(details.url); })) { - return { cancel: true }; - } - - var requestHeaders = details.requestHeaders; - var tabId = details.tabId; - - var useUserAgentMobile = false; - var setReferer = false; - - // if referer exists, set it to google - requestHeaders = requestHeaders.map(function(requestHeader) { - if (requestHeader.name === 'Referer') { - if (details.url.indexOf("cooking.nytimes.com/api/v1/users/bootstrap") !== -1) { - // this fixes images not being loaded on cooking.nytimes.com main page - // referrer has to be *nytimes.com otherwise returns 403 - requestHeader.value = 'https://cooking.nytimes.com'; - } else if (details.url.indexOf("wsj.com") !== -1 || details.url.indexOf("ft.com") !== -1) { - requestHeader.value = 'https://www.facebook.com/'; - } else { - requestHeader.value = 'https://www.google.com/'; - } - setReferer = true; - } - if (requestHeader.name === 'User-Agent') { - useUserAgentMobile = requestHeader.value.toLowerCase().includes("mobile"); - } - - return requestHeader; - }); - - // otherwise add it - if (!setReferer) { - if (details.url.indexOf("wsj.com") !== -1) { - requestHeaders.push({ - name: 'Referer', - value: 'https://www.facebook.com/' - }); - } else { - requestHeaders.push({ - name: 'Referer', - value: 'https://www.google.com/' - }); - } - } - - // override User-Agent to use Googlebot - var useGoogleBot = use_google_bot.filter(function(item) { - return typeof item == 'string' && details.url.indexOf(item) > -1; - }).length > 0; - - if (useGoogleBot) { - requestHeaders.push({ - "name": "User-Agent", - "value": useUserAgentMobile ? userAgentMobile : userAgentDesktop - }) - requestHeaders.push({ - "name": "X-Forwarded-For", - "value": "66.249.66.1" - }) - } - - // remove cookies before page load - requestHeaders = requestHeaders.map(function(requestHeader) { - for (var siteIndex in allow_cookies) { - if (details.url.indexOf(allow_cookies[siteIndex]) !== -1) { - return requestHeader; - } - } - if (requestHeader.name === 'Cookie') { - requestHeader.value = ''; - } - return requestHeader; - }); - - if (tabId !== -1) { - // run contentScript inside tab - browser.tabs.executeScript(tabId, { - file: 'contentScript.js', - runAt: 'document_start' - }, function(res) { - if (browser.runtime.lastError || res[0]) { - return; - } - }); - } - - return { requestHeaders: requestHeaders }; -}, { - urls: [''] -}, ['blocking', 'requestHeaders']); - -// remove cookies after page load -browser.webRequest.onCompleted.addListener(function(details) { - for (var domainIndex in remove_cookies) { - var domainVar = remove_cookies[domainIndex]; - if (!enabledSites.includes(domainVar) || details.url.indexOf(domainVar) === -1) { - continue; // don't remove cookies - } - browser.cookies.getAll({domain: domainVar}, function(cookies) { - for (var i=0; i"] -}); - -function isSiteEnabled(details) { - var isEnabled = enabledSites.some(function(enabledSite) { - var useSite = details.url.indexOf("." + enabledSite) !== -1; - if (enabledSite in restrictions) { - return useSite && details.url.indexOf(restrictions[enabledSite]) !== -1; - } - return useSite; - }); - return isEnabled; -} - -function getParameterByName(name, url) { - if (!url) url = window.location.href; - name = name.replace(/[\[\]]/g, '\\$&'); - var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), - results = regex.exec(url); - if (!results) return null; - if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, ' ')); -} - -function stripQueryStringAndHashFromPath(url) { - return url.split("?")[0].split("#")[0]; -} +'use strict'; + +var defaultSites = { + 'Algemeen Dagblad': 'ad.nl', + 'Baltimore Sun': 'baltimoresun.com', + 'Barron\'s': 'barrons.com', + 'Bloomberg': 'bloomberg.com', + 'Business Insider': 'businessinsider.com', + 'Caixin': 'caixinglobal.com', + 'Chemical & Engineering News': 'cen.acs.org', + 'Chicago Tribune': 'chicagotribune.com', + 'Central Western Daily': 'centralwesterndaily.com.au', + 'Crain\'s Chicago Business': 'chicagobusiness.com', + 'Corriere Della Sera': 'corriere.it', + 'Daily Press': 'dailypress.com', + 'Denver Post': 'denverpost.com', + 'De Tijd': 'tijd.be', + 'De Groene Amsterdammer': 'groene.nl', + 'de Volkskrant': 'volkskrant.nl', + 'The Economist': 'economist.com', + 'Eindhovens Dagblad': 'ed.nl', + 'Examiner': 'examiner.com.au', + 'Financial Times': 'ft.com', + 'Foreign Policy': 'foreignpolicy.com', + 'Glassdoor': 'glassdoor.com', + 'Haaretz': 'haaretz.co.il', + 'Haaretz English': 'haaretz.com', + 'Handelsblatt': 'handelsblatt.com', + 'Hartford Courant': 'courant.com', + 'Harvard Business Review': 'hbr.org', + 'Inc.com': 'inc.com', + 'Investors Chronicle': 'investorschronicle.co.uk', + 'La Repubblica': 'repubblica.it', + 'Le Monde': 'lemonde.fr', + 'Le Temps': 'letemps.ch', + 'Los Angeles Times': 'latimes.com', + 'Medium': 'medium.com', + 'Medscape': 'medscape.com', + 'MIT Technology Review': 'technologyreview.com', + 'Mountain View Voice': 'mv-voice.com', + 'National Post': 'nationalpost.com', + 'New Statesman': 'newstatesman.com', + 'New York Magazine': 'nymag.com', + 'Nikkei Asian Review': 'asia.nikkei.com', + 'NRC': 'nrc.nl', + 'New Zealand Herald': 'nzherald.co.nz', + 'Orange County Register': 'ocregister.com', + 'Orlando Sentinel': 'orlandosentinel.com', + 'Palo Alto Online': 'paloaltoonline.com', + 'Parool': 'parool.nl', + 'Quartz': 'qz.com', + 'Quora': 'quora.com', + 'Statista': 'statista.com', + 'Telegraaf': 'telegraaf.nl', + 'SunSentinel': 'sun-sentinel.com', + 'The Advocate': 'theadvocate.com.au', + 'The Age': 'theage.com.au', + 'The Atlantic': 'theatlantic.com', + 'The Australian': 'theaustralian.com.au', + 'The Australian Financial Review': 'afr.com', + 'The Boston Globe': 'bostonglobe.com', + 'The Business Journals': 'bizjournals.com', + 'The Diplomat': 'thediplomat.com', + 'The Globe and Mail': 'theglobeandmail.com', + 'The Herald': 'theherald.com.au', + 'The Japan Times': 'japantimes.co.jp', + 'TheMarker': 'themarker.com', + 'The Mercury News': 'mercurynews.com', + 'The Morning Call': 'mcall.com', + 'The Nation': 'thenation.com', + 'The New York Times': 'nytimes.com', + 'The New Yorker': 'newyorker.com', + 'The News-Gazette': 'news-gazette.com', + 'The Saturday Paper': 'thesaturdaypaper.com.au', + 'The Spectator': 'spectator.co.uk', + 'The Seattle Times': 'seattletimes.com', + 'The Sydney Morning Herald': 'smh.com.au', + 'The Telegraph': 'telegraph.co.uk', + 'The Times': 'thetimes.co.uk', + 'The Toronto Star': 'thestar.com', + 'The Washington Post': 'washingtonpost.com', + 'The Wall Street Journal': 'wsj.com', + 'Towards Data Science': 'towardsdatascience.com', + 'Trouw': 'trouw.nl', + 'Vanity Fair': 'vanityfair.com', + 'Vrij Nederland': 'vn.nl', + 'Wired': 'wired.com' +}; + +const restrictions = { + 'barrons.com': 'barrons.com/articles' +} + +// Don't remove cookies before page load +const allow_cookies = [ +'ad.nl', +'asia.nikkei.com', +'bostonglobe.com', +'cen.acs.org', +'chicagobusiness.com', +'denverpost.com', +'economist.com', +'ed.nl', +'examiner.com.au', +'ft.com', +'hacked.com', +'hbr.org', +'lemonde.fr', +'letemps.ch', +'medium.com', +'mercurynews.com', +'newstatesman.com', +'nymag.com', +'nytimes.com', +'ocregister.com', +'parool.nl', +'qz.com', +'spectator.co.uk', +'telegraaf.nl', +'theadvocate.com.au', +'theage.com.au', +'theaustralian.com.au', +'thediplomat.com', +'thestar.com', +'towardsdatascience.com', +'trouw.nl', +'vn.nl', +'volkskrant.nl', +'washingtonpost.com', +'wsj.com', +] + +// Removes cookies after page load +const remove_cookies = [ +'ad.nl', +'asia.nikkei.com', +'bostonglobe.com', +'cen.acs.org', +'chicagobusiness.com', +'denverpost.com', +'economist.com', +'ed.nl', +'examiner.com.au', +'ft.com', +'hacked.com', +'hbr.org', +'letemps.ch', +'medium.com', +'mercurynews.com', +'newstatesman.com', +'nymag.com', +'nytimes.com', +'ocregister.com', +'qz.com', +'spectator.co.uk', +'telegraaf.nl', +'theadvocate.com.au', +'theage.com.au', +'thediplomat.com', +'thestar.com', +'towardsdatascience.com', +'vn.nl', +'washingtonpost.com', +'wsj.com', +] + +// select specific cookie(s) to hold from remove_cookies domains +const remove_cookies_select_hold = { + '.nrc.nl': ['nmt_closed_cookiebar'], + '.washingtonpost.com': ['wp_gdpr'], + '.wsj.com': ['wsjregion'] +} + +// select only specific cookie(s) to drop from remove_cookies domains +const remove_cookies_select_drop = { + 'www.nrc.nl': ['counter'] +} + +// Override User-Agent with Googlebot +const use_google_bot = [ +'barrons.com', +'nytimes.com', +'telegraph.co.uk', +'theaustralian.com.au', +'thetimes.co.uk', +'wsj.com', +] + +function setDefaultOptions() { + browser.storage.sync.set({ + sites: defaultSites + }, function() { + browser.runtime.openOptionsPage(); + }); +} + +const blockedRegexes = [ +/.+:\/\/.+\.tribdss\.com\//, +/thenation\.com\/.+\/paywall-script\.php/, +/haaretz\.co\.il\/htz\/js\/inter\.js/, +/nzherald\.co\.nz\/.+\/headjs\/.+\.js/ +]; + +const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" +const userAgentMobile = "Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible ; Googlebot/2.1 ; +http://www.google.com/bot.html)" + +var enabledSites = []; + +// Get the enabled sites +browser.storage.sync.get({ + sites: {} +}, function(items) { + var sites = items.sites; + enabledSites = Object.keys(items.sites).map(function(key) { + return items.sites[key]; + }); +}); + +// Listen for changes to options +browser.storage.onChanged.addListener(function(changes, namespace) { + var key; + for (key in changes) { + var storageChange = changes[key]; + if (key === 'sites') { + var sites = storageChange.newValue; + enabledSites = Object.keys(sites).map(function(key) { + return sites[key]; + }); + } + } +}); + +// Set and show default options on install +browser.runtime.onInstalled.addListener(function(details) { + if (details.reason == "install") { + setDefaultOptions(); + } else if (details.reason == "update") { + // User updated extension + } +}); + +/** +// WSJ bypass +browser.webRequest.onBeforeSendHeaders.addListener(function(details) { + if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1 || details.url.indexOf("/print-edition/") !== -1) { + return; + } + + var param; + var updatedUrl; + + param = getParameterByName("mod", details.url); + + if (param === null) { + updatedUrl = stripQueryStringAndHashFromPath(details.url); + updatedUrl += "?mod=rsswn"; + } else { + updatedUrl = details.url.replace(param, "rsswn"); + } + return { redirectUrl: updatedUrl}; +}, +{urls:["*://*.wsj.com/*"], types:["main_frame"]}, +["blocking"] +); +**/ + +// Disable javascript for these sites +chrome.webRequest.onBeforeRequest.addListener(function(details) { + if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1) { + return; + } + return {cancel: true}; + }, + { + urls: ["*://*.theglobeandmail.com/*", "*://*.economist.com/*", "*://*.thestar.com/*", "*://*.newstatesman.com/*", "*://*.bostonglobe.com/*", "*://*.afr.com/*"], + types: ["script"] + }, + ["blocking"] +); + +browser.webRequest.onBeforeSendHeaders.addListener(function(details) { + if (!isSiteEnabled(details)) { + return; + } + + if (blockedRegexes.some(function(regex) { return regex.test(details.url); })) { + return { cancel: true }; + } + + var requestHeaders = details.requestHeaders; + var tabId = details.tabId; + + var useUserAgentMobile = false; + var setReferer = false; + + // if referer exists, set it to google + requestHeaders = requestHeaders.map(function(requestHeader) { + if (requestHeader.name === 'Referer') { + if (details.url.indexOf("cooking.nytimes.com/api/v1/users/bootstrap") !== -1) { + // this fixes images not being loaded on cooking.nytimes.com main page + // referrer has to be *nytimes.com otherwise returns 403 + requestHeader.value = 'https://cooking.nytimes.com'; + } else if (details.url.indexOf("wsj.com") !== -1 || details.url.indexOf("ft.com") !== -1) { + requestHeader.value = 'https://www.facebook.com/'; + } else { + requestHeader.value = 'https://www.google.com/'; + } + setReferer = true; + } + if (requestHeader.name === 'User-Agent') { + useUserAgentMobile = requestHeader.value.toLowerCase().includes("mobile"); + } + + return requestHeader; + }); + + // otherwise add it + if (!setReferer) { + if (details.url.indexOf("wsj.com") !== -1) { + requestHeaders.push({ + name: 'Referer', + value: 'https://www.facebook.com/' + }); + } else { + requestHeaders.push({ + name: 'Referer', + value: 'https://www.google.com/' + }); + } + } + + // override User-Agent to use Googlebot + var useGoogleBot = use_google_bot.filter(function(item) { + return typeof item == 'string' && details.url.indexOf(item) > -1; + }).length > 0; + + if (useGoogleBot) { + requestHeaders.push({ + "name": "User-Agent", + "value": useUserAgentMobile ? userAgentMobile : userAgentDesktop + }) + requestHeaders.push({ + "name": "X-Forwarded-For", + "value": "66.249.66.1" + }) + } + + // remove cookies before page load + requestHeaders = requestHeaders.map(function(requestHeader) { + for (var siteIndex in allow_cookies) { + if (details.url.indexOf(allow_cookies[siteIndex]) !== -1) { + return requestHeader; + } + } + if (requestHeader.name === 'Cookie') { + requestHeader.value = ''; + } + return requestHeader; + }); + + if (tabId !== -1) { + // run contentScript inside tab + browser.tabs.executeScript(tabId, { + file: 'contentScript.js', + runAt: 'document_start' + }, function(res) { + if (browser.runtime.lastError || res[0]) { + return; + } + }); + } + + return { requestHeaders: requestHeaders }; +}, { + urls: [''] +}, ['blocking', 'requestHeaders']); + +// remove cookies after page load +browser.webRequest.onCompleted.addListener(function(details) { + for (var domainIndex in remove_cookies) { + var domainVar = remove_cookies[domainIndex]; + if (!enabledSites.includes(domainVar) || details.url.indexOf(domainVar) === -1) { + continue; // don't remove cookies + } + browser.cookies.getAll({domain: domainVar}, function(cookies) { + for (var i=0; i"] +}); + +function isSiteEnabled(details) { + var isEnabled = enabledSites.some(function(enabledSite) { + var useSite = details.url.indexOf("." + enabledSite) !== -1; + if (enabledSite in restrictions) { + return useSite && details.url.indexOf(restrictions[enabledSite]) !== -1; + } + return useSite; + }); + return isEnabled; +} + +function getParameterByName(name, url) { + if (!url) url = window.location.href; + name = name.replace(/[\[\]]/g, '\\$&'); + var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, ' ')); +} + +function stripQueryStringAndHashFromPath(url) { + return url.split("?")[0].split("#")[0]; +} From 7d20c5e422084585365a54f13c28589640099de6 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Tue, 29 Oct 2019 14:05:40 +0100 Subject: [PATCH 05/32] Fix styling --- background.js | 874 +++++++++++++++++++++++++------------------------- 1 file changed, 437 insertions(+), 437 deletions(-) diff --git a/background.js b/background.js index e5e6c15..882f056 100644 --- a/background.js +++ b/background.js @@ -1,437 +1,437 @@ -'use strict'; - -var defaultSites = { - 'Algemeen Dagblad': 'ad.nl', - 'Baltimore Sun': 'baltimoresun.com', - 'Barron\'s': 'barrons.com', - 'Bloomberg': 'bloomberg.com', - 'Business Insider': 'businessinsider.com', - 'Caixin': 'caixinglobal.com', - 'Chemical & Engineering News': 'cen.acs.org', - 'Chicago Tribune': 'chicagotribune.com', - 'Central Western Daily': 'centralwesterndaily.com.au', - 'Crain\'s Chicago Business': 'chicagobusiness.com', - 'Corriere Della Sera': 'corriere.it', - 'Daily Press': 'dailypress.com', - 'Denver Post': 'denverpost.com', - 'De Tijd': 'tijd.be', - 'De Groene Amsterdammer': 'groene.nl', - 'de Volkskrant': 'volkskrant.nl', - 'The Economist': 'economist.com', - 'Eindhovens Dagblad': 'ed.nl', - 'Examiner': 'examiner.com.au', - 'Financial Times': 'ft.com', - 'Foreign Policy': 'foreignpolicy.com', - 'Glassdoor': 'glassdoor.com', - 'Haaretz': 'haaretz.co.il', - 'Haaretz English': 'haaretz.com', - 'Handelsblatt': 'handelsblatt.com', - 'Hartford Courant': 'courant.com', - 'Harvard Business Review': 'hbr.org', - 'Inc.com': 'inc.com', - 'Investors Chronicle': 'investorschronicle.co.uk', - 'La Repubblica': 'repubblica.it', - 'Le Monde': 'lemonde.fr', - 'Le Temps': 'letemps.ch', - 'Los Angeles Times': 'latimes.com', - 'Medium': 'medium.com', - 'Medscape': 'medscape.com', - 'MIT Technology Review': 'technologyreview.com', - 'Mountain View Voice': 'mv-voice.com', - 'National Post': 'nationalpost.com', - 'New Statesman': 'newstatesman.com', - 'New York Magazine': 'nymag.com', - 'Nikkei Asian Review': 'asia.nikkei.com', - 'NRC': 'nrc.nl', - 'New Zealand Herald': 'nzherald.co.nz', - 'Orange County Register': 'ocregister.com', - 'Orlando Sentinel': 'orlandosentinel.com', - 'Palo Alto Online': 'paloaltoonline.com', - 'Parool': 'parool.nl', - 'Quartz': 'qz.com', - 'Quora': 'quora.com', - 'Statista': 'statista.com', - 'Telegraaf': 'telegraaf.nl', - 'SunSentinel': 'sun-sentinel.com', - 'The Advocate': 'theadvocate.com.au', - 'The Age': 'theage.com.au', - 'The Atlantic': 'theatlantic.com', - 'The Australian': 'theaustralian.com.au', - 'The Australian Financial Review': 'afr.com', - 'The Boston Globe': 'bostonglobe.com', - 'The Business Journals': 'bizjournals.com', - 'The Diplomat': 'thediplomat.com', - 'The Globe and Mail': 'theglobeandmail.com', - 'The Herald': 'theherald.com.au', - 'The Japan Times': 'japantimes.co.jp', - 'TheMarker': 'themarker.com', - 'The Mercury News': 'mercurynews.com', - 'The Morning Call': 'mcall.com', - 'The Nation': 'thenation.com', - 'The New York Times': 'nytimes.com', - 'The New Yorker': 'newyorker.com', - 'The News-Gazette': 'news-gazette.com', - 'The Saturday Paper': 'thesaturdaypaper.com.au', - 'The Spectator': 'spectator.co.uk', - 'The Seattle Times': 'seattletimes.com', - 'The Sydney Morning Herald': 'smh.com.au', - 'The Telegraph': 'telegraph.co.uk', - 'The Times': 'thetimes.co.uk', - 'The Toronto Star': 'thestar.com', - 'The Washington Post': 'washingtonpost.com', - 'The Wall Street Journal': 'wsj.com', - 'Towards Data Science': 'towardsdatascience.com', - 'Trouw': 'trouw.nl', - 'Vanity Fair': 'vanityfair.com', - 'Vrij Nederland': 'vn.nl', - 'Wired': 'wired.com' -}; - -const restrictions = { - 'barrons.com': 'barrons.com/articles' -} - -// Don't remove cookies before page load -const allow_cookies = [ -'ad.nl', -'asia.nikkei.com', -'bostonglobe.com', -'cen.acs.org', -'chicagobusiness.com', -'denverpost.com', -'economist.com', -'ed.nl', -'examiner.com.au', -'ft.com', -'hacked.com', -'hbr.org', -'lemonde.fr', -'letemps.ch', -'medium.com', -'mercurynews.com', -'newstatesman.com', -'nymag.com', -'nytimes.com', -'ocregister.com', -'parool.nl', -'qz.com', -'spectator.co.uk', -'telegraaf.nl', -'theadvocate.com.au', -'theage.com.au', -'theaustralian.com.au', -'thediplomat.com', -'thestar.com', -'towardsdatascience.com', -'trouw.nl', -'vn.nl', -'volkskrant.nl', -'washingtonpost.com', -'wsj.com', -] - -// Removes cookies after page load -const remove_cookies = [ -'ad.nl', -'asia.nikkei.com', -'bostonglobe.com', -'cen.acs.org', -'chicagobusiness.com', -'denverpost.com', -'economist.com', -'ed.nl', -'examiner.com.au', -'ft.com', -'hacked.com', -'hbr.org', -'letemps.ch', -'medium.com', -'mercurynews.com', -'newstatesman.com', -'nymag.com', -'nytimes.com', -'ocregister.com', -'qz.com', -'spectator.co.uk', -'telegraaf.nl', -'theadvocate.com.au', -'theage.com.au', -'thediplomat.com', -'thestar.com', -'towardsdatascience.com', -'vn.nl', -'washingtonpost.com', -'wsj.com', -] - -// select specific cookie(s) to hold from remove_cookies domains -const remove_cookies_select_hold = { - '.nrc.nl': ['nmt_closed_cookiebar'], - '.washingtonpost.com': ['wp_gdpr'], - '.wsj.com': ['wsjregion'] -} - -// select only specific cookie(s) to drop from remove_cookies domains -const remove_cookies_select_drop = { - 'www.nrc.nl': ['counter'] -} - -// Override User-Agent with Googlebot -const use_google_bot = [ -'barrons.com', -'nytimes.com', -'telegraph.co.uk', -'theaustralian.com.au', -'thetimes.co.uk', -'wsj.com', -] - -function setDefaultOptions() { - browser.storage.sync.set({ - sites: defaultSites - }, function() { - browser.runtime.openOptionsPage(); - }); -} - -const blockedRegexes = [ -/.+:\/\/.+\.tribdss\.com\//, -/thenation\.com\/.+\/paywall-script\.php/, -/haaretz\.co\.il\/htz\/js\/inter\.js/, -/nzherald\.co\.nz\/.+\/headjs\/.+\.js/ -]; - -const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" -const userAgentMobile = "Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible ; Googlebot/2.1 ; +http://www.google.com/bot.html)" - -var enabledSites = []; - -// Get the enabled sites -browser.storage.sync.get({ - sites: {} -}, function(items) { - var sites = items.sites; - enabledSites = Object.keys(items.sites).map(function(key) { - return items.sites[key]; - }); -}); - -// Listen for changes to options -browser.storage.onChanged.addListener(function(changes, namespace) { - var key; - for (key in changes) { - var storageChange = changes[key]; - if (key === 'sites') { - var sites = storageChange.newValue; - enabledSites = Object.keys(sites).map(function(key) { - return sites[key]; - }); - } - } -}); - -// Set and show default options on install -browser.runtime.onInstalled.addListener(function(details) { - if (details.reason == "install") { - setDefaultOptions(); - } else if (details.reason == "update") { - // User updated extension - } -}); - -/** -// WSJ bypass -browser.webRequest.onBeforeSendHeaders.addListener(function(details) { - if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1 || details.url.indexOf("/print-edition/") !== -1) { - return; - } - - var param; - var updatedUrl; - - param = getParameterByName("mod", details.url); - - if (param === null) { - updatedUrl = stripQueryStringAndHashFromPath(details.url); - updatedUrl += "?mod=rsswn"; - } else { - updatedUrl = details.url.replace(param, "rsswn"); - } - return { redirectUrl: updatedUrl}; -}, -{urls:["*://*.wsj.com/*"], types:["main_frame"]}, -["blocking"] -); -**/ - -// Disable javascript for these sites -chrome.webRequest.onBeforeRequest.addListener(function(details) { - if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1) { - return; - } - return {cancel: true}; - }, - { - urls: ["*://*.theglobeandmail.com/*", "*://*.economist.com/*", "*://*.thestar.com/*", "*://*.newstatesman.com/*", "*://*.bostonglobe.com/*", "*://*.afr.com/*"], - types: ["script"] - }, - ["blocking"] -); - -browser.webRequest.onBeforeSendHeaders.addListener(function(details) { - if (!isSiteEnabled(details)) { - return; - } - - if (blockedRegexes.some(function(regex) { return regex.test(details.url); })) { - return { cancel: true }; - } - - var requestHeaders = details.requestHeaders; - var tabId = details.tabId; - - var useUserAgentMobile = false; - var setReferer = false; - - // if referer exists, set it to google - requestHeaders = requestHeaders.map(function(requestHeader) { - if (requestHeader.name === 'Referer') { - if (details.url.indexOf("cooking.nytimes.com/api/v1/users/bootstrap") !== -1) { - // this fixes images not being loaded on cooking.nytimes.com main page - // referrer has to be *nytimes.com otherwise returns 403 - requestHeader.value = 'https://cooking.nytimes.com'; - } else if (details.url.indexOf("wsj.com") !== -1 || details.url.indexOf("ft.com") !== -1) { - requestHeader.value = 'https://www.facebook.com/'; - } else { - requestHeader.value = 'https://www.google.com/'; - } - setReferer = true; - } - if (requestHeader.name === 'User-Agent') { - useUserAgentMobile = requestHeader.value.toLowerCase().includes("mobile"); - } - - return requestHeader; - }); - - // otherwise add it - if (!setReferer) { - if (details.url.indexOf("wsj.com") !== -1) { - requestHeaders.push({ - name: 'Referer', - value: 'https://www.facebook.com/' - }); - } else { - requestHeaders.push({ - name: 'Referer', - value: 'https://www.google.com/' - }); - } - } - - // override User-Agent to use Googlebot - var useGoogleBot = use_google_bot.filter(function(item) { - return typeof item == 'string' && details.url.indexOf(item) > -1; - }).length > 0; - - if (useGoogleBot) { - requestHeaders.push({ - "name": "User-Agent", - "value": useUserAgentMobile ? userAgentMobile : userAgentDesktop - }) - requestHeaders.push({ - "name": "X-Forwarded-For", - "value": "66.249.66.1" - }) - } - - // remove cookies before page load - requestHeaders = requestHeaders.map(function(requestHeader) { - for (var siteIndex in allow_cookies) { - if (details.url.indexOf(allow_cookies[siteIndex]) !== -1) { - return requestHeader; - } - } - if (requestHeader.name === 'Cookie') { - requestHeader.value = ''; - } - return requestHeader; - }); - - if (tabId !== -1) { - // run contentScript inside tab - browser.tabs.executeScript(tabId, { - file: 'contentScript.js', - runAt: 'document_start' - }, function(res) { - if (browser.runtime.lastError || res[0]) { - return; - } - }); - } - - return { requestHeaders: requestHeaders }; -}, { - urls: [''] -}, ['blocking', 'requestHeaders']); - -// remove cookies after page load -browser.webRequest.onCompleted.addListener(function(details) { - for (var domainIndex in remove_cookies) { - var domainVar = remove_cookies[domainIndex]; - if (!enabledSites.includes(domainVar) || details.url.indexOf(domainVar) === -1) { - continue; // don't remove cookies - } - browser.cookies.getAll({domain: domainVar}, function(cookies) { - for (var i=0; i"] -}); - -function isSiteEnabled(details) { - var isEnabled = enabledSites.some(function(enabledSite) { - var useSite = details.url.indexOf("." + enabledSite) !== -1; - if (enabledSite in restrictions) { - return useSite && details.url.indexOf(restrictions[enabledSite]) !== -1; - } - return useSite; - }); - return isEnabled; -} - -function getParameterByName(name, url) { - if (!url) url = window.location.href; - name = name.replace(/[\[\]]/g, '\\$&'); - var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), - results = regex.exec(url); - if (!results) return null; - if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, ' ')); -} - -function stripQueryStringAndHashFromPath(url) { - return url.split("?")[0].split("#")[0]; -} +'use strict'; + +var defaultSites = { + 'Algemeen Dagblad': 'ad.nl', + 'Baltimore Sun': 'baltimoresun.com', + 'Barron\'s': 'barrons.com', + 'Bloomberg': 'bloomberg.com', + 'Business Insider': 'businessinsider.com', + 'Caixin': 'caixinglobal.com', + 'Chemical & Engineering News': 'cen.acs.org', + 'Chicago Tribune': 'chicagotribune.com', + 'Central Western Daily': 'centralwesterndaily.com.au', + 'Crain\'s Chicago Business': 'chicagobusiness.com', + 'Corriere Della Sera': 'corriere.it', + 'Daily Press': 'dailypress.com', + 'Denver Post': 'denverpost.com', + 'De Tijd': 'tijd.be', + 'De Groene Amsterdammer': 'groene.nl', + 'de Volkskrant': 'volkskrant.nl', + 'The Economist': 'economist.com', + 'Eindhovens Dagblad': 'ed.nl', + 'Examiner': 'examiner.com.au', + 'Financial Times': 'ft.com', + 'Foreign Policy': 'foreignpolicy.com', + 'Glassdoor': 'glassdoor.com', + 'Haaretz': 'haaretz.co.il', + 'Haaretz English': 'haaretz.com', + 'Handelsblatt': 'handelsblatt.com', + 'Hartford Courant': 'courant.com', + 'Harvard Business Review': 'hbr.org', + 'Inc.com': 'inc.com', + 'Investors Chronicle': 'investorschronicle.co.uk', + 'La Repubblica': 'repubblica.it', + 'Le Monde': 'lemonde.fr', + 'Le Temps': 'letemps.ch', + 'Los Angeles Times': 'latimes.com', + 'Medium': 'medium.com', + 'Medscape': 'medscape.com', + 'MIT Technology Review': 'technologyreview.com', + 'Mountain View Voice': 'mv-voice.com', + 'National Post': 'nationalpost.com', + 'New Statesman': 'newstatesman.com', + 'New York Magazine': 'nymag.com', + 'Nikkei Asian Review': 'asia.nikkei.com', + 'NRC': 'nrc.nl', + 'New Zealand Herald': 'nzherald.co.nz', + 'Orange County Register': 'ocregister.com', + 'Orlando Sentinel': 'orlandosentinel.com', + 'Palo Alto Online': 'paloaltoonline.com', + 'Parool': 'parool.nl', + 'Quartz': 'qz.com', + 'Quora': 'quora.com', + 'Statista': 'statista.com', + 'Telegraaf': 'telegraaf.nl', + 'SunSentinel': 'sun-sentinel.com', + 'The Advocate': 'theadvocate.com.au', + 'The Age': 'theage.com.au', + 'The Atlantic': 'theatlantic.com', + 'The Australian': 'theaustralian.com.au', + 'The Australian Financial Review': 'afr.com', + 'The Boston Globe': 'bostonglobe.com', + 'The Business Journals': 'bizjournals.com', + 'The Diplomat': 'thediplomat.com', + 'The Globe and Mail': 'theglobeandmail.com', + 'The Herald': 'theherald.com.au', + 'The Japan Times': 'japantimes.co.jp', + 'TheMarker': 'themarker.com', + 'The Mercury News': 'mercurynews.com', + 'The Morning Call': 'mcall.com', + 'The Nation': 'thenation.com', + 'The New York Times': 'nytimes.com', + 'The New Yorker': 'newyorker.com', + 'The News-Gazette': 'news-gazette.com', + 'The Saturday Paper': 'thesaturdaypaper.com.au', + 'The Spectator': 'spectator.co.uk', + 'The Seattle Times': 'seattletimes.com', + 'The Sydney Morning Herald': 'smh.com.au', + 'The Telegraph': 'telegraph.co.uk', + 'The Times': 'thetimes.co.uk', + 'The Toronto Star': 'thestar.com', + 'The Washington Post': 'washingtonpost.com', + 'The Wall Street Journal': 'wsj.com', + 'Towards Data Science': 'towardsdatascience.com', + 'Trouw': 'trouw.nl', + 'Vanity Fair': 'vanityfair.com', + 'Vrij Nederland': 'vn.nl', + 'Wired': 'wired.com' +}; + +const restrictions = { + 'barrons.com': 'barrons.com/articles' +} + +// Don't remove cookies before page load +const allow_cookies = [ +'ad.nl', +'asia.nikkei.com', +'bostonglobe.com', +'cen.acs.org', +'chicagobusiness.com', +'denverpost.com', +'economist.com', +'ed.nl', +'examiner.com.au', +'ft.com', +'hacked.com', +'hbr.org', +'lemonde.fr', +'letemps.ch', +'medium.com', +'mercurynews.com', +'newstatesman.com', +'nymag.com', +'nytimes.com', +'ocregister.com', +'parool.nl', +'qz.com', +'spectator.co.uk', +'telegraaf.nl', +'theadvocate.com.au', +'theage.com.au', +'theaustralian.com.au', +'thediplomat.com', +'thestar.com', +'towardsdatascience.com', +'trouw.nl', +'vn.nl', +'volkskrant.nl', +'washingtonpost.com', +'wsj.com', +] + +// Removes cookies after page load +const remove_cookies = [ +'ad.nl', +'asia.nikkei.com', +'bostonglobe.com', +'cen.acs.org', +'chicagobusiness.com', +'denverpost.com', +'economist.com', +'ed.nl', +'examiner.com.au', +'ft.com', +'hacked.com', +'hbr.org', +'letemps.ch', +'medium.com', +'mercurynews.com', +'newstatesman.com', +'nymag.com', +'nytimes.com', +'ocregister.com', +'qz.com', +'spectator.co.uk', +'telegraaf.nl', +'theadvocate.com.au', +'theage.com.au', +'thediplomat.com', +'thestar.com', +'towardsdatascience.com', +'vn.nl', +'washingtonpost.com', +'wsj.com', +] + +// select specific cookie(s) to hold from remove_cookies domains +const remove_cookies_select_hold = { + '.nrc.nl': ['nmt_closed_cookiebar'], + '.washingtonpost.com': ['wp_gdpr'], + '.wsj.com': ['wsjregion'] +} + +// select only specific cookie(s) to drop from remove_cookies domains +const remove_cookies_select_drop = { + 'www.nrc.nl': ['counter'] +} + +// Override User-Agent with Googlebot +const use_google_bot = [ +'barrons.com', +'nytimes.com', +'telegraph.co.uk', +'theaustralian.com.au', +'thetimes.co.uk', +'wsj.com', +] + +function setDefaultOptions() { + browser.storage.sync.set({ + sites: defaultSites + }, function() { + browser.runtime.openOptionsPage(); + }); +} + +const blockedRegexes = [ +/.+:\/\/.+\.tribdss\.com\//, +/thenation\.com\/.+\/paywall-script\.php/, +/haaretz\.co\.il\/htz\/js\/inter\.js/, +/nzherald\.co\.nz\/.+\/headjs\/.+\.js/ +]; + +const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" +const userAgentMobile = "Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible ; Googlebot/2.1 ; +http://www.google.com/bot.html)" + +var enabledSites = []; + +// Get the enabled sites +browser.storage.sync.get({ + sites: {} +}, function(items) { + var sites = items.sites; + enabledSites = Object.keys(items.sites).map(function(key) { + return items.sites[key]; + }); +}); + +// Listen for changes to options +browser.storage.onChanged.addListener(function(changes, namespace) { + var key; + for (key in changes) { + var storageChange = changes[key]; + if (key === 'sites') { + var sites = storageChange.newValue; + enabledSites = Object.keys(sites).map(function(key) { + return sites[key]; + }); + } + } +}); + +// Set and show default options on install +browser.runtime.onInstalled.addListener(function(details) { + if (details.reason == "install") { + setDefaultOptions(); + } else if (details.reason == "update") { + // User updated extension + } +}); + +/** +// WSJ bypass +browser.webRequest.onBeforeSendHeaders.addListener(function(details) { + if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1 || details.url.indexOf("/print-edition/") !== -1) { + return; + } + + var param; + var updatedUrl; + + param = getParameterByName("mod", details.url); + + if (param === null) { + updatedUrl = stripQueryStringAndHashFromPath(details.url); + updatedUrl += "?mod=rsswn"; + } else { + updatedUrl = details.url.replace(param, "rsswn"); + } + return { redirectUrl: updatedUrl}; +}, +{urls:["*://*.wsj.com/*"], types:["main_frame"]}, +["blocking"] +); +**/ + +// Disable javascript for these sites +chrome.webRequest.onBeforeRequest.addListener(function(details) { + if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1) { + return; + } + return {cancel: true}; + }, + { + urls: ["*://*.theglobeandmail.com/*", "*://*.economist.com/*", "*://*.thestar.com/*", "*://*.newstatesman.com/*", "*://*.bostonglobe.com/*", "*://*.afr.com/*"], + types: ["script"] + }, + ["blocking"] +); + +browser.webRequest.onBeforeSendHeaders.addListener(function(details) { + if (!isSiteEnabled(details)) { + return; + } + + if (blockedRegexes.some(function(regex) { return regex.test(details.url); })) { + return { cancel: true }; + } + + var requestHeaders = details.requestHeaders; + var tabId = details.tabId; + + var useUserAgentMobile = false; + var setReferer = false; + + // if referer exists, set it to google + requestHeaders = requestHeaders.map(function(requestHeader) { + if (requestHeader.name === 'Referer') { + if (details.url.indexOf("cooking.nytimes.com/api/v1/users/bootstrap") !== -1) { + // this fixes images not being loaded on cooking.nytimes.com main page + // referrer has to be *nytimes.com otherwise returns 403 + requestHeader.value = 'https://cooking.nytimes.com'; + } else if (details.url.indexOf("wsj.com") !== -1 || details.url.indexOf("ft.com") !== -1) { + requestHeader.value = 'https://www.facebook.com/'; + } else { + requestHeader.value = 'https://www.google.com/'; + } + setReferer = true; + } + if (requestHeader.name === 'User-Agent') { + useUserAgentMobile = requestHeader.value.toLowerCase().includes("mobile"); + } + + return requestHeader; + }); + + // otherwise add it + if (!setReferer) { + if (details.url.indexOf("wsj.com") !== -1) { + requestHeaders.push({ + name: 'Referer', + value: 'https://www.facebook.com/' + }); + } else { + requestHeaders.push({ + name: 'Referer', + value: 'https://www.google.com/' + }); + } + } + + // override User-Agent to use Googlebot + var useGoogleBot = use_google_bot.filter(function(item) { + return typeof item == 'string' && details.url.indexOf(item) > -1; + }).length > 0; + + if (useGoogleBot) { + requestHeaders.push({ + "name": "User-Agent", + "value": useUserAgentMobile ? userAgentMobile : userAgentDesktop + }) + requestHeaders.push({ + "name": "X-Forwarded-For", + "value": "66.249.66.1" + }) + } + + // remove cookies before page load + requestHeaders = requestHeaders.map(function(requestHeader) { + for (var siteIndex in allow_cookies) { + if (details.url.indexOf(allow_cookies[siteIndex]) !== -1) { + return requestHeader; + } + } + if (requestHeader.name === 'Cookie') { + requestHeader.value = ''; + } + return requestHeader; + }); + + if (tabId !== -1) { + // run contentScript inside tab + browser.tabs.executeScript(tabId, { + file: 'contentScript.js', + runAt: 'document_start' + }, function(res) { + if (browser.runtime.lastError || res[0]) { + return; + } + }); + } + + return { requestHeaders: requestHeaders }; +}, { + urls: [''] +}, ['blocking', 'requestHeaders']); + +// remove cookies after page load +browser.webRequest.onCompleted.addListener(function(details) { + for (var domainIndex in remove_cookies) { + var domainVar = remove_cookies[domainIndex]; + if (!enabledSites.includes(domainVar) || details.url.indexOf(domainVar) === -1) { + continue; // don't remove cookies + } + browser.cookies.getAll({domain: domainVar}, function(cookies) { + for (var i=0; i"] +}); + +function isSiteEnabled(details) { + var isEnabled = enabledSites.some(function(enabledSite) { + var useSite = details.url.indexOf("." + enabledSite) !== -1; + if (enabledSite in restrictions) { + return useSite && details.url.indexOf(restrictions[enabledSite]) !== -1; + } + return useSite; + }); + return isEnabled; +} + +function getParameterByName(name, url) { + if (!url) url = window.location.href; + name = name.replace(/[\[\]]/g, '\\$&'); + var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, ' ')); +} + +function stripQueryStringAndHashFromPath(url) { + return url.split("?")[0].split("#")[0]; +} From e4f70487fe21b8024adf445165f4e54f39374a86 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Tue, 29 Oct 2019 19:27:54 +0100 Subject: [PATCH 06/32] Fix Quora 'read more' error Fixed 'read more' error by adding quora.com to googlebot settings. --- background.js | 1 + 1 file changed, 1 insertion(+) diff --git a/background.js b/background.js index 882f056..d7d2536 100644 --- a/background.js +++ b/background.js @@ -180,6 +180,7 @@ const remove_cookies_select_drop = { const use_google_bot = [ 'barrons.com', 'nytimes.com', +'quora.com', 'telegraph.co.uk', 'theaustralian.com.au', 'thetimes.co.uk', From 65bb5fe79405b1a41f053a4a5e8683f34326a746 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Fri, 1 Nov 2019 18:25:06 +0100 Subject: [PATCH 07/32] Add Scientific American (fix free-article limit) No access to subscription-articles. --- README.md | 241 ++++++++++++++++++------------------- background.js | 5 +- manifest.json | 289 +++++++++++++++++++++++---------------------- options.js | 321 +++++++++++++++++++++++++------------------------- 4 files changed, 431 insertions(+), 425 deletions(-) diff --git a/README.md b/README.md index 1f1eb7a..01a7ef7 100644 --- a/README.md +++ b/README.md @@ -1,120 +1,121 @@ -# Bypass Paywalls for Firefox - -## [Download and install the latest version](https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.6.0/bypass_paywalls-1.6.0-an+fx.xpi) - -### Bypass the following sites' paywalls with this extension - -[Algemeen Dagblad](https://www.ad.nl)\ -[Baltimore Sun](https://www.baltimoresun.com)\ -[Barron's](https://www.barrons.com)\ -[Bloomberg](https://www.bloomberg.com)\ -[Business Insider](https://www.businessinsider.com)\ -[Caixin](https://www.caixinglobal.com)\ -[Chemical & Engineering News](https://cen.acs.org)\ -[Central Western Daily](https://www.centralwesterndaily.com.au)\ -[Chicago Tribune](https://www.chicagotribune.com)\ -[Crain's Chicago Business](https://www.chicagobusiness.com)\ -[Corriere Della Sera](https://www.corriere.it)\ -[Daily Press](https://www.dailypress.com)\ -[Denver Post](https://www.denverpost.com)\ -[De Groene Amsterdammer](https://www.groene.nl)\ -[De Tijd](https://www.tijd.be)\ -[de Volkskrant](https://www.volkskrant.nl)\ -[The Economist](https://www.economist.com)\ -[Eindhovens Dagblad](https://ed.nl)\ -[Examiner](https://www.examiner.com.au)\ -[Financial Times](https://www.ft.com)\ -[Foreign Policy](https://www.foreignpolicy.com)\ -[Glassdoor](https://www.glassdoor.com)\ -[Haaretz.co.il](https://www.haaretz.co.il)\ -[Haaretz.com](https://www.haaretz.com)\ -[Handelsblatt](https://www.handelsblatt.com)\ -[Hartford Courant](https://www.courant.com)\ -[Harvard Business Review](https://www.hbr.org)\ -[Inc.com](https://www.inc.com)\ -[Investors Chronicle](https://www.investorschronicle.co.uk)\ -[La Repubblica](https://www.repubblica.it)\ -[Le Monde](https://www.lemonde.fr)\ -[Le Temps](https://www.letemps.ch)\ -[Los Angeles Times](https://www.latimes.com)\ -[Medium](https://www.medium.com)\ -[Medscape](https://www.medscape.com)\ -[MIT Technology Review](https://www.technologyreview.com)\ -[Mountain View Voice](https://www.mv-voice.com)\ -[National Post](https://www.nationalpost.com)\ -[New Statesman](https://www.newstatesman.com)\ -[New York Magazine](https://www.nymag.com)\ -[New Zealand Herald](https://www.nzherald.co.nz)\ -[Nikkei Asian Review](https://asia.nikkei.com)\ -[NRC](https://www.nrc.nl)\ -[Orange County Register](https://www.ocregister.com)\ -[Orlando Sentinel](https://www.orlandosentinel.com)\ -[Palo Alto Online](https://www.paloaltoonline.com)\ -[Parool](https://www.parool.nl)\ -[Quartz](https://qz.com)\ -[Quora](https://www.quora.com)\ -[Statista](https://www.statista.com)\ -[SunSentinel](https://www.sun-sentinel.com)\ -[Telegraaf](https://telegraaf.nl)\ -[The Advocate](https://www.theadvocate.com.au)\ -[The Age](https://www.theage.com.au)\ -[The Atlantic](https://www.theatlantic.com)\ -[The Australian](https://www.theaustralian.com.au)\ -[The Australian Financial Review](https://www.afr.com)\ -[The Boston Globe](https://www.bostonglobe.com)\ -[The Business Journals](https://www.bizjournals.com)\ -[The Diplomat](https://www.thediplomat.com)\ -[The Globe and Mail](https://www.theglobeandmail.com)\ -[The Herald](https://www.theherald.com.au)\ -[The Japan Times](https://www.japantimes.co.jp)\ -[TheMarker](https://www.themarker.com)\ -[The Mercury News](https://www.mercurynews.com)\ -[The Morning Call](https://www.mcall.com)\ -[The Nation](https://www.thenation.com)\ -[The New York Times](https://www.nytimes.com)\ -[The New Yorker](https://www.newyorker.com)\ -[The News-Gazette](https://www.news-gazette.com)\ -[The Saturday Paper](https://www.thesaturdaypaper.com.au)\ -[The Spectator](https://www.spectator.co.uk)\ -[The Seattle Times](https://www.seattletimes.com)\ -[The Sydney Morning Herald](https://www.smh.com.au)\ -[The Telegraph](https://www.telegraph.co.uk)\ -[The Times](https://www.thetimes.co.uk)\ -[The Toronto Star](https://www.thestar.com)\ -[The Washington Post](https://www.washingtonpost.com)\ -[The Wall Street Journal](https://www.wsj.com)\ -[Towards Data Science](https://www.towardsdatascience.com)\ -[Trouw](https://www.trouw.nl)\ -[Vanity Fair](https://www.vanityfair.com)\ -[Vrij Nederland](https://www.vn.nl)\ -[Wired](https://www.wired.com) - -### Sites with limited number of free articles -The free article limit can normally be bypassed by removing cookies for the site.* - -Install the [Cookie Remover](https://addons.mozilla.org/en-US/firefox/addon/cookie-remover/) Add-on. - -When coming across a paywall click the cookie icon to remove the cookies then refresh the page. - -_*May not always succeed_ - -### New site requests -Only large or major sites will be considered. No small sites or local newspapers. -1. Visit an article on the site you want to bypass the paywall for and copy the article title. -2. Open up a new Private window (Ctrl+Shift+P) and paste the article title into Google. -3. Click on the same article from the Google search results page. If it loads without a paywall you can [submit a request](https://github.com/iamadamdev/bypass-paywalls-firefox/issues/new) to add the site, otherwise my extension cannot bypass it either. - -Usually premium articles cannot be bypassed as they are behind a hard paywall. - -### Troubleshooting -* This add-on works best alongside [uBlock Origin](https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/). -* If a site doesn't work try turning off uBlock and refreshing. - -### Pull Requesets -* PRs are welcome. - -### Show your support -* I am not asking for donations or anything like that, all I ask is that you star this repo. - -### License -Bypass Paywalls is [MIT-licensed](https://github.com/iamadamdev/bypass-paywalls-firefox/blob/master/LICENSE). +# Bypass Paywalls for Firefox + +## [Download and install the latest version](https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.6.0/bypass_paywalls-1.6.0-an+fx.xpi) + +### Bypass the following sites' paywalls with this extension + +[Algemeen Dagblad](https://www.ad.nl)\ +[Baltimore Sun](https://www.baltimoresun.com)\ +[Barron's](https://www.barrons.com)\ +[Bloomberg](https://www.bloomberg.com)\ +[Business Insider](https://www.businessinsider.com)\ +[Caixin](https://www.caixinglobal.com)\ +[Chemical & Engineering News](https://cen.acs.org)\ +[Central Western Daily](https://www.centralwesterndaily.com.au)\ +[Chicago Tribune](https://www.chicagotribune.com)\ +[Crain's Chicago Business](https://www.chicagobusiness.com)\ +[Corriere Della Sera](https://www.corriere.it)\ +[Daily Press](https://www.dailypress.com)\ +[Denver Post](https://www.denverpost.com)\ +[De Groene Amsterdammer](https://www.groene.nl)\ +[De Tijd](https://www.tijd.be)\ +[de Volkskrant](https://www.volkskrant.nl)\ +[The Economist](https://www.economist.com)\ +[Eindhovens Dagblad](https://ed.nl)\ +[Examiner](https://www.examiner.com.au)\ +[Financial Times](https://www.ft.com)\ +[Foreign Policy](https://www.foreignpolicy.com)\ +[Glassdoor](https://www.glassdoor.com)\ +[Haaretz.co.il](https://www.haaretz.co.il)\ +[Haaretz.com](https://www.haaretz.com)\ +[Handelsblatt](https://www.handelsblatt.com)\ +[Hartford Courant](https://www.courant.com)\ +[Harvard Business Review](https://www.hbr.org)\ +[Inc.com](https://www.inc.com)\ +[Investors Chronicle](https://www.investorschronicle.co.uk)\ +[La Repubblica](https://www.repubblica.it)\ +[Le Monde](https://www.lemonde.fr)\ +[Le Temps](https://www.letemps.ch)\ +[Los Angeles Times](https://www.latimes.com)\ +[Medium](https://www.medium.com)\ +[Medscape](https://www.medscape.com)\ +[MIT Technology Review](https://www.technologyreview.com)\ +[Mountain View Voice](https://www.mv-voice.com)\ +[National Post](https://www.nationalpost.com)\ +[New Statesman](https://www.newstatesman.com)\ +[New York Magazine](https://www.nymag.com)\ +[New Zealand Herald](https://www.nzherald.co.nz)\ +[Nikkei Asian Review](https://asia.nikkei.com)\ +[NRC](https://www.nrc.nl)\ +[Orange County Register](https://www.ocregister.com)\ +[Orlando Sentinel](https://www.orlandosentinel.com)\ +[Palo Alto Online](https://www.paloaltoonline.com)\ +[Parool](https://www.parool.nl)\ +[Quartz](https://qz.com)\ +[Quora](https://www.quora.com)\ +[Scientific American](https://scientificamerican.com)\ +[Statista](https://www.statista.com)\ +[SunSentinel](https://www.sun-sentinel.com)\ +[Telegraaf](https://telegraaf.nl)\ +[The Advocate](https://www.theadvocate.com.au)\ +[The Age](https://www.theage.com.au)\ +[The Atlantic](https://www.theatlantic.com)\ +[The Australian](https://www.theaustralian.com.au)\ +[The Australian Financial Review](https://www.afr.com)\ +[The Boston Globe](https://www.bostonglobe.com)\ +[The Business Journals](https://www.bizjournals.com)\ +[The Diplomat](https://www.thediplomat.com)\ +[The Globe and Mail](https://www.theglobeandmail.com)\ +[The Herald](https://www.theherald.com.au)\ +[The Japan Times](https://www.japantimes.co.jp)\ +[TheMarker](https://www.themarker.com)\ +[The Mercury News](https://www.mercurynews.com)\ +[The Morning Call](https://www.mcall.com)\ +[The Nation](https://www.thenation.com)\ +[The New York Times](https://www.nytimes.com)\ +[The New Yorker](https://www.newyorker.com)\ +[The News-Gazette](https://www.news-gazette.com)\ +[The Saturday Paper](https://www.thesaturdaypaper.com.au)\ +[The Spectator](https://www.spectator.co.uk)\ +[The Seattle Times](https://www.seattletimes.com)\ +[The Sydney Morning Herald](https://www.smh.com.au)\ +[The Telegraph](https://www.telegraph.co.uk)\ +[The Times](https://www.thetimes.co.uk)\ +[The Toronto Star](https://www.thestar.com)\ +[The Washington Post](https://www.washingtonpost.com)\ +[The Wall Street Journal](https://www.wsj.com)\ +[Towards Data Science](https://www.towardsdatascience.com)\ +[Trouw](https://www.trouw.nl)\ +[Vanity Fair](https://www.vanityfair.com)\ +[Vrij Nederland](https://www.vn.nl)\ +[Wired](https://www.wired.com) + +### Sites with limited number of free articles +The free article limit can normally be bypassed by removing cookies for the site.* + +Install the [Cookie Remover](https://addons.mozilla.org/en-US/firefox/addon/cookie-remover/) Add-on. + +When coming across a paywall click the cookie icon to remove the cookies then refresh the page. + +_*May not always succeed_ + +### New site requests +Only large or major sites will be considered. No small sites or local newspapers. +1. Visit an article on the site you want to bypass the paywall for and copy the article title. +2. Open up a new Private window (Ctrl+Shift+P) and paste the article title into Google. +3. Click on the same article from the Google search results page. If it loads without a paywall you can [submit a request](https://github.com/iamadamdev/bypass-paywalls-firefox/issues/new) to add the site, otherwise my extension cannot bypass it either. + +Usually premium articles cannot be bypassed as they are behind a hard paywall. + +### Troubleshooting +* This add-on works best alongside [uBlock Origin](https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/). +* If a site doesn't work try turning off uBlock and refreshing. + +### Pull Requesets +* PRs are welcome. + +### Show your support +* I am not asking for donations or anything like that, all I ask is that you star this repo. + +### License +Bypass Paywalls is [MIT-licensed](https://github.com/iamadamdev/bypass-paywalls-firefox/blob/master/LICENSE). diff --git a/background.js b/background.js index d7d2536..a9bf7a4 100644 --- a/background.js +++ b/background.js @@ -50,9 +50,10 @@ var defaultSites = { 'Parool': 'parool.nl', 'Quartz': 'qz.com', 'Quora': 'quora.com', + 'Scientific American': 'scientificamerican.com', 'Statista': 'statista.com', - 'Telegraaf': 'telegraaf.nl', 'SunSentinel': 'sun-sentinel.com', + 'Telegraaf': 'telegraaf.nl', 'The Advocate': 'theadvocate.com.au', 'The Age': 'theage.com.au', 'The Atlantic': 'theatlantic.com', @@ -115,6 +116,7 @@ const allow_cookies = [ 'ocregister.com', 'parool.nl', 'qz.com', +'scientificamerican.com', 'spectator.co.uk', 'telegraaf.nl', 'theadvocate.com.au', @@ -152,6 +154,7 @@ const remove_cookies = [ 'nytimes.com', 'ocregister.com', 'qz.com', +'scientificamerican.com', 'spectator.co.uk', 'telegraaf.nl', 'theadvocate.com.au', diff --git a/manifest.json b/manifest.json index 052c628..c56be16 100644 --- a/manifest.json +++ b/manifest.json @@ -1,144 +1,145 @@ -{ - "background": { - "scripts": ["background.js"] - }, - "content_scripts": [ - { - "matches": [ - "*://*.bizjournals.com/*", - "*://*.bloomberg.com/*", - "*://*.businessinsider.com/*", - "*://*.ed.nl/*", - "*://*.haaretz.co.il/*", - "*://*.lemonde.fr/*", - "*://*.nzherald.co.nz/*", - "*://*.parool.nl/*", - "*://*.repubblica.it/*", - "*://*.telegraaf.nl/*", - "*://*.trouw.nl/*", - "*://*.volkskrant.nl/*", - "*://*.washingtonpost.com/*" - ], - "js": ["contentScript.js"] - } - ], - "applications": { - "gecko": { - "id": "bypasspaywalls@bypasspaywalls.weebly.com", - "update_url": "https://raw.githubusercontent.com/iamadamdev/bypass-paywalls-firefox/master/updates.json" - } - }, - "browser_action": { - "default_popup": "popup.html", - "default_icon": { - "128": "bypass.png" - }, - "theme_icons": [ - { - "light": "bypass-dark.png", - "dark": "bypass.png", - "size": 128 - } - ] - }, - "description": "Bypass News Sites' Paywalls", - "icons": { - "128": "bypass.png" - }, - "manifest_version": 2, - "name": "Bypass Paywalls", - "short_name": "Bypass Paywall", - "options_ui": { - "page": "options.html" - }, - "permissions": [ - "cookies", - "storage", - "webRequest", - "webRequestBlocking", - "*://*.baltimoresun.com/*", - "*://*.barrons.com/*", - "*://*.bloomberg.com/*", - "*://*.businessinsider.com/*", - "*://*.caixinglobal.com/*", - "*://*.cen.acs.org/*", - "*://*.chicagotribune.com/*", - "*://*.centralwesterndaily.com.au/*", - "*://*.chicagobusiness.com/*", - "*://*.corriere.it/*", - "*://*.dailypress.com/*", - "*://*.denverpost.com/*", - "*://*.tijd.be/*", - "*://*.volkskrant.nl/*", - "*://*.economist.com/*", - "*://*.examiner.com.au/*", - "*://*.ft.com/*", - "*://*.foreignpolicy.com/*", - "*://*.glassdoor.com/*", - "*://*.haaretz.co.il/*", - "*://*.haaretz.com/*", - "*://*.handelsblatt.com/*", - "*://*.courant.com/*", - "*://*.hbr.org/*", - "*://*.inc.com/*", - "*://*.investorschronicle.co.uk/*", - "*://*.repubblica.it/*", - "*://*.letemps.ch/*", - "*://*.latimes.com/*", - "*://*.medium.com/*", - "*://*.medscape.com/*", - "*://*.technologyreview.com/*", - "*://*.mv-voice.com/*", - "*://*.nationalpost.com/*", - "*://*.newstatesman.com/*", - "*://*.nymag.com/*", - "*://*.nzherald.co.nz/*", - "*://*.asia.nikkei.com/*", - "*://*.nrc.nl/*", - "*://*.ocregister.com/*", - "*://*.orlandosentinel.com/*", - "*://*.paloaltoonline.com/*", - "*://*.quora.com/*", - "*://*.sun-sentinel.com/*", - "*://*.theadvocate.com.au/*", - "*://*.theage.com.au/*", - "*://*.theaustralian.com.au/*", - "*://*.afr.com/*", - "*://*.bostonglobe.com/*", - "*://*.bizjournals.com/*", - "*://*.theglobeandmail.com/*", - "*://*.theherald.com.au/*", - "*://*.japantimes.co.jp/*", - "*://*.themarker.com/*", - "*://*.mercurynews.com/*", - "*://*.mcall.com/*", - "*://*.thenation.com/*", - "*://*.nytimes.com/*", - "*://*.newyorker.com/*", - "*://*.news-gazette.com/*", - "*://*.thesaturdaypaper.com.au/*", - "*://*.spectator.co.uk/*", - "*://*.seattletimes.com/*", - "*://*.smh.com.au/*", - "*://*.telegraph.co.uk/*", - "*://*.thetimes.co.uk/*", - "*://*.thestar.com/*", - "*://*.washingtonpost.com/*", - "*://*.wsj.com/*", - "*://*.towardsdatascience.com/*", - "*://*.vanityfair.com/*", - "*://*.wired.com/*", - "*://*.thediplomat.com/*", - "*://*.theatlantic.com/*", - "*://*.qz.com/*", - "*://*.ad.nl/*", - "*://*.ed.nl/*", - "*://*.groene.nl/*", - "*://*.parool.nl/*", - "*://*.telegraaf.nl/*", - "*://*.trouw.nl/*", - "*://*.vn.nl/*", - "*://*.lemonde.fr/*" - ], - "version": "1.6.0" -} +{ + "background": { + "scripts": ["background.js"] + }, + "content_scripts": [ + { + "matches": [ + "*://*.bizjournals.com/*", + "*://*.bloomberg.com/*", + "*://*.businessinsider.com/*", + "*://*.ed.nl/*", + "*://*.haaretz.co.il/*", + "*://*.lemonde.fr/*", + "*://*.nzherald.co.nz/*", + "*://*.parool.nl/*", + "*://*.repubblica.it/*", + "*://*.telegraaf.nl/*", + "*://*.trouw.nl/*", + "*://*.volkskrant.nl/*", + "*://*.washingtonpost.com/*" + ], + "js": ["contentScript.js"] + } + ], + "applications": { + "gecko": { + "id": "bypasspaywalls@bypasspaywalls.weebly.com", + "update_url": "https://raw.githubusercontent.com/iamadamdev/bypass-paywalls-firefox/master/updates.json" + } + }, + "browser_action": { + "default_popup": "popup.html", + "default_icon": { + "128": "bypass.png" + }, + "theme_icons": [ + { + "light": "bypass-dark.png", + "dark": "bypass.png", + "size": 128 + } + ] + }, + "description": "Bypass News Sites' Paywalls", + "icons": { + "128": "bypass.png" + }, + "manifest_version": 2, + "name": "Bypass Paywalls", + "short_name": "Bypass Paywall", + "options_ui": { + "page": "options.html" + }, + "permissions": [ + "cookies", + "storage", + "webRequest", + "webRequestBlocking", + "*://*.baltimoresun.com/*", + "*://*.barrons.com/*", + "*://*.bloomberg.com/*", + "*://*.businessinsider.com/*", + "*://*.caixinglobal.com/*", + "*://*.cen.acs.org/*", + "*://*.chicagotribune.com/*", + "*://*.centralwesterndaily.com.au/*", + "*://*.chicagobusiness.com/*", + "*://*.corriere.it/*", + "*://*.dailypress.com/*", + "*://*.denverpost.com/*", + "*://*.tijd.be/*", + "*://*.volkskrant.nl/*", + "*://*.economist.com/*", + "*://*.examiner.com.au/*", + "*://*.ft.com/*", + "*://*.foreignpolicy.com/*", + "*://*.glassdoor.com/*", + "*://*.haaretz.co.il/*", + "*://*.haaretz.com/*", + "*://*.handelsblatt.com/*", + "*://*.courant.com/*", + "*://*.hbr.org/*", + "*://*.inc.com/*", + "*://*.investorschronicle.co.uk/*", + "*://*.repubblica.it/*", + "*://*.letemps.ch/*", + "*://*.latimes.com/*", + "*://*.medium.com/*", + "*://*.medscape.com/*", + "*://*.technologyreview.com/*", + "*://*.mv-voice.com/*", + "*://*.nationalpost.com/*", + "*://*.newstatesman.com/*", + "*://*.nymag.com/*", + "*://*.nzherald.co.nz/*", + "*://*.asia.nikkei.com/*", + "*://*.nrc.nl/*", + "*://*.ocregister.com/*", + "*://*.orlandosentinel.com/*", + "*://*.paloaltoonline.com/*", + "*://*.quora.com/*", + "*://*.sun-sentinel.com/*", + "*://*.theadvocate.com.au/*", + "*://*.theage.com.au/*", + "*://*.theaustralian.com.au/*", + "*://*.afr.com/*", + "*://*.bostonglobe.com/*", + "*://*.bizjournals.com/*", + "*://*.theglobeandmail.com/*", + "*://*.theherald.com.au/*", + "*://*.japantimes.co.jp/*", + "*://*.themarker.com/*", + "*://*.mercurynews.com/*", + "*://*.mcall.com/*", + "*://*.thenation.com/*", + "*://*.nytimes.com/*", + "*://*.newyorker.com/*", + "*://*.news-gazette.com/*", + "*://*.thesaturdaypaper.com.au/*", + "*://*.spectator.co.uk/*", + "*://*.seattletimes.com/*", + "*://*.smh.com.au/*", + "*://*.telegraph.co.uk/*", + "*://*.thetimes.co.uk/*", + "*://*.thestar.com/*", + "*://*.washingtonpost.com/*", + "*://*.wsj.com/*", + "*://*.towardsdatascience.com/*", + "*://*.vanityfair.com/*", + "*://*.wired.com/*", + "*://*.thediplomat.com/*", + "*://*.theatlantic.com/*", + "*://*.qz.com/*", + "*://*.ad.nl/*", + "*://*.ed.nl/*", + "*://*.groene.nl/*", + "*://*.parool.nl/*", + "*://*.telegraaf.nl/*", + "*://*.trouw.nl/*", + "*://*.vn.nl/*", + "*://*.lemonde.fr/*", + "*://*.scientificamerican.com/*" + ], + "version": "1.6.0" +} diff --git a/options.js b/options.js index 19a0d34..a68eaa8 100644 --- a/options.js +++ b/options.js @@ -1,160 +1,161 @@ -var defaultSites = { - 'Algemeen Dagblad': 'ad.nl', - 'Baltimore Sun': 'baltimoresun.com', - 'Barron\'s': 'barrons.com', - 'Bloomberg': 'bloomberg.com', - 'Business Insider': 'businessinsider.com', - 'Caixin': 'caixinglobal.com', - 'Chemical & Engineering News': 'cen.acs.org', - 'Chicago Tribune': 'chicagotribune.com', - 'Central Western Daily': 'centralwesterndaily.com.au', - 'Crain\'s Chicago Business': 'chicagobusiness.com', - 'Corriere Della Sera': 'corriere.it', - 'Daily Press': 'dailypress.com', - 'Denver Post': 'denverpost.com', - 'De Groene Amsterdammer': 'groene.nl', - 'De Tijd': 'tijd.be', - 'de Volkskrant': 'volkskrant.nl', - 'The Economist (javascript disabled)': 'economist.com', - 'Eindhovens Dagblad': 'ed.nl', - 'Examiner': 'examiner.com.au', - 'Financial Times': 'ft.com', - 'Foreign Policy': 'foreignpolicy.com', - 'Glassdoor': 'glassdoor.com', - 'Haaretz': 'haaretz.co.il', - 'Haaretz English': 'haaretz.com', - 'Handelsblatt': 'handelsblatt.com', - 'Hartford Courant': 'courant.com', - 'Harvard Business Review': 'hbr.org', - 'Inc.com': 'inc.com', - 'Investors Chronicle': 'investorschronicle.co.uk', - 'La Repubblica': 'repubblica.it', - 'Le Monde': 'lemonde.fr', - 'Le Temps': 'letemps.ch', - 'Los Angeles Times': 'latimes.com', - 'Medium': 'medium.com', - 'Medscape': 'medscape.com', - 'MIT Technology Review': 'technologyreview.com', - 'Mountain View Voice': 'mv-voice.com', - 'National Post': 'nationalpost.com', - 'New Statesman (javascript disabled)': 'newstatesman.com', - 'New York Magazine': 'nymag.com', - 'New Zealand Herald': 'nzherald.co.nz', - 'Nikkei Asian Review': 'asia.nikkei.com', - 'NRC': 'nrc.nl', - 'Orange County Register': 'ocregister.com', - 'Orlando Sentinel': 'orlandosentinel.com', - 'Palo Alto Online': 'paloaltoonline.com', - 'Parool': 'parool.nl', - 'Quartz': 'qz.com', - 'Quora': 'quora.com', - 'Statista': 'statista.com', - 'SunSentinel': 'sun-sentinel.com', - 'Telegraaf': 'telegraaf.nl', - 'The Advocate': 'theadvocate.com.au', - 'The Age': 'theage.com.au', - 'The Atlantic': 'theatlantic.com', - 'The Australian': 'theaustralian.com.au', - 'The Australian Financial Review (javascript disabled)': 'afr.com', - 'The Boston Globe (javascript disabled)': 'bostonglobe.com', - 'The Business Journals': 'bizjournals.com', - 'The Diplomat': 'thediplomat.com', - 'The Globe and Mail (javascript disabled)': 'theglobeandmail.com', - 'The Herald': 'theherald.com.au', - 'The Japan Times': 'japantimes.co.jp', - 'TheMarker': 'themarker.com', - 'The Mercury News': 'mercurynews.com', - 'The Morning Call': 'mcall.com', - 'The Nation': 'thenation.com', - 'The New York Times': 'nytimes.com', - 'The New Yorker': 'newyorker.com', - 'The News-Gazette': 'news-gazette.com', - 'The Saturday Paper': 'thesaturdaypaper.com.au', - 'The Spectator': 'spectator.co.uk', - 'The Seattle Times': 'seattletimes.com', - 'The Sydney Morning Herald': 'smh.com.au', - 'The Telegraph': 'telegraph.co.uk', - 'The Times': 'thetimes.co.uk', - 'The Toronto Star (javascript disabled)': 'thestar.com', - 'The Washington Post': 'washingtonpost.com', - 'The Wall Street Journal': 'wsj.com', - 'Towards Data Science': 'towardsdatascience.com', - 'Trouw': 'trouw.nl', - 'Vanity Fair': 'vanityfair.com', - 'Vrij Nederland': 'vn.nl', - 'Wired': 'wired.com' -}; - -// Saves options to browser.storage -function save_options() { - var gh_url = document.getElementById('bypass_sites').value; - var inputEls = document.querySelectorAll('#bypass_sites input'); - var sites = {}; - - var sites = Array.from(inputEls).reduce(function(memo, inputEl) { - if (inputEl.checked) { - memo[inputEl.dataset.key] = inputEl.dataset.value; - } - return memo; - }, {}); - - browser.storage.sync.set({ - sites: sites - }, function() { - // Update status to let user know options were saved. - var status = document.getElementById('status'); - status.textContent = 'Options saved.'; - setTimeout(function() { - // status.textContent = ''; - window.close(); - }, 500); - }); -} - -// Restores checkbox input states using the preferences -// stored in browser.storage. -function renderOptions() { - browser.storage.sync.get({ - sites: {} - }, function(items) { - var sites = items.sites; - var sitesEl = document.getElementById('bypass_sites'); - for (var key in defaultSites) { - if (!defaultSites.hasOwnProperty(key)) { - continue; - } - - var value = defaultSites[key]; - var labelEl = document.createElement('label'); - var inputEl = document.createElement('input'); - inputEl.type = 'checkbox'; - inputEl.dataset.key = key; - inputEl.dataset.value = value; - inputEl.checked = key in sites; - - labelEl.appendChild(inputEl); - labelEl.appendChild(document.createTextNode(' '+key)); - sitesEl.appendChild(labelEl); - } - }); -} - -function selectAll() { - var inputEls = Array.from(document.querySelectorAll('input')); - inputEls.forEach(function(inputEl) { - inputEl.checked = true; - }); -} - -function selectNone() { - var inputEls = Array.from(document.querySelectorAll('input')); - inputEls.forEach(function(inputEl) { - inputEl.checked = false; - }); -} - -document.addEventListener('DOMContentLoaded', renderOptions); -document.getElementById('save').addEventListener('click', save_options); -document.getElementById('select-all').addEventListener('click', selectAll); -document.getElementById('select-none').addEventListener('click', selectNone); - +var defaultSites = { + 'Algemeen Dagblad': 'ad.nl', + 'Baltimore Sun': 'baltimoresun.com', + 'Barron\'s': 'barrons.com', + 'Bloomberg': 'bloomberg.com', + 'Business Insider': 'businessinsider.com', + 'Caixin': 'caixinglobal.com', + 'Chemical & Engineering News': 'cen.acs.org', + 'Chicago Tribune': 'chicagotribune.com', + 'Central Western Daily': 'centralwesterndaily.com.au', + 'Crain\'s Chicago Business': 'chicagobusiness.com', + 'Corriere Della Sera': 'corriere.it', + 'Daily Press': 'dailypress.com', + 'Denver Post': 'denverpost.com', + 'De Groene Amsterdammer': 'groene.nl', + 'De Tijd': 'tijd.be', + 'de Volkskrant': 'volkskrant.nl', + 'The Economist (javascript disabled)': 'economist.com', + 'Eindhovens Dagblad': 'ed.nl', + 'Examiner': 'examiner.com.au', + 'Financial Times': 'ft.com', + 'Foreign Policy': 'foreignpolicy.com', + 'Glassdoor': 'glassdoor.com', + 'Haaretz': 'haaretz.co.il', + 'Haaretz English': 'haaretz.com', + 'Handelsblatt': 'handelsblatt.com', + 'Hartford Courant': 'courant.com', + 'Harvard Business Review': 'hbr.org', + 'Inc.com': 'inc.com', + 'Investors Chronicle': 'investorschronicle.co.uk', + 'La Repubblica': 'repubblica.it', + 'Le Monde': 'lemonde.fr', + 'Le Temps': 'letemps.ch', + 'Los Angeles Times': 'latimes.com', + 'Medium': 'medium.com', + 'Medscape': 'medscape.com', + 'MIT Technology Review': 'technologyreview.com', + 'Mountain View Voice': 'mv-voice.com', + 'National Post': 'nationalpost.com', + 'New Statesman (javascript disabled)': 'newstatesman.com', + 'New York Magazine': 'nymag.com', + 'New Zealand Herald': 'nzherald.co.nz', + 'Nikkei Asian Review': 'asia.nikkei.com', + 'NRC': 'nrc.nl', + 'Orange County Register': 'ocregister.com', + 'Orlando Sentinel': 'orlandosentinel.com', + 'Palo Alto Online': 'paloaltoonline.com', + 'Parool': 'parool.nl', + 'Quartz': 'qz.com', + 'Quora': 'quora.com', + 'Scientific American': 'scientificamerican.com', + 'Statista': 'statista.com', + 'SunSentinel': 'sun-sentinel.com', + 'Telegraaf': 'telegraaf.nl', + 'The Advocate': 'theadvocate.com.au', + 'The Age': 'theage.com.au', + 'The Atlantic': 'theatlantic.com', + 'The Australian': 'theaustralian.com.au', + 'The Australian Financial Review (javascript disabled)': 'afr.com', + 'The Boston Globe (javascript disabled)': 'bostonglobe.com', + 'The Business Journals': 'bizjournals.com', + 'The Diplomat': 'thediplomat.com', + 'The Globe and Mail (javascript disabled)': 'theglobeandmail.com', + 'The Herald': 'theherald.com.au', + 'The Japan Times': 'japantimes.co.jp', + 'TheMarker': 'themarker.com', + 'The Mercury News': 'mercurynews.com', + 'The Morning Call': 'mcall.com', + 'The Nation': 'thenation.com', + 'The New York Times': 'nytimes.com', + 'The New Yorker': 'newyorker.com', + 'The News-Gazette': 'news-gazette.com', + 'The Saturday Paper': 'thesaturdaypaper.com.au', + 'The Spectator': 'spectator.co.uk', + 'The Seattle Times': 'seattletimes.com', + 'The Sydney Morning Herald': 'smh.com.au', + 'The Telegraph': 'telegraph.co.uk', + 'The Times': 'thetimes.co.uk', + 'The Toronto Star (javascript disabled)': 'thestar.com', + 'The Washington Post': 'washingtonpost.com', + 'The Wall Street Journal': 'wsj.com', + 'Towards Data Science': 'towardsdatascience.com', + 'Trouw': 'trouw.nl', + 'Vanity Fair': 'vanityfair.com', + 'Vrij Nederland': 'vn.nl', + 'Wired': 'wired.com' +}; + +// Saves options to browser.storage +function save_options() { + var gh_url = document.getElementById('bypass_sites').value; + var inputEls = document.querySelectorAll('#bypass_sites input'); + var sites = {}; + + var sites = Array.from(inputEls).reduce(function(memo, inputEl) { + if (inputEl.checked) { + memo[inputEl.dataset.key] = inputEl.dataset.value; + } + return memo; + }, {}); + + browser.storage.sync.set({ + sites: sites + }, function() { + // Update status to let user know options were saved. + var status = document.getElementById('status'); + status.textContent = 'Options saved.'; + setTimeout(function() { + // status.textContent = ''; + window.close(); + }, 500); + }); +} + +// Restores checkbox input states using the preferences +// stored in browser.storage. +function renderOptions() { + browser.storage.sync.get({ + sites: {} + }, function(items) { + var sites = items.sites; + var sitesEl = document.getElementById('bypass_sites'); + for (var key in defaultSites) { + if (!defaultSites.hasOwnProperty(key)) { + continue; + } + + var value = defaultSites[key]; + var labelEl = document.createElement('label'); + var inputEl = document.createElement('input'); + inputEl.type = 'checkbox'; + inputEl.dataset.key = key; + inputEl.dataset.value = value; + inputEl.checked = key in sites; + + labelEl.appendChild(inputEl); + labelEl.appendChild(document.createTextNode(' '+key)); + sitesEl.appendChild(labelEl); + } + }); +} + +function selectAll() { + var inputEls = Array.from(document.querySelectorAll('input')); + inputEls.forEach(function(inputEl) { + inputEl.checked = true; + }); +} + +function selectNone() { + var inputEls = Array.from(document.querySelectorAll('input')); + inputEls.forEach(function(inputEl) { + inputEl.checked = false; + }); +} + +document.addEventListener('DOMContentLoaded', renderOptions); +document.getElementById('save').addEventListener('click', save_options); +document.getElementById('select-all').addEventListener('click', selectAll); +document.getElementById('select-none').addEventListener('click', selectNone); + From 3dbc7d8f6aa03ee8d7720c341b145b0e4dd0f0c0 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Fri, 1 Nov 2019 18:40:39 +0100 Subject: [PATCH 08/32] Restore styling --- README.md | 242 ++++++++++++++++++------------------- manifest.json | 290 ++++++++++++++++++++++----------------------- options.js | 322 +++++++++++++++++++++++++------------------------- 3 files changed, 427 insertions(+), 427 deletions(-) diff --git a/README.md b/README.md index 01a7ef7..f62669b 100644 --- a/README.md +++ b/README.md @@ -1,121 +1,121 @@ -# Bypass Paywalls for Firefox - -## [Download and install the latest version](https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.6.0/bypass_paywalls-1.6.0-an+fx.xpi) - -### Bypass the following sites' paywalls with this extension - -[Algemeen Dagblad](https://www.ad.nl)\ -[Baltimore Sun](https://www.baltimoresun.com)\ -[Barron's](https://www.barrons.com)\ -[Bloomberg](https://www.bloomberg.com)\ -[Business Insider](https://www.businessinsider.com)\ -[Caixin](https://www.caixinglobal.com)\ -[Chemical & Engineering News](https://cen.acs.org)\ -[Central Western Daily](https://www.centralwesterndaily.com.au)\ -[Chicago Tribune](https://www.chicagotribune.com)\ -[Crain's Chicago Business](https://www.chicagobusiness.com)\ -[Corriere Della Sera](https://www.corriere.it)\ -[Daily Press](https://www.dailypress.com)\ -[Denver Post](https://www.denverpost.com)\ -[De Groene Amsterdammer](https://www.groene.nl)\ -[De Tijd](https://www.tijd.be)\ -[de Volkskrant](https://www.volkskrant.nl)\ -[The Economist](https://www.economist.com)\ -[Eindhovens Dagblad](https://ed.nl)\ -[Examiner](https://www.examiner.com.au)\ -[Financial Times](https://www.ft.com)\ -[Foreign Policy](https://www.foreignpolicy.com)\ -[Glassdoor](https://www.glassdoor.com)\ -[Haaretz.co.il](https://www.haaretz.co.il)\ -[Haaretz.com](https://www.haaretz.com)\ -[Handelsblatt](https://www.handelsblatt.com)\ -[Hartford Courant](https://www.courant.com)\ -[Harvard Business Review](https://www.hbr.org)\ -[Inc.com](https://www.inc.com)\ -[Investors Chronicle](https://www.investorschronicle.co.uk)\ -[La Repubblica](https://www.repubblica.it)\ -[Le Monde](https://www.lemonde.fr)\ -[Le Temps](https://www.letemps.ch)\ -[Los Angeles Times](https://www.latimes.com)\ -[Medium](https://www.medium.com)\ -[Medscape](https://www.medscape.com)\ -[MIT Technology Review](https://www.technologyreview.com)\ -[Mountain View Voice](https://www.mv-voice.com)\ -[National Post](https://www.nationalpost.com)\ -[New Statesman](https://www.newstatesman.com)\ -[New York Magazine](https://www.nymag.com)\ -[New Zealand Herald](https://www.nzherald.co.nz)\ -[Nikkei Asian Review](https://asia.nikkei.com)\ -[NRC](https://www.nrc.nl)\ -[Orange County Register](https://www.ocregister.com)\ -[Orlando Sentinel](https://www.orlandosentinel.com)\ -[Palo Alto Online](https://www.paloaltoonline.com)\ -[Parool](https://www.parool.nl)\ -[Quartz](https://qz.com)\ -[Quora](https://www.quora.com)\ -[Scientific American](https://scientificamerican.com)\ -[Statista](https://www.statista.com)\ -[SunSentinel](https://www.sun-sentinel.com)\ -[Telegraaf](https://telegraaf.nl)\ -[The Advocate](https://www.theadvocate.com.au)\ -[The Age](https://www.theage.com.au)\ -[The Atlantic](https://www.theatlantic.com)\ -[The Australian](https://www.theaustralian.com.au)\ -[The Australian Financial Review](https://www.afr.com)\ -[The Boston Globe](https://www.bostonglobe.com)\ -[The Business Journals](https://www.bizjournals.com)\ -[The Diplomat](https://www.thediplomat.com)\ -[The Globe and Mail](https://www.theglobeandmail.com)\ -[The Herald](https://www.theherald.com.au)\ -[The Japan Times](https://www.japantimes.co.jp)\ -[TheMarker](https://www.themarker.com)\ -[The Mercury News](https://www.mercurynews.com)\ -[The Morning Call](https://www.mcall.com)\ -[The Nation](https://www.thenation.com)\ -[The New York Times](https://www.nytimes.com)\ -[The New Yorker](https://www.newyorker.com)\ -[The News-Gazette](https://www.news-gazette.com)\ -[The Saturday Paper](https://www.thesaturdaypaper.com.au)\ -[The Spectator](https://www.spectator.co.uk)\ -[The Seattle Times](https://www.seattletimes.com)\ -[The Sydney Morning Herald](https://www.smh.com.au)\ -[The Telegraph](https://www.telegraph.co.uk)\ -[The Times](https://www.thetimes.co.uk)\ -[The Toronto Star](https://www.thestar.com)\ -[The Washington Post](https://www.washingtonpost.com)\ -[The Wall Street Journal](https://www.wsj.com)\ -[Towards Data Science](https://www.towardsdatascience.com)\ -[Trouw](https://www.trouw.nl)\ -[Vanity Fair](https://www.vanityfair.com)\ -[Vrij Nederland](https://www.vn.nl)\ -[Wired](https://www.wired.com) - -### Sites with limited number of free articles -The free article limit can normally be bypassed by removing cookies for the site.* - -Install the [Cookie Remover](https://addons.mozilla.org/en-US/firefox/addon/cookie-remover/) Add-on. - -When coming across a paywall click the cookie icon to remove the cookies then refresh the page. - -_*May not always succeed_ - -### New site requests -Only large or major sites will be considered. No small sites or local newspapers. -1. Visit an article on the site you want to bypass the paywall for and copy the article title. -2. Open up a new Private window (Ctrl+Shift+P) and paste the article title into Google. -3. Click on the same article from the Google search results page. If it loads without a paywall you can [submit a request](https://github.com/iamadamdev/bypass-paywalls-firefox/issues/new) to add the site, otherwise my extension cannot bypass it either. - -Usually premium articles cannot be bypassed as they are behind a hard paywall. - -### Troubleshooting -* This add-on works best alongside [uBlock Origin](https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/). -* If a site doesn't work try turning off uBlock and refreshing. - -### Pull Requesets -* PRs are welcome. - -### Show your support -* I am not asking for donations or anything like that, all I ask is that you star this repo. - -### License -Bypass Paywalls is [MIT-licensed](https://github.com/iamadamdev/bypass-paywalls-firefox/blob/master/LICENSE). +# Bypass Paywalls for Firefox + +## [Download and install the latest version](https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.6.0/bypass_paywalls-1.6.0-an+fx.xpi) + +### Bypass the following sites' paywalls with this extension + +[Algemeen Dagblad](https://www.ad.nl)\ +[Baltimore Sun](https://www.baltimoresun.com)\ +[Barron's](https://www.barrons.com)\ +[Bloomberg](https://www.bloomberg.com)\ +[Business Insider](https://www.businessinsider.com)\ +[Caixin](https://www.caixinglobal.com)\ +[Chemical & Engineering News](https://cen.acs.org)\ +[Central Western Daily](https://www.centralwesterndaily.com.au)\ +[Chicago Tribune](https://www.chicagotribune.com)\ +[Crain's Chicago Business](https://www.chicagobusiness.com)\ +[Corriere Della Sera](https://www.corriere.it)\ +[Daily Press](https://www.dailypress.com)\ +[Denver Post](https://www.denverpost.com)\ +[De Groene Amsterdammer](https://www.groene.nl)\ +[De Tijd](https://www.tijd.be)\ +[de Volkskrant](https://www.volkskrant.nl)\ +[The Economist](https://www.economist.com)\ +[Eindhovens Dagblad](https://ed.nl)\ +[Examiner](https://www.examiner.com.au)\ +[Financial Times](https://www.ft.com)\ +[Foreign Policy](https://www.foreignpolicy.com)\ +[Glassdoor](https://www.glassdoor.com)\ +[Haaretz.co.il](https://www.haaretz.co.il)\ +[Haaretz.com](https://www.haaretz.com)\ +[Handelsblatt](https://www.handelsblatt.com)\ +[Hartford Courant](https://www.courant.com)\ +[Harvard Business Review](https://www.hbr.org)\ +[Inc.com](https://www.inc.com)\ +[Investors Chronicle](https://www.investorschronicle.co.uk)\ +[La Repubblica](https://www.repubblica.it)\ +[Le Monde](https://www.lemonde.fr)\ +[Le Temps](https://www.letemps.ch)\ +[Los Angeles Times](https://www.latimes.com)\ +[Medium](https://www.medium.com)\ +[Medscape](https://www.medscape.com)\ +[MIT Technology Review](https://www.technologyreview.com)\ +[Mountain View Voice](https://www.mv-voice.com)\ +[National Post](https://www.nationalpost.com)\ +[New Statesman](https://www.newstatesman.com)\ +[New York Magazine](https://www.nymag.com)\ +[New Zealand Herald](https://www.nzherald.co.nz)\ +[Nikkei Asian Review](https://asia.nikkei.com)\ +[NRC](https://www.nrc.nl)\ +[Orange County Register](https://www.ocregister.com)\ +[Orlando Sentinel](https://www.orlandosentinel.com)\ +[Palo Alto Online](https://www.paloaltoonline.com)\ +[Parool](https://www.parool.nl)\ +[Quartz](https://qz.com)\ +[Quora](https://www.quora.com)\ +[Scientific American](https://scientificamerican.com)\ +[Statista](https://www.statista.com)\ +[SunSentinel](https://www.sun-sentinel.com)\ +[Telegraaf](https://telegraaf.nl)\ +[The Advocate](https://www.theadvocate.com.au)\ +[The Age](https://www.theage.com.au)\ +[The Atlantic](https://www.theatlantic.com)\ +[The Australian](https://www.theaustralian.com.au)\ +[The Australian Financial Review](https://www.afr.com)\ +[The Boston Globe](https://www.bostonglobe.com)\ +[The Business Journals](https://www.bizjournals.com)\ +[The Diplomat](https://www.thediplomat.com)\ +[The Globe and Mail](https://www.theglobeandmail.com)\ +[The Herald](https://www.theherald.com.au)\ +[The Japan Times](https://www.japantimes.co.jp)\ +[TheMarker](https://www.themarker.com)\ +[The Mercury News](https://www.mercurynews.com)\ +[The Morning Call](https://www.mcall.com)\ +[The Nation](https://www.thenation.com)\ +[The New York Times](https://www.nytimes.com)\ +[The New Yorker](https://www.newyorker.com)\ +[The News-Gazette](https://www.news-gazette.com)\ +[The Saturday Paper](https://www.thesaturdaypaper.com.au)\ +[The Spectator](https://www.spectator.co.uk)\ +[The Seattle Times](https://www.seattletimes.com)\ +[The Sydney Morning Herald](https://www.smh.com.au)\ +[The Telegraph](https://www.telegraph.co.uk)\ +[The Times](https://www.thetimes.co.uk)\ +[The Toronto Star](https://www.thestar.com)\ +[The Washington Post](https://www.washingtonpost.com)\ +[The Wall Street Journal](https://www.wsj.com)\ +[Towards Data Science](https://www.towardsdatascience.com)\ +[Trouw](https://www.trouw.nl)\ +[Vanity Fair](https://www.vanityfair.com)\ +[Vrij Nederland](https://www.vn.nl)\ +[Wired](https://www.wired.com) + +### Sites with limited number of free articles +The free article limit can normally be bypassed by removing cookies for the site.* + +Install the [Cookie Remover](https://addons.mozilla.org/en-US/firefox/addon/cookie-remover/) Add-on. + +When coming across a paywall click the cookie icon to remove the cookies then refresh the page. + +_*May not always succeed_ + +### New site requests +Only large or major sites will be considered. No small sites or local newspapers. +1. Visit an article on the site you want to bypass the paywall for and copy the article title. +2. Open up a new Private window (Ctrl+Shift+P) and paste the article title into Google. +3. Click on the same article from the Google search results page. If it loads without a paywall you can [submit a request](https://github.com/iamadamdev/bypass-paywalls-firefox/issues/new) to add the site, otherwise my extension cannot bypass it either. + +Usually premium articles cannot be bypassed as they are behind a hard paywall. + +### Troubleshooting +* This add-on works best alongside [uBlock Origin](https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/). +* If a site doesn't work try turning off uBlock and refreshing. + +### Pull Requesets +* PRs are welcome. + +### Show your support +* I am not asking for donations or anything like that, all I ask is that you star this repo. + +### License +Bypass Paywalls is [MIT-licensed](https://github.com/iamadamdev/bypass-paywalls-firefox/blob/master/LICENSE). diff --git a/manifest.json b/manifest.json index c56be16..f4a3718 100644 --- a/manifest.json +++ b/manifest.json @@ -1,145 +1,145 @@ -{ - "background": { - "scripts": ["background.js"] - }, - "content_scripts": [ - { - "matches": [ - "*://*.bizjournals.com/*", - "*://*.bloomberg.com/*", - "*://*.businessinsider.com/*", - "*://*.ed.nl/*", - "*://*.haaretz.co.il/*", - "*://*.lemonde.fr/*", - "*://*.nzherald.co.nz/*", - "*://*.parool.nl/*", - "*://*.repubblica.it/*", - "*://*.telegraaf.nl/*", - "*://*.trouw.nl/*", - "*://*.volkskrant.nl/*", - "*://*.washingtonpost.com/*" - ], - "js": ["contentScript.js"] - } - ], - "applications": { - "gecko": { - "id": "bypasspaywalls@bypasspaywalls.weebly.com", - "update_url": "https://raw.githubusercontent.com/iamadamdev/bypass-paywalls-firefox/master/updates.json" - } - }, - "browser_action": { - "default_popup": "popup.html", - "default_icon": { - "128": "bypass.png" - }, - "theme_icons": [ - { - "light": "bypass-dark.png", - "dark": "bypass.png", - "size": 128 - } - ] - }, - "description": "Bypass News Sites' Paywalls", - "icons": { - "128": "bypass.png" - }, - "manifest_version": 2, - "name": "Bypass Paywalls", - "short_name": "Bypass Paywall", - "options_ui": { - "page": "options.html" - }, - "permissions": [ - "cookies", - "storage", - "webRequest", - "webRequestBlocking", - "*://*.baltimoresun.com/*", - "*://*.barrons.com/*", - "*://*.bloomberg.com/*", - "*://*.businessinsider.com/*", - "*://*.caixinglobal.com/*", - "*://*.cen.acs.org/*", - "*://*.chicagotribune.com/*", - "*://*.centralwesterndaily.com.au/*", - "*://*.chicagobusiness.com/*", - "*://*.corriere.it/*", - "*://*.dailypress.com/*", - "*://*.denverpost.com/*", - "*://*.tijd.be/*", - "*://*.volkskrant.nl/*", - "*://*.economist.com/*", - "*://*.examiner.com.au/*", - "*://*.ft.com/*", - "*://*.foreignpolicy.com/*", - "*://*.glassdoor.com/*", - "*://*.haaretz.co.il/*", - "*://*.haaretz.com/*", - "*://*.handelsblatt.com/*", - "*://*.courant.com/*", - "*://*.hbr.org/*", - "*://*.inc.com/*", - "*://*.investorschronicle.co.uk/*", - "*://*.repubblica.it/*", - "*://*.letemps.ch/*", - "*://*.latimes.com/*", - "*://*.medium.com/*", - "*://*.medscape.com/*", - "*://*.technologyreview.com/*", - "*://*.mv-voice.com/*", - "*://*.nationalpost.com/*", - "*://*.newstatesman.com/*", - "*://*.nymag.com/*", - "*://*.nzherald.co.nz/*", - "*://*.asia.nikkei.com/*", - "*://*.nrc.nl/*", - "*://*.ocregister.com/*", - "*://*.orlandosentinel.com/*", - "*://*.paloaltoonline.com/*", - "*://*.quora.com/*", - "*://*.sun-sentinel.com/*", - "*://*.theadvocate.com.au/*", - "*://*.theage.com.au/*", - "*://*.theaustralian.com.au/*", - "*://*.afr.com/*", - "*://*.bostonglobe.com/*", - "*://*.bizjournals.com/*", - "*://*.theglobeandmail.com/*", - "*://*.theherald.com.au/*", - "*://*.japantimes.co.jp/*", - "*://*.themarker.com/*", - "*://*.mercurynews.com/*", - "*://*.mcall.com/*", - "*://*.thenation.com/*", - "*://*.nytimes.com/*", - "*://*.newyorker.com/*", - "*://*.news-gazette.com/*", - "*://*.thesaturdaypaper.com.au/*", - "*://*.spectator.co.uk/*", - "*://*.seattletimes.com/*", - "*://*.smh.com.au/*", - "*://*.telegraph.co.uk/*", - "*://*.thetimes.co.uk/*", - "*://*.thestar.com/*", - "*://*.washingtonpost.com/*", - "*://*.wsj.com/*", - "*://*.towardsdatascience.com/*", - "*://*.vanityfair.com/*", - "*://*.wired.com/*", - "*://*.thediplomat.com/*", - "*://*.theatlantic.com/*", - "*://*.qz.com/*", - "*://*.ad.nl/*", - "*://*.ed.nl/*", - "*://*.groene.nl/*", - "*://*.parool.nl/*", - "*://*.telegraaf.nl/*", - "*://*.trouw.nl/*", - "*://*.vn.nl/*", - "*://*.lemonde.fr/*", - "*://*.scientificamerican.com/*" - ], - "version": "1.6.0" -} +{ + "background": { + "scripts": ["background.js"] + }, + "content_scripts": [ + { + "matches": [ + "*://*.bizjournals.com/*", + "*://*.bloomberg.com/*", + "*://*.businessinsider.com/*", + "*://*.ed.nl/*", + "*://*.haaretz.co.il/*", + "*://*.lemonde.fr/*", + "*://*.nzherald.co.nz/*", + "*://*.parool.nl/*", + "*://*.repubblica.it/*", + "*://*.telegraaf.nl/*", + "*://*.trouw.nl/*", + "*://*.volkskrant.nl/*", + "*://*.washingtonpost.com/*" + ], + "js": ["contentScript.js"] + } + ], + "applications": { + "gecko": { + "id": "bypasspaywalls@bypasspaywalls.weebly.com", + "update_url": "https://raw.githubusercontent.com/iamadamdev/bypass-paywalls-firefox/master/updates.json" + } + }, + "browser_action": { + "default_popup": "popup.html", + "default_icon": { + "128": "bypass.png" + }, + "theme_icons": [ + { + "light": "bypass-dark.png", + "dark": "bypass.png", + "size": 128 + } + ] + }, + "description": "Bypass News Sites' Paywalls", + "icons": { + "128": "bypass.png" + }, + "manifest_version": 2, + "name": "Bypass Paywalls", + "short_name": "Bypass Paywall", + "options_ui": { + "page": "options.html" + }, + "permissions": [ + "cookies", + "storage", + "webRequest", + "webRequestBlocking", + "*://*.baltimoresun.com/*", + "*://*.barrons.com/*", + "*://*.bloomberg.com/*", + "*://*.businessinsider.com/*", + "*://*.caixinglobal.com/*", + "*://*.cen.acs.org/*", + "*://*.chicagotribune.com/*", + "*://*.centralwesterndaily.com.au/*", + "*://*.chicagobusiness.com/*", + "*://*.corriere.it/*", + "*://*.dailypress.com/*", + "*://*.denverpost.com/*", + "*://*.tijd.be/*", + "*://*.volkskrant.nl/*", + "*://*.economist.com/*", + "*://*.examiner.com.au/*", + "*://*.ft.com/*", + "*://*.foreignpolicy.com/*", + "*://*.glassdoor.com/*", + "*://*.haaretz.co.il/*", + "*://*.haaretz.com/*", + "*://*.handelsblatt.com/*", + "*://*.courant.com/*", + "*://*.hbr.org/*", + "*://*.inc.com/*", + "*://*.investorschronicle.co.uk/*", + "*://*.repubblica.it/*", + "*://*.letemps.ch/*", + "*://*.latimes.com/*", + "*://*.medium.com/*", + "*://*.medscape.com/*", + "*://*.technologyreview.com/*", + "*://*.mv-voice.com/*", + "*://*.nationalpost.com/*", + "*://*.newstatesman.com/*", + "*://*.nymag.com/*", + "*://*.nzherald.co.nz/*", + "*://*.asia.nikkei.com/*", + "*://*.nrc.nl/*", + "*://*.ocregister.com/*", + "*://*.orlandosentinel.com/*", + "*://*.paloaltoonline.com/*", + "*://*.quora.com/*", + "*://*.sun-sentinel.com/*", + "*://*.theadvocate.com.au/*", + "*://*.theage.com.au/*", + "*://*.theaustralian.com.au/*", + "*://*.afr.com/*", + "*://*.bostonglobe.com/*", + "*://*.bizjournals.com/*", + "*://*.theglobeandmail.com/*", + "*://*.theherald.com.au/*", + "*://*.japantimes.co.jp/*", + "*://*.themarker.com/*", + "*://*.mercurynews.com/*", + "*://*.mcall.com/*", + "*://*.thenation.com/*", + "*://*.nytimes.com/*", + "*://*.newyorker.com/*", + "*://*.news-gazette.com/*", + "*://*.thesaturdaypaper.com.au/*", + "*://*.spectator.co.uk/*", + "*://*.seattletimes.com/*", + "*://*.smh.com.au/*", + "*://*.telegraph.co.uk/*", + "*://*.thetimes.co.uk/*", + "*://*.thestar.com/*", + "*://*.washingtonpost.com/*", + "*://*.wsj.com/*", + "*://*.towardsdatascience.com/*", + "*://*.vanityfair.com/*", + "*://*.wired.com/*", + "*://*.thediplomat.com/*", + "*://*.theatlantic.com/*", + "*://*.qz.com/*", + "*://*.ad.nl/*", + "*://*.ed.nl/*", + "*://*.groene.nl/*", + "*://*.parool.nl/*", + "*://*.telegraaf.nl/*", + "*://*.trouw.nl/*", + "*://*.vn.nl/*", + "*://*.lemonde.fr/*", + "*://*.scientificamerican.com/*" + ], + "version": "1.6.0" +} diff --git a/options.js b/options.js index a68eaa8..4aa1b1e 100644 --- a/options.js +++ b/options.js @@ -1,161 +1,161 @@ -var defaultSites = { - 'Algemeen Dagblad': 'ad.nl', - 'Baltimore Sun': 'baltimoresun.com', - 'Barron\'s': 'barrons.com', - 'Bloomberg': 'bloomberg.com', - 'Business Insider': 'businessinsider.com', - 'Caixin': 'caixinglobal.com', - 'Chemical & Engineering News': 'cen.acs.org', - 'Chicago Tribune': 'chicagotribune.com', - 'Central Western Daily': 'centralwesterndaily.com.au', - 'Crain\'s Chicago Business': 'chicagobusiness.com', - 'Corriere Della Sera': 'corriere.it', - 'Daily Press': 'dailypress.com', - 'Denver Post': 'denverpost.com', - 'De Groene Amsterdammer': 'groene.nl', - 'De Tijd': 'tijd.be', - 'de Volkskrant': 'volkskrant.nl', - 'The Economist (javascript disabled)': 'economist.com', - 'Eindhovens Dagblad': 'ed.nl', - 'Examiner': 'examiner.com.au', - 'Financial Times': 'ft.com', - 'Foreign Policy': 'foreignpolicy.com', - 'Glassdoor': 'glassdoor.com', - 'Haaretz': 'haaretz.co.il', - 'Haaretz English': 'haaretz.com', - 'Handelsblatt': 'handelsblatt.com', - 'Hartford Courant': 'courant.com', - 'Harvard Business Review': 'hbr.org', - 'Inc.com': 'inc.com', - 'Investors Chronicle': 'investorschronicle.co.uk', - 'La Repubblica': 'repubblica.it', - 'Le Monde': 'lemonde.fr', - 'Le Temps': 'letemps.ch', - 'Los Angeles Times': 'latimes.com', - 'Medium': 'medium.com', - 'Medscape': 'medscape.com', - 'MIT Technology Review': 'technologyreview.com', - 'Mountain View Voice': 'mv-voice.com', - 'National Post': 'nationalpost.com', - 'New Statesman (javascript disabled)': 'newstatesman.com', - 'New York Magazine': 'nymag.com', - 'New Zealand Herald': 'nzherald.co.nz', - 'Nikkei Asian Review': 'asia.nikkei.com', - 'NRC': 'nrc.nl', - 'Orange County Register': 'ocregister.com', - 'Orlando Sentinel': 'orlandosentinel.com', - 'Palo Alto Online': 'paloaltoonline.com', - 'Parool': 'parool.nl', - 'Quartz': 'qz.com', - 'Quora': 'quora.com', - 'Scientific American': 'scientificamerican.com', - 'Statista': 'statista.com', - 'SunSentinel': 'sun-sentinel.com', - 'Telegraaf': 'telegraaf.nl', - 'The Advocate': 'theadvocate.com.au', - 'The Age': 'theage.com.au', - 'The Atlantic': 'theatlantic.com', - 'The Australian': 'theaustralian.com.au', - 'The Australian Financial Review (javascript disabled)': 'afr.com', - 'The Boston Globe (javascript disabled)': 'bostonglobe.com', - 'The Business Journals': 'bizjournals.com', - 'The Diplomat': 'thediplomat.com', - 'The Globe and Mail (javascript disabled)': 'theglobeandmail.com', - 'The Herald': 'theherald.com.au', - 'The Japan Times': 'japantimes.co.jp', - 'TheMarker': 'themarker.com', - 'The Mercury News': 'mercurynews.com', - 'The Morning Call': 'mcall.com', - 'The Nation': 'thenation.com', - 'The New York Times': 'nytimes.com', - 'The New Yorker': 'newyorker.com', - 'The News-Gazette': 'news-gazette.com', - 'The Saturday Paper': 'thesaturdaypaper.com.au', - 'The Spectator': 'spectator.co.uk', - 'The Seattle Times': 'seattletimes.com', - 'The Sydney Morning Herald': 'smh.com.au', - 'The Telegraph': 'telegraph.co.uk', - 'The Times': 'thetimes.co.uk', - 'The Toronto Star (javascript disabled)': 'thestar.com', - 'The Washington Post': 'washingtonpost.com', - 'The Wall Street Journal': 'wsj.com', - 'Towards Data Science': 'towardsdatascience.com', - 'Trouw': 'trouw.nl', - 'Vanity Fair': 'vanityfair.com', - 'Vrij Nederland': 'vn.nl', - 'Wired': 'wired.com' -}; - -// Saves options to browser.storage -function save_options() { - var gh_url = document.getElementById('bypass_sites').value; - var inputEls = document.querySelectorAll('#bypass_sites input'); - var sites = {}; - - var sites = Array.from(inputEls).reduce(function(memo, inputEl) { - if (inputEl.checked) { - memo[inputEl.dataset.key] = inputEl.dataset.value; - } - return memo; - }, {}); - - browser.storage.sync.set({ - sites: sites - }, function() { - // Update status to let user know options were saved. - var status = document.getElementById('status'); - status.textContent = 'Options saved.'; - setTimeout(function() { - // status.textContent = ''; - window.close(); - }, 500); - }); -} - -// Restores checkbox input states using the preferences -// stored in browser.storage. -function renderOptions() { - browser.storage.sync.get({ - sites: {} - }, function(items) { - var sites = items.sites; - var sitesEl = document.getElementById('bypass_sites'); - for (var key in defaultSites) { - if (!defaultSites.hasOwnProperty(key)) { - continue; - } - - var value = defaultSites[key]; - var labelEl = document.createElement('label'); - var inputEl = document.createElement('input'); - inputEl.type = 'checkbox'; - inputEl.dataset.key = key; - inputEl.dataset.value = value; - inputEl.checked = key in sites; - - labelEl.appendChild(inputEl); - labelEl.appendChild(document.createTextNode(' '+key)); - sitesEl.appendChild(labelEl); - } - }); -} - -function selectAll() { - var inputEls = Array.from(document.querySelectorAll('input')); - inputEls.forEach(function(inputEl) { - inputEl.checked = true; - }); -} - -function selectNone() { - var inputEls = Array.from(document.querySelectorAll('input')); - inputEls.forEach(function(inputEl) { - inputEl.checked = false; - }); -} - -document.addEventListener('DOMContentLoaded', renderOptions); -document.getElementById('save').addEventListener('click', save_options); -document.getElementById('select-all').addEventListener('click', selectAll); -document.getElementById('select-none').addEventListener('click', selectNone); - +var defaultSites = { + 'Algemeen Dagblad': 'ad.nl', + 'Baltimore Sun': 'baltimoresun.com', + 'Barron\'s': 'barrons.com', + 'Bloomberg': 'bloomberg.com', + 'Business Insider': 'businessinsider.com', + 'Caixin': 'caixinglobal.com', + 'Chemical & Engineering News': 'cen.acs.org', + 'Chicago Tribune': 'chicagotribune.com', + 'Central Western Daily': 'centralwesterndaily.com.au', + 'Crain\'s Chicago Business': 'chicagobusiness.com', + 'Corriere Della Sera': 'corriere.it', + 'Daily Press': 'dailypress.com', + 'Denver Post': 'denverpost.com', + 'De Groene Amsterdammer': 'groene.nl', + 'De Tijd': 'tijd.be', + 'de Volkskrant': 'volkskrant.nl', + 'The Economist (javascript disabled)': 'economist.com', + 'Eindhovens Dagblad': 'ed.nl', + 'Examiner': 'examiner.com.au', + 'Financial Times': 'ft.com', + 'Foreign Policy': 'foreignpolicy.com', + 'Glassdoor': 'glassdoor.com', + 'Haaretz': 'haaretz.co.il', + 'Haaretz English': 'haaretz.com', + 'Handelsblatt': 'handelsblatt.com', + 'Hartford Courant': 'courant.com', + 'Harvard Business Review': 'hbr.org', + 'Inc.com': 'inc.com', + 'Investors Chronicle': 'investorschronicle.co.uk', + 'La Repubblica': 'repubblica.it', + 'Le Monde': 'lemonde.fr', + 'Le Temps': 'letemps.ch', + 'Los Angeles Times': 'latimes.com', + 'Medium': 'medium.com', + 'Medscape': 'medscape.com', + 'MIT Technology Review': 'technologyreview.com', + 'Mountain View Voice': 'mv-voice.com', + 'National Post': 'nationalpost.com', + 'New Statesman (javascript disabled)': 'newstatesman.com', + 'New York Magazine': 'nymag.com', + 'New Zealand Herald': 'nzherald.co.nz', + 'Nikkei Asian Review': 'asia.nikkei.com', + 'NRC': 'nrc.nl', + 'Orange County Register': 'ocregister.com', + 'Orlando Sentinel': 'orlandosentinel.com', + 'Palo Alto Online': 'paloaltoonline.com', + 'Parool': 'parool.nl', + 'Quartz': 'qz.com', + 'Quora': 'quora.com', + 'Scientific American': 'scientificamerican.com', + 'Statista': 'statista.com', + 'SunSentinel': 'sun-sentinel.com', + 'Telegraaf': 'telegraaf.nl', + 'The Advocate': 'theadvocate.com.au', + 'The Age': 'theage.com.au', + 'The Atlantic': 'theatlantic.com', + 'The Australian': 'theaustralian.com.au', + 'The Australian Financial Review (javascript disabled)': 'afr.com', + 'The Boston Globe (javascript disabled)': 'bostonglobe.com', + 'The Business Journals': 'bizjournals.com', + 'The Diplomat': 'thediplomat.com', + 'The Globe and Mail (javascript disabled)': 'theglobeandmail.com', + 'The Herald': 'theherald.com.au', + 'The Japan Times': 'japantimes.co.jp', + 'TheMarker': 'themarker.com', + 'The Mercury News': 'mercurynews.com', + 'The Morning Call': 'mcall.com', + 'The Nation': 'thenation.com', + 'The New York Times': 'nytimes.com', + 'The New Yorker': 'newyorker.com', + 'The News-Gazette': 'news-gazette.com', + 'The Saturday Paper': 'thesaturdaypaper.com.au', + 'The Spectator': 'spectator.co.uk', + 'The Seattle Times': 'seattletimes.com', + 'The Sydney Morning Herald': 'smh.com.au', + 'The Telegraph': 'telegraph.co.uk', + 'The Times': 'thetimes.co.uk', + 'The Toronto Star (javascript disabled)': 'thestar.com', + 'The Washington Post': 'washingtonpost.com', + 'The Wall Street Journal': 'wsj.com', + 'Towards Data Science': 'towardsdatascience.com', + 'Trouw': 'trouw.nl', + 'Vanity Fair': 'vanityfair.com', + 'Vrij Nederland': 'vn.nl', + 'Wired': 'wired.com' +}; + +// Saves options to browser.storage +function save_options() { + var gh_url = document.getElementById('bypass_sites').value; + var inputEls = document.querySelectorAll('#bypass_sites input'); + var sites = {}; + + var sites = Array.from(inputEls).reduce(function(memo, inputEl) { + if (inputEl.checked) { + memo[inputEl.dataset.key] = inputEl.dataset.value; + } + return memo; + }, {}); + + browser.storage.sync.set({ + sites: sites + }, function() { + // Update status to let user know options were saved. + var status = document.getElementById('status'); + status.textContent = 'Options saved.'; + setTimeout(function() { + // status.textContent = ''; + window.close(); + }, 500); + }); +} + +// Restores checkbox input states using the preferences +// stored in browser.storage. +function renderOptions() { + browser.storage.sync.get({ + sites: {} + }, function(items) { + var sites = items.sites; + var sitesEl = document.getElementById('bypass_sites'); + for (var key in defaultSites) { + if (!defaultSites.hasOwnProperty(key)) { + continue; + } + + var value = defaultSites[key]; + var labelEl = document.createElement('label'); + var inputEl = document.createElement('input'); + inputEl.type = 'checkbox'; + inputEl.dataset.key = key; + inputEl.dataset.value = value; + inputEl.checked = key in sites; + + labelEl.appendChild(inputEl); + labelEl.appendChild(document.createTextNode(' '+key)); + sitesEl.appendChild(labelEl); + } + }); +} + +function selectAll() { + var inputEls = Array.from(document.querySelectorAll('input')); + inputEls.forEach(function(inputEl) { + inputEl.checked = true; + }); +} + +function selectNone() { + var inputEls = Array.from(document.querySelectorAll('input')); + inputEls.forEach(function(inputEl) { + inputEl.checked = false; + }); +} + +document.addEventListener('DOMContentLoaded', renderOptions); +document.getElementById('save').addEventListener('click', save_options); +document.getElementById('select-all').addEventListener('click', selectAll); +document.getElementById('select-none').addEventListener('click', selectNone); + From d2821596352cc2bcf7e5bc94a3ef8672a5583630 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Sat, 2 Nov 2019 12:07:01 +0100 Subject: [PATCH 09/32] Fix Le Monde support (now all paragraphs) --- background.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index a9bf7a4..ea56b40 100644 --- a/background.js +++ b/background.js @@ -31,7 +31,7 @@ var defaultSites = { 'Inc.com': 'inc.com', 'Investors Chronicle': 'investorschronicle.co.uk', 'La Repubblica': 'repubblica.it', - 'Le Monde': 'lemonde.fr', + 'Le Monde': 'lemonde.fr', 'Le Temps': 'letemps.ch', 'Los Angeles Times': 'latimes.com', 'Medium': 'medium.com', @@ -182,6 +182,7 @@ const remove_cookies_select_drop = { // Override User-Agent with Googlebot const use_google_bot = [ 'barrons.com', +'lemonde.fr', 'nytimes.com', 'quora.com', 'telegraph.co.uk', From d6705e843825a38f292a3498944ea2874db99fc9 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Sat, 2 Nov 2019 12:20:28 +0100 Subject: [PATCH 10/32] Add TheHindu --- README.md | 1 + background.js | 1 + manifest.json | 3 ++- options.js | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f62669b..d1aae55 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ [The Diplomat](https://www.thediplomat.com)\ [The Globe and Mail](https://www.theglobeandmail.com)\ [The Herald](https://www.theherald.com.au)\ +[The Hindu](https://www.thehindu.com)\ [The Japan Times](https://www.japantimes.co.jp)\ [TheMarker](https://www.themarker.com)\ [The Mercury News](https://www.mercurynews.com)\ diff --git a/background.js b/background.js index ea56b40..3295e05 100644 --- a/background.js +++ b/background.js @@ -64,6 +64,7 @@ var defaultSites = { 'The Diplomat': 'thediplomat.com', 'The Globe and Mail': 'theglobeandmail.com', 'The Herald': 'theherald.com.au', + 'The Hindu': 'thehindu.com', 'The Japan Times': 'japantimes.co.jp', 'TheMarker': 'themarker.com', 'The Mercury News': 'mercurynews.com', diff --git a/manifest.json b/manifest.json index f4a3718..c3b085a 100644 --- a/manifest.json +++ b/manifest.json @@ -139,7 +139,8 @@ "*://*.trouw.nl/*", "*://*.vn.nl/*", "*://*.lemonde.fr/*", - "*://*.scientificamerican.com/*" + "*://*.scientificamerican.com/*", + "*://*.thehindu.com/*" ], "version": "1.6.0" } diff --git a/options.js b/options.js index 4aa1b1e..1b55e0f 100644 --- a/options.js +++ b/options.js @@ -62,6 +62,7 @@ var defaultSites = { 'The Diplomat': 'thediplomat.com', 'The Globe and Mail (javascript disabled)': 'theglobeandmail.com', 'The Herald': 'theherald.com.au', + 'The Hindu': 'thehindu.com', 'The Japan Times': 'japantimes.co.jp', 'TheMarker': 'themarker.com', 'The Mercury News': 'mercurynews.com', From d9414b063ca16298c7e1574b06cea3a22a096404 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Tue, 5 Nov 2019 13:55:17 +0100 Subject: [PATCH 11/32] Fix default websites not checked in options Default websites with postfix like ' (javascript disabled) are not checked in options because mismatch in key. New filter to disregard any space + text in parentheses (options.js). --- options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options.js b/options.js index 1b55e0f..136da36 100644 --- a/options.js +++ b/options.js @@ -132,7 +132,7 @@ function renderOptions() { inputEl.type = 'checkbox'; inputEl.dataset.key = key; inputEl.dataset.value = value; - inputEl.checked = key in sites; + inputEl.checked = key.replace(/\s\(.*\)/, '') in sites; labelEl.appendChild(inputEl); labelEl.appendChild(document.createTextNode(' '+key)); From c95becae3468c5c50e4602c8762e6bc483b6383d Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Tue, 5 Nov 2019 18:13:46 +0100 Subject: [PATCH 12/32] Fix default websites not checked in options (part 2) Now both for new install and update of options. --- options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options.js b/options.js index 136da36..d912f21 100644 --- a/options.js +++ b/options.js @@ -132,7 +132,7 @@ function renderOptions() { inputEl.type = 'checkbox'; inputEl.dataset.key = key; inputEl.dataset.value = value; - inputEl.checked = key.replace(/\s\(.*\)/, '') in sites; + inputEl.checked = (key in sites) || (key.replace(/\s\(.*\)/, '') in sites); labelEl.appendChild(inputEl); labelEl.appendChild(document.createTextNode(' '+key)); From f3a7c92e9db63c45095a537dfa20841279808446 Mon Sep 17 00:00:00 2001 From: alastairR Date: Wed, 6 Nov 2019 10:37:32 +1300 Subject: [PATCH 13/32] Update contentScript.js Simplify NZ Herald class changes --- contentScript.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/contentScript.js b/contentScript.js index bbbc6f8..b15b90c 100644 --- a/contentScript.js +++ b/contentScript.js @@ -37,18 +37,9 @@ if (window.location.href.indexOf("bizjournals.com") !== -1) { paywall.classList.remove('premium-content'); paywall.classList.add('full-content'); var paras = paywall.querySelectorAll("p, span, h2, div"); - var delClass = ""; - for (var i = 0; i < paras.length; i++) { - if (paras[i].nodeName == 'P' || paras[i].nodeName == 'SPAN') { - paras[i].classList.remove("ellipsis"); - if (delClass == "" && paras[i].className != "") { - delClass = paras[i].className; - } else { - if (delClass != "") { - paras[i].classList.remove(delClass); - } - } - } + for (var i = paras.length -1; i > -1; i--) { + removeClassesByPrefix(paras[i], 'QUnW'); + paras[i].classList.remove("ellipsis"); paras[i].removeAttribute('style'); } } @@ -151,3 +142,10 @@ function removeDOMElement(...elements) { } } +function removeClassesByPrefix(el, prefix) { + for(var i = el.classList.length - 1; i >= 0; i--) { + if(el.classList[i].startsWith(prefix)) { + el.classList.remove(el.classList[i]); + } + } +} From 52590cd578059afe53f92bb6742bfb462dd1a14a Mon Sep 17 00:00:00 2001 From: alastairR Date: Wed, 6 Nov 2019 12:40:18 +1300 Subject: [PATCH 14/32] Update contentScript.js Missed parent div class --- contentScript.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contentScript.js b/contentScript.js index b15b90c..4cca61b 100644 --- a/contentScript.js +++ b/contentScript.js @@ -36,6 +36,7 @@ if (window.location.href.indexOf("bizjournals.com") !== -1) { if (paywall) { paywall.classList.remove('premium-content'); paywall.classList.add('full-content'); + removeClassesByPrefix(paywall, 'QUnW'); var paras = paywall.querySelectorAll("p, span, h2, div"); for (var i = paras.length -1; i > -1; i--) { removeClassesByPrefix(paras[i], 'QUnW'); @@ -142,7 +143,8 @@ function removeDOMElement(...elements) { } } -function removeClassesByPrefix(el, prefix) { +function removeClassesByPrefix(el, prefix) +{ for(var i = el.classList.length - 1; i >= 0; i--) { if(el.classList[i].startsWith(prefix)) { el.classList.remove(el.classList[i]); From 0555ab6fe5938fd094476fae13698dd6e215bdde Mon Sep 17 00:00:00 2001 From: alastairR Date: Wed, 6 Nov 2019 12:54:01 +1300 Subject: [PATCH 15/32] Update contentScript.js Remove link to premium popup --- contentScript.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contentScript.js b/contentScript.js index 4cca61b..0b5c267 100644 --- a/contentScript.js +++ b/contentScript.js @@ -34,6 +34,8 @@ if (window.location.href.indexOf("bizjournals.com") !== -1) { "article-content" ); if (paywall) { + const premium = document.getElementByClass('premium-sub'); + removeDOMElement(premium); paywall.classList.remove('premium-content'); paywall.classList.add('full-content'); removeClassesByPrefix(paywall, 'QUnW'); From 673af472f2a893e06531cb556ebb0c3a2e63a155 Mon Sep 17 00:00:00 2001 From: alastairR Date: Wed, 6 Nov 2019 13:12:21 +1300 Subject: [PATCH 16/32] Update contentScript.js Reverse removal of DOM element containing link to subscription popup because it stopped module working --- contentScript.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/contentScript.js b/contentScript.js index 0b5c267..4cca61b 100644 --- a/contentScript.js +++ b/contentScript.js @@ -34,8 +34,6 @@ if (window.location.href.indexOf("bizjournals.com") !== -1) { "article-content" ); if (paywall) { - const premium = document.getElementByClass('premium-sub'); - removeDOMElement(premium); paywall.classList.remove('premium-content'); paywall.classList.add('full-content'); removeClassesByPrefix(paywall, 'QUnW'); From 98d97f593d79192cd87fb74ee612929a5373b169 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Fri, 8 Nov 2019 23:26:06 +0100 Subject: [PATCH 17/32] Fix Bloomberg bot-alert A captcha popped up (earlier fixed for Chrome). --- contentScript.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contentScript.js b/contentScript.js index bbbc6f8..17e9c30 100644 --- a/contentScript.js +++ b/contentScript.js @@ -100,8 +100,10 @@ if (window.location.href.indexOf("bizjournals.com") !== -1) { } if (window.location.href.indexOf("bloomberg.com") !== -1) { - const paywall = document.getElementById('paywall-banner'); - removeDOMElement(paywall); + document.addEventListener('DOMContentLoaded', () => { + const paywall = document.getElementById('paywall-banner'); + removeDOMElement(paywall); + }); } if (window.location.href.indexOf('telegraaf.nl') !== -1) { From 41018773c6a602b95830ddb4f6fd06cebb9c5cc1 Mon Sep 17 00:00:00 2001 From: Adam <36013816+iamadamdev@users.noreply.github.com> Date: Sun, 10 Nov 2019 11:39:03 -0800 Subject: [PATCH 18/32] Add space between if ( --- contentScript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentScript.js b/contentScript.js index 502439b..a43b997 100644 --- a/contentScript.js +++ b/contentScript.js @@ -103,7 +103,7 @@ if (window.location.href.indexOf("medium.com") !== -1) { const bottomMessageText = 'Get one more story in your member preview when you sign up. It’s free.'; const DOMElementsToTextDiv = pageContains('div', bottomMessageText); - if(DOMElementsToTextDiv[2]) removeDOMElement(DOMElementsToTextDiv[2]); + if (DOMElementsToTextDiv[2]) removeDOMElement(DOMElementsToTextDiv[2]); } if (window.location.href.indexOf("bloombergquint.com") !== -1) { From f21f0fcdc8afcc6b7ac8007faa60b5df06ac146f Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Mon, 11 Nov 2019 21:52:03 +0100 Subject: [PATCH 19/32] Typo Bloomberg Quint --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 320ed96..a2f5043 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [Baltimore Sun](https://www.baltimoresun.com)\ [Barron's](https://www.barrons.com)\ [Bloomberg](https://www.bloomberg.com)\ -[Bloomberg Quint]('https://www.bloombergquint.com)\ +[Bloomberg Quint](https://www.bloombergquint.com)\ [Business Insider](https://www.businessinsider.com)\ [Caixin](https://www.caixinglobal.com)\ [Chemical & Engineering News](https://cen.acs.org)\ From 33ac5631330adda0a622cff11bb1f97684adab74 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Mon, 11 Nov 2019 22:11:48 +0100 Subject: [PATCH 20/32] Fix NYTimes subscription form --- contentScript.js | 7 +++++++ manifest.json | 1 + 2 files changed, 8 insertions(+) diff --git a/contentScript.js b/contentScript.js index 83ccfbb..7bb832a 100644 --- a/contentScript.js +++ b/contentScript.js @@ -160,6 +160,13 @@ if (window.location.href.indexOf('lemonde.fr') !== -1) { }); } +if (window.location.href.indexOf("nytimes.com") !== -1) { + + const preview_button = document.querySelector('.css-3s1ce0'); + if (preview_button) + preview_button.click(); +} + function removeDOMElement(...elements) { for (let element of elements) { if (element) element.remove(); diff --git a/manifest.json b/manifest.json index c3b085a..2281e85 100644 --- a/manifest.json +++ b/manifest.json @@ -11,6 +11,7 @@ "*://*.ed.nl/*", "*://*.haaretz.co.il/*", "*://*.lemonde.fr/*", + "*://*.nytimes.com/*", "*://*.nzherald.co.nz/*", "*://*.parool.nl/*", "*://*.repubblica.it/*", From f82b1c05641b5c22dc29ba8ad8a159adc89a17e5 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Mon, 11 Nov 2019 23:19:57 +0100 Subject: [PATCH 21/32] Fix Caixin Global --- contentScript.js | 11 ++++++++++- manifest.json | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/contentScript.js b/contentScript.js index 7bb832a..89526db 100644 --- a/contentScript.js +++ b/contentScript.js @@ -161,12 +161,21 @@ if (window.location.href.indexOf('lemonde.fr') !== -1) { } if (window.location.href.indexOf("nytimes.com") !== -1) { - const preview_button = document.querySelector('.css-3s1ce0'); if (preview_button) preview_button.click(); } +if (window.location.href.indexOf("caixinglobal.com") !== -1) { + const appContent = document.getElementById('appContent'); + if (appContent) { + const p_hidden = document.querySelectorAll('p:not([style="display:block;"]'); + for (var i = 0; i < p_hidden.length; i++) { + p_hidden[i].setAttribute('style', 'display:block;'); + } + } +} + function removeDOMElement(...elements) { for (let element of elements) { if (element) element.remove(); diff --git a/manifest.json b/manifest.json index 2281e85..6ab2933 100644 --- a/manifest.json +++ b/manifest.json @@ -8,6 +8,7 @@ "*://*.bizjournals.com/*", "*://*.bloomberg.com/*", "*://*.businessinsider.com/*", + "*://*.caixinglobal.com/*", "*://*.ed.nl/*", "*://*.haaretz.co.il/*", "*://*.lemonde.fr/*", From 191377482d07ff6ff98bbd1249322a0306895667 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Wed, 13 Nov 2019 12:35:23 +0100 Subject: [PATCH 22/32] Fix The Atlantic (cookie) --- background.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/background.js b/background.js index c747260..177f3ab 100644 --- a/background.js +++ b/background.js @@ -123,6 +123,7 @@ const allow_cookies = [ 'telegraaf.nl', 'theadvocate.com.au', 'theage.com.au', +'theatlantic.com', 'theaustralian.com.au', 'thediplomat.com', 'thestar.com', @@ -161,6 +162,7 @@ const remove_cookies = [ 'telegraaf.nl', 'theadvocate.com.au', 'theage.com.au', +'theatlantic.com', 'thediplomat.com', 'thestar.com', 'towardsdatascience.com', From dcb86b90ea86a42f14cf5c9282e9f5fd2d8881cc Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Wed, 13 Nov 2019 13:12:24 +0100 Subject: [PATCH 23/32] Fix Telegraaf.nl (timing issue) Fix for persistent refreshing at paywall-banner. --- contentScript.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contentScript.js b/contentScript.js index 89526db..556ffa1 100644 --- a/contentScript.js +++ b/contentScript.js @@ -120,10 +120,12 @@ if (window.location.href.indexOf("bloomberg.com") !== -1) { } if (window.location.href.indexOf('telegraaf.nl') !== -1) { - const paywall = document.getElementById('TEMPRORARY_METERING_ID'); - if (paywall) { - window.location.reload(1); - } + setTimeout(function () { + const paywall = document.getElementById('TEMPRORARY_METERING_ID'); + if (paywall) { + window.location.reload(true); + } + }, 500); // Delay (in milliseconds) } if (window.location.href.indexOf('ed.nl') !== -1) { From 5e54e795d35e0afa53d7424ddfab87e3e58570cc Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Thu, 14 Nov 2019 12:22:48 +0100 Subject: [PATCH 24/32] Fix Bloomberg Fixes issue https://github.com/iamadamdev/bypass-paywalls-chrome/issues/399 --- contentScript.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contentScript.js b/contentScript.js index 556ffa1..5312c80 100644 --- a/contentScript.js +++ b/contentScript.js @@ -114,6 +114,9 @@ if (window.location.href.indexOf("bloombergquint.com") !== -1) { if (window.location.href.indexOf("bloomberg.com") !== -1) { document.addEventListener('DOMContentLoaded', () => { + const fence = document.querySelector('.fence-body'); + if (fence) + fence.classList.remove('fence-body'); const paywall = document.getElementById('paywall-banner'); removeDOMElement(paywall); }); From d66554ddf353a8645b551e269d18853ca76f0c26 Mon Sep 17 00:00:00 2001 From: alastairR Date: Fri, 15 Nov 2019 10:11:39 +1300 Subject: [PATCH 25/32] Fix var definitions Co-Authored-By: Tom <41207070+cimke@users.noreply.github.com> --- contentScript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentScript.js b/contentScript.js index 57c4a63..9f49406 100644 --- a/contentScript.js +++ b/contentScript.js @@ -37,7 +37,7 @@ if (window.location.href.indexOf("bizjournals.com") !== -1) { paywall.classList.remove('premium-content'); paywall.classList.add('full-content'); removeClassesByPrefix(paywall, 'QUnW'); - var paras = paywall.querySelectorAll("p, span, h2, div"); + let paras = paywall.querySelectorAll("p, span, h2, div"); for (var i = paras.length -1; i > -1; i--) { removeClassesByPrefix(paras[i], 'QUnW'); paras[i].classList.remove("ellipsis"); From 1c78592dc242aed78bdcd407101e629ba6d7fe77 Mon Sep 17 00:00:00 2001 From: alastairR Date: Fri, 15 Nov 2019 10:11:55 +1300 Subject: [PATCH 26/32] Fix var definitions Co-Authored-By: Tom <41207070+cimke@users.noreply.github.com> --- contentScript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentScript.js b/contentScript.js index 9f49406..1a11402 100644 --- a/contentScript.js +++ b/contentScript.js @@ -38,7 +38,7 @@ if (window.location.href.indexOf("bizjournals.com") !== -1) { paywall.classList.add('full-content'); removeClassesByPrefix(paywall, 'QUnW'); let paras = paywall.querySelectorAll("p, span, h2, div"); - for (var i = paras.length -1; i > -1; i--) { + for (let i = paras.length - 1; i > -1; i--) { removeClassesByPrefix(paras[i], 'QUnW'); paras[i].classList.remove("ellipsis"); paras[i].removeAttribute('style'); From 0f284b51e9a6fea2a6f091cd6b4fba2509ca5fa3 Mon Sep 17 00:00:00 2001 From: alastairR Date: Fri, 15 Nov 2019 10:12:54 +1300 Subject: [PATCH 27/32] Fix var definitions Co-Authored-By: Tom <41207070+cimke@users.noreply.github.com> --- contentScript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentScript.js b/contentScript.js index 1a11402..b7f73e4 100644 --- a/contentScript.js +++ b/contentScript.js @@ -160,7 +160,7 @@ function removeDOMElement(...elements) { function removeClassesByPrefix(el, prefix) { - for(var i = el.classList.length - 1; i >= 0; i--) { + for (let i = el.classList.length - 1; i >= 0; i--) { if(el.classList[i].startsWith(prefix)) { el.classList.remove(el.classList[i]); } From 9e43913e6481dddd7a176987a4334ad91b50195e Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Sat, 16 Nov 2019 22:57:23 +0100 Subject: [PATCH 28/32] Fix Ad.nl/Ed.nl (cookie) Fix for new cookie-scheme (drop specific cookie). --- background.js | 6 ++++++ contentScript.js | 14 ++++++-------- manifest.json | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/background.js b/background.js index 177f3ab..4e99b39 100644 --- a/background.js +++ b/background.js @@ -181,6 +181,12 @@ const remove_cookies_select_hold = { // select only specific cookie(s) to drop from remove_cookies domains const remove_cookies_select_drop = { + '.ad.nl': ['temptationTrackingId'], + '.www.ad.nl': ['none'], + 'www.ad.nl': ['none'], + '.ed.nl': ['temptationTrackingId'], + '.www.ed.nl': ['none'], + 'www.ed.nl': ['none'], 'www.nrc.nl': ['counter'] } diff --git a/contentScript.js b/contentScript.js index 5312c80..168111a 100644 --- a/contentScript.js +++ b/contentScript.js @@ -115,8 +115,9 @@ if (window.location.href.indexOf("bloombergquint.com") !== -1) { if (window.location.href.indexOf("bloomberg.com") !== -1) { document.addEventListener('DOMContentLoaded', () => { const fence = document.querySelector('.fence-body'); - if (fence) + if (fence){ fence.classList.remove('fence-body'); + } const paywall = document.getElementById('paywall-banner'); removeDOMElement(paywall); }); @@ -128,15 +129,12 @@ if (window.location.href.indexOf('telegraaf.nl') !== -1) { if (paywall) { window.location.reload(true); } - }, 500); // Delay (in milliseconds) + }, 1000); // Delay (in milliseconds) } -if (window.location.href.indexOf('ed.nl') !== -1) { - const paywall = document.querySelector('.article__component.article__component--paywall-module-notification'); - if (paywall) { - paywall.remove(); - paywall = null; - } +if (window.location.href.indexOf('ad.nl') !== -1 || window.location.href.indexOf('ed.nl') !== -1) { + let paywall = document.querySelector('.article__component.article__component--paywall-module-notification'); + removeDOMElement(paywall); } if (window.location.href.indexOf("parool.nl") !== -1 || window.location.href.indexOf("trouw.nl") !== -1 || window.location.href.indexOf("volkskrant.nl") !== -1) { diff --git a/manifest.json b/manifest.json index 6ab2933..3b3cd6d 100644 --- a/manifest.json +++ b/manifest.json @@ -9,6 +9,7 @@ "*://*.bloomberg.com/*", "*://*.businessinsider.com/*", "*://*.caixinglobal.com/*", + "*://*.ad.nl/*", "*://*.ed.nl/*", "*://*.haaretz.co.il/*", "*://*.lemonde.fr/*", From cbdcbe81f524646302e60e40931e592dbc87e9c0 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Sun, 17 Nov 2019 17:06:30 +0100 Subject: [PATCH 29/32] Add DeMorgen.be Already in Chrome version of extension. --- README.md | 1 + background.js | 5 +++++ manifest.json | 3 ++- options.js | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a2f5043..da0c1fa 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ [Crain's Chicago Business](https://www.chicagobusiness.com)\ [Corriere Della Sera](https://www.corriere.it)\ [Daily Press](https://www.dailypress.com)\ +[DeMorgen](https://demorgen.be)\ [Denver Post](https://www.denverpost.com)\ [De Groene Amsterdammer](https://www.groene.nl)\ [De Tijd](https://www.tijd.be)\ diff --git a/background.js b/background.js index 4e99b39..e3e473d 100644 --- a/background.js +++ b/background.js @@ -14,6 +14,7 @@ var defaultSites = { 'Crain\'s Chicago Business': 'chicagobusiness.com', 'Corriere Della Sera': 'corriere.it', 'Daily Press': 'dailypress.com', + 'DeMorgen': 'demorgen.be', 'Denver Post': 'denverpost.com', 'De Tijd': 'tijd.be', 'De Groene Amsterdammer': 'groene.nl', @@ -101,6 +102,7 @@ const allow_cookies = [ 'bostonglobe.com', 'cen.acs.org', 'chicagobusiness.com', +'demorgen.be', 'denverpost.com', 'economist.com', 'ed.nl', @@ -142,6 +144,7 @@ const remove_cookies = [ 'bostonglobe.com', 'cen.acs.org', 'chicagobusiness.com', +'demorgen.be', 'denverpost.com', 'economist.com', 'ed.nl', @@ -184,6 +187,8 @@ const remove_cookies_select_drop = { '.ad.nl': ['temptationTrackingId'], '.www.ad.nl': ['none'], 'www.ad.nl': ['none'], + '.demorgen.be': ['TID_ID'], + 'www.demorgen.be': ['none'], '.ed.nl': ['temptationTrackingId'], '.www.ed.nl': ['none'], 'www.ed.nl': ['none'], diff --git a/manifest.json b/manifest.json index 3b3cd6d..93694bf 100644 --- a/manifest.json +++ b/manifest.json @@ -143,7 +143,8 @@ "*://*.vn.nl/*", "*://*.lemonde.fr/*", "*://*.scientificamerican.com/*", - "*://*.thehindu.com/*" + "*://*.thehindu.com/*", + "*://*.demorgen.be/*" ], "version": "1.6.0" } diff --git a/options.js b/options.js index fbb3d3d..5f40578 100644 --- a/options.js +++ b/options.js @@ -12,6 +12,7 @@ var defaultSites = { 'Crain\'s Chicago Business': 'chicagobusiness.com', 'Corriere Della Sera': 'corriere.it', 'Daily Press': 'dailypress.com', + 'DeMorgen': 'demorgen.be', 'Denver Post': 'denverpost.com', 'De Groene Amsterdammer': 'groene.nl', 'De Tijd': 'tijd.be', From ede7f1e0e50c5d5e2639da2f0e91bad89ecee986 Mon Sep 17 00:00:00 2001 From: magnolia1234 <54500520+magnolia1234@users.noreply.github.com> Date: Sun, 17 Nov 2019 20:26:29 +0100 Subject: [PATCH 30/32] Simplify specific cookie drop/hold Search for specific cookiename in all available cookie-(sub)domains. --- background.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/background.js b/background.js index e3e473d..a8d5178 100644 --- a/background.js +++ b/background.js @@ -177,22 +177,17 @@ const remove_cookies = [ // select specific cookie(s) to hold from remove_cookies domains const remove_cookies_select_hold = { - '.nrc.nl': ['nmt_closed_cookiebar'], - '.washingtonpost.com': ['wp_gdpr'], - '.wsj.com': ['wsjregion'] + 'nrc.nl': ['nmt_closed_cookiebar'], + 'washingtonpost.com': ['wp_gdpr'], + 'wsj.com': ['wsjregion'] } // select only specific cookie(s) to drop from remove_cookies domains const remove_cookies_select_drop = { - '.ad.nl': ['temptationTrackingId'], - '.www.ad.nl': ['none'], - 'www.ad.nl': ['none'], - '.demorgen.be': ['TID_ID'], - 'www.demorgen.be': ['none'], - '.ed.nl': ['temptationTrackingId'], - '.www.ed.nl': ['none'], - 'www.ed.nl': ['none'], - 'www.nrc.nl': ['counter'] + 'ad.nl': ['temptationTrackingId'], + 'demorgen.be': ['TID_ID'], + 'ed.nl': ['temptationTrackingId'], + 'nrc.nl': ['counter'] } // Override User-Agent with Googlebot @@ -415,12 +410,13 @@ browser.webRequest.onCompleted.addListener(function(details) { } var cookie_domain = cookies[i].domain; + var rc_domain = cookie_domain.replace(/^(\.?www\.|\.)/, ''); // hold specific cookie(s) from remove_cookies domains - if ((cookie_domain in remove_cookies_select_hold) && remove_cookies_select_hold[cookie_domain].includes(cookies[i].name)){ + if ((rc_domain in remove_cookies_select_hold) && remove_cookies_select_hold[rc_domain].includes(cookies[i].name)){ continue; // don't remove specific cookie } // drop only specific cookie(s) from remove_cookies domains - if ((cookie_domain in remove_cookies_select_drop) && !(remove_cookies_select_drop[cookie_domain].includes(cookies[i].name))){ + if ((rc_domain in remove_cookies_select_drop) && !(remove_cookies_select_drop[rc_domain].includes(cookies[i].name))){ continue; // only remove specific cookie } From 44049b913d7fa214f813d801a439363562d5e943 Mon Sep 17 00:00:00 2001 From: alastairR Date: Thu, 21 Nov 2019 15:19:36 +1300 Subject: [PATCH 31/32] NZ Herald fix, missing curly brace --- contentScript.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contentScript.js b/contentScript.js index b2a0487..c158dbc 100644 --- a/contentScript.js +++ b/contentScript.js @@ -174,13 +174,13 @@ function removeDOMElement(...elements) { } } -function removeClassesByPrefix(el, prefix) -{ +function removeClassesByPrefix(el, prefix) { for (let i = el.classList.length - 1; i >= 0; i--) { - if(el.classList[i].startsWith(prefix)) { - el.classList.remove(el.classList[i]); + if(el.classList[i].startsWith(prefix)) + el.classList.remove(el.classList[i]); } - } + } +} function pageContains(selector, text) { let elements = document.querySelectorAll(selector); From e57feb2a3cdf3fb94f61154df3c5fdf2e8d9a55f Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 21 Nov 2019 20:17:21 -0800 Subject: [PATCH 32/32] Cleanup contentScript.js a little, convert tabs to spaces --- contentScript.js | 328 +++++++++++++++++++++++------------------------ 1 file changed, 161 insertions(+), 167 deletions(-) diff --git a/contentScript.js b/contentScript.js index 8d21bcf..fdc936a 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1,195 +1,189 @@ -window.localStorage.clear(); -if (window.location.href.indexOf("bizjournals.com") !== -1) { - const hiddenStory = document.getElementsByClassName( - "js-pre-chunks__story-body" - ); - if (hiddenStory && hiddenStory.length > 0) { - hiddenStory[0].style.display = "block"; - } +window.localStorage.clear() +if (window.location.href.indexOf('bizjournals.com') !== -1) { + const hiddenStory = document.getElementsByClassName( + 'js-pre-chunks__story-body' + ) + if (hiddenStory && hiddenStory.length > 0) { + hiddenStory[0].style.display = 'block' + } - const payWallMessage = document.getElementsByClassName( - "chunk chunk--flex@lg chunk--paywall" - ); - if (payWallMessage && payWallMessage.length > 0) { - payWallMessage[0].style.display = "none"; - } -} else if (window.location.href.indexOf("businessinsider.com") !== -1) { - const paywall = document.getElementsByClassName( - "tp-modal" - ); - while (paywall.length > 0) { - paywall[0].parentNode.removeChild(paywall[0]); - } + const payWallMessage = document.getElementsByClassName( + 'chunk chunk--flex@lg chunk--paywall' + ) + if (payWallMessage && payWallMessage.length > 0) { + payWallMessage[0].style.display = 'none' + } +} else if (window.location.href.indexOf('businessinsider.com') !== -1) { + const paywall = document.getElementsByClassName( + 'tp-modal' + ) + while (paywall.length > 0) { + paywall[0].parentNode.removeChild(paywall[0]) + } } else if (location.hostname.endsWith('haaretz.co.il')) { - const html = document.getElementsByTagName('html'); - if (html && html.length > 0) { - html[0].style['overflow-y'] = 'auto'; - } - const msg = document.getElementById('article-wrapper'); - if (msg) { - msg.style['display'] = 'none'; - } -} else if (window.location.href.indexOf("nzherald.co.nz") !== -1) { - const paywall = document.getElementById( - "article-content" - ); - if (paywall) { - paywall.classList.remove('premium-content'); - paywall.classList.add('full-content'); - removeClassesByPrefix(paywall, 'QUnW'); - let paras = paywall.querySelectorAll("p, span, h2, div"); - for (let i = paras.length - 1; i > -1; i--) { - removeClassesByPrefix(paras[i], 'QUnW'); - paras[i].classList.remove("ellipsis"); - paras[i].removeAttribute('style'); - } - } + const html = document.getElementsByTagName('html') + if (html && html.length > 0) { + html[0].style['overflow-y'] = 'auto' + } + const msg = document.getElementById('article-wrapper') + if (msg) { + msg.style.display = 'none' + } +} else if (window.location.href.indexOf('nzherald.co.nz') !== -1) { + const paywall = document.getElementById( + 'article-content' + ) + if (paywall) { + paywall.classList.remove('premium-content') + paywall.classList.add('full-content') + removeClassesByPrefix(paywall, 'QUnW') + const paras = paywall.querySelectorAll('p, span, h2, div') + for (let i = paras.length - 1; i > -1; i--) { + removeClassesByPrefix(paras[i], 'QUnW') + paras[i].classList.remove('ellipsis') + paras[i].removeAttribute('style') + } + } } else if (location.hostname.endsWith('rep.repubblica.it')) { - if (location.href.includes("/pwa/")) { - location.href = location.href.replace("/pwa/", "/ws/detail/"); - } + if (location.href.includes('/pwa/')) { + location.href = location.href.replace('/pwa/', '/ws/detail/') + } - if (location.href.includes("/ws/detail/")) { - const paywall = document.querySelector('.paywall[subscriptions-section="content"]'); - if (paywall) { - paywall.removeAttribute('subscriptions-section'); - const preview = document.querySelector('div[subscriptions-section="content-not-granted"]'); - if (preview) { - preview.remove(); - } - } - } -} else if (window.location.href.indexOf("wsj.com") !== -1) { - if (location.href.includes('/articles/')) { - document.addEventListener('DOMContentLoaded', () => { - const paywall = document.getElementById('cx-scrim'); - const candybar = document.getElementById('cx-candybar'); - removeDOMElement(paywall, candybar); - }); - /** - setTimeout(function () { - const close_button = document.querySelector('.close-btn'); - if (close_button) - close_button.click(); - }, 2000); - **/ - } -} else if (window.location.href.indexOf("washingtonpost.com") !== -1) { - if (location.href.includes('/gdpr-consent/')) { - document.querySelector('.gdpr-consent-container .continue-btn.button.free').click(); - - setTimeout(function () { - - const gdprcheckbox = document.querySelector('.gdpr-consent-container .consent-page:not(.hide) #agree'); - if (gdprcheckbox) { - gdprcheckbox.checked = true; - gdprcheckbox.dispatchEvent(new Event('change')); - - document.querySelector('.gdpr-consent-container .consent-page:not(.hide) .continue-btn.button.accept-consent').click(); - } - }, 300); // Delay (in milliseconds) - } -} - -if (window.location.href.indexOf("medium.com") !== -1) { - const bottomMessageText = 'Get one more story in your member preview when you sign up. It’s free.'; - const DOMElementsToTextDiv = pageContains('div', bottomMessageText); - - if (DOMElementsToTextDiv[2]) removeDOMElement(DOMElementsToTextDiv[2]); -} - -if (window.location.href.indexOf("bloombergquint.com") !== -1) { - const articlesLeftModal = document.getElementsByClassName('paywall-meter-module__story-paywall-container__1UgCE')[0]; - const paywall = document.getElementById('paywallDmp'); - removeDOMElement(articlesLeftModal, paywall); -} - -if (window.location.href.indexOf("bloomberg.com") !== -1) { + if (location.href.includes('/ws/detail/')) { + const paywall = document.querySelector('.paywall[subscriptions-section="content"]') + if (paywall) { + paywall.removeAttribute('subscriptions-section') + const preview = document.querySelector('div[subscriptions-section="content-not-granted"]') + if (preview) { + preview.remove() + } + } + } +} else if (window.location.href.indexOf('wsj.com') !== -1) { + if (location.href.includes('/articles/')) { document.addEventListener('DOMContentLoaded', () => { - const fence = document.querySelector('.fence-body'); - if (fence){ - fence.classList.remove('fence-body'); - } - const paywall = document.getElementById('paywall-banner'); - removeDOMElement(paywall); - }); + const paywall = document.getElementById('cx-scrim') + const candybar = document.getElementById('cx-candybar') + removeDOMElement(paywall, candybar) + }) + /** + setTimeout(function () { + const close_button = document.querySelector('.close-btn'); + if (close_button) + close_button.click(); + }, 2000); + **/ + } +} else if (window.location.href.indexOf('washingtonpost.com') !== -1) { + if (location.href.includes('/gdpr-consent/')) { + document.querySelector('.gdpr-consent-container .continue-btn.button.free').click() + + setTimeout(function () { + const gdprcheckbox = document.querySelector('.gdpr-consent-container .consent-page:not(.hide) #agree') + if (gdprcheckbox) { + gdprcheckbox.checked = true + gdprcheckbox.dispatchEvent(new Event('change')) + + document.querySelector('.gdpr-consent-container .consent-page:not(.hide) .continue-btn.button.accept-consent').click() + } + }, 300) // Delay (in milliseconds) + } +} + +if (window.location.href.indexOf('medium.com') !== -1) { + const bottomMessageText = 'Get one more story in your member preview when you sign up. It’s free.' + const DOMElementsToTextDiv = pageContains('div', bottomMessageText) + + if (DOMElementsToTextDiv[2]) removeDOMElement(DOMElementsToTextDiv[2]) +} + +if (window.location.href.indexOf('bloombergquint.com') !== -1) { + const articlesLeftModal = document.getElementsByClassName('paywall-meter-module__story-paywall-container__1UgCE')[0] + const paywall = document.getElementById('paywallDmp') + removeDOMElement(articlesLeftModal, paywall) +} + +if (window.location.href.indexOf('bloomberg.com') !== -1) { + document.addEventListener('DOMContentLoaded', () => { + const fence = document.querySelector('.fence-body') + if (fence) { + fence.classList.remove('fence-body') + } + const paywall = document.getElementById('paywall-banner') + removeDOMElement(paywall) + }) } if (window.location.href.indexOf('telegraaf.nl') !== -1) { - setTimeout(function () { - const paywall = document.getElementById('TEMPRORARY_METERING_ID'); - if (paywall) { - window.location.reload(true); - } - }, 1000); // Delay (in milliseconds) + setTimeout(function () { + const paywall = document.getElementById('TEMPRORARY_METERING_ID') + if (paywall) { + window.location.reload(true) + } + }, 1000) // Delay (in milliseconds) } if (window.location.href.indexOf('ad.nl') !== -1 || window.location.href.indexOf('ed.nl') !== -1) { - let paywall = document.querySelector('.article__component.article__component--paywall-module-notification'); - removeDOMElement(paywall); + const paywall = document.querySelector('.article__component.article__component--paywall-module-notification') + removeDOMElement(paywall) } -if (window.location.href.indexOf("parool.nl") !== -1 || window.location.href.indexOf("trouw.nl") !== -1 || window.location.href.indexOf("volkskrant.nl") !== -1) { - document.addEventListener('DOMContentLoaded', () => { - const paywall = document.querySelector('div[data-temptation-position="ARTICLE_BOTTOM"]'); - const hidden_section = document.querySelector('div[data-temptation-position="ARTICLE_INLINE"]'); - removeDOMElement(paywall, hidden_section); - }); +if (window.location.href.indexOf('parool.nl') !== -1 || window.location.href.indexOf('trouw.nl') !== -1 || window.location.href.indexOf('volkskrant.nl') !== -1) { + document.addEventListener('DOMContentLoaded', () => { + const paywall = document.querySelector('div[data-temptation-position="ARTICLE_BOTTOM"]') + const hidden_section = document.querySelector('div[data-temptation-position="ARTICLE_INLINE"]') + removeDOMElement(paywall, hidden_section) + }) } if (window.location.href.indexOf('lemonde.fr') !== -1) { - document.addEventListener('DOMContentLoaded', () => { - const hidden_section = document.getElementsByClassName('article__content--restricted-media')[0]; - if (hidden_section) - hidden_section.classList.remove('article__content--restricted-media'); - const longform_article_restricted = document.getElementsByClassName('article__content--restricted')[0]; - if (longform_article_restricted) - longform_article_restricted.classList.remove('article__content--restricted'); - const longform_paywall = document.getElementsByClassName('paywall--longform')[0]; - if (longform_paywall) - longform_paywall.classList.remove('paywall--longform'); - const paywall = document.getElementById('js-paywall-content'); - const friend_paywall = document.getElementsByClassName('friend--paywall')[0]; - const cookie_banner = document.getElementById('cookie-banner'); - removeDOMElement(paywall, friend_paywall, cookie_banner); - }); + document.addEventListener('DOMContentLoaded', () => { + const hidden_section = document.getElementsByClassName('article__content--restricted-media')[0] + if (hidden_section) { hidden_section.classList.remove('article__content--restricted-media') } + const longform_article_restricted = document.getElementsByClassName('article__content--restricted')[0] + if (longform_article_restricted) { longform_article_restricted.classList.remove('article__content--restricted') } + const longform_paywall = document.getElementsByClassName('paywall--longform')[0] + if (longform_paywall) { longform_paywall.classList.remove('paywall--longform') } + const paywall = document.getElementById('js-paywall-content') + const friend_paywall = document.getElementsByClassName('friend--paywall')[0] + const cookie_banner = document.getElementById('cookie-banner') + removeDOMElement(paywall, friend_paywall, cookie_banner) + }) } -if (window.location.href.indexOf("nytimes.com") !== -1) { - const preview_button = document.querySelector('.css-3s1ce0'); - if (preview_button) - preview_button.click(); +if (window.location.href.indexOf('nytimes.com') !== -1) { + const preview_button = document.querySelector('.css-3s1ce0') + if (preview_button) { preview_button.click() } } -if (window.location.href.indexOf("caixinglobal.com") !== -1) { - const appContent = document.getElementById('appContent'); - if (appContent) { - const p_hidden = document.querySelectorAll('p:not([style="display:block;"]'); - for (var i = 0; i < p_hidden.length; i++) { - p_hidden[i].setAttribute('style', 'display:block;'); - } - } +if (window.location.href.indexOf('caixinglobal.com') !== -1) { + const appContent = document.getElementById('appContent') + if (appContent) { + const p_hidden = document.querySelectorAll('p:not([style="display:block;"]') + for (var i = 0; i < p_hidden.length; i++) { + p_hidden[i].setAttribute('style', 'display:block;') + } + } } -function removeDOMElement(...elements) { - for (let element of elements) { - if (element) element.remove(); - } +function removeDOMElement (...elements) { + for (const element of elements) { + if (element) element.remove() + } } -function removeClassesByPrefix(el, prefix) { - for (let i = el.classList.length - 1; i >= 0; i--) { - if(el.classList[i].startsWith(prefix)) - el.classList.remove(el.classList[i]); - } - } +function removeClassesByPrefix (el, prefix) { + for (let i = el.classList.length - 1; i >= 0; i--) { + if (el.classList[i].startsWith(prefix)) { + el.classList.remove(el.classList[i]) + } + } } -function pageContains(selector, text) { - let elements = document.querySelectorAll(selector); - - return Array.prototype.filter.call(elements, function(element){ - return RegExp(text).test(element.textContent); - }); +function pageContains (selector, text) { + const elements = document.querySelectorAll(selector) + return Array.prototype.filter.call(elements, function (element) { + return RegExp(text).test(element.textContent) + }) }