diff --git a/README.md b/README.md index da6ef1d..1f1eb7a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # Bypass Paywalls for Firefox -## [Download and install the latest version](https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.5.9/bypass_paywalls-1.5.9-an+fx.xpi) +## [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)\ @@ -16,9 +17,11 @@ [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)\ @@ -31,6 +34,7 @@ [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)\ @@ -46,10 +50,12 @@ [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)\ @@ -78,7 +84,9 @@ [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 diff --git a/background.js b/background.js index 89e4f3a..d7d2536 100644 --- a/background.js +++ b/background.js @@ -1,6 +1,7 @@ 'use strict'; var defaultSites = { + 'Algemeen Dagblad': 'ad.nl', 'Baltimore Sun': 'baltimoresun.com', 'Barron\'s': 'barrons.com', 'Bloomberg': 'bloomberg.com', @@ -14,8 +15,10 @@ var defaultSites = { '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', @@ -28,6 +31,7 @@ var defaultSites = { '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', @@ -43,9 +47,11 @@ var defaultSites = { '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', @@ -69,12 +75,15 @@ var defaultSites = { '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' }; @@ -84,77 +93,98 @@ const restrictions = { // Don't remove cookies before page load const allow_cookies = [ +'ad.nl', 'asia.nikkei.com', -'nytimes.com', -'wsj.com', -'ft.com', -'letemps.ch', -'mercurynews.com', -'economist.com', 'bostonglobe.com', +'cen.acs.org', +'chicagobusiness.com', 'denverpost.com', -'hacked.com', -'ocregister.com', -'newstatesman.com', -'spectator.co.uk', -'towardsdatascience.com', -'medium.com', -'theadvocate.com.au', +'economist.com', +'ed.nl', 'examiner.com.au', -'thestar.com', -'washingtonpost.com', +'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', -'nytimes.com', -'ft.com', -'letemps.ch', -'mercurynews.com', -'theage.com.au', -'economist.com', 'bostonglobe.com', -'denverpost.com', -'hacked.com', -'ocregister.com', -'newstatesman.com', -'spectator.co.uk', -'towardsdatascience.com', -'medium.com', -'theadvocate.com.au', -'examiner.com.au', -'thestar.com', -'centralwesterndaily.com.au', -'theherald.com.au', -'foreignpolicy.com', -'wsj.com', -'glassdoor.com', 'cen.acs.org', -'hbr.org', -'thenewsrep.com', -'washingtonpost.com', -'nymag.com', -'nationalpost.com', -'volkskrant.nl', -'handelsblatt.com', -'thediplomat.com', -'latimes.com', -'theatlantic.com', '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 = [ -'theaustralian.com.au', -'telegraph.co.uk', -'thetimes.co.uk', 'barrons.com', +'nytimes.com', +'quora.com', +'telegraph.co.uk', +'theaustralian.com.au', +'thetimes.co.uk', +'wsj.com', ] function setDefaultOptions() { @@ -210,9 +240,10 @@ browser.runtime.onInstalled.addListener(function(details) { } }); +/** // WSJ bypass browser.webRequest.onBeforeSendHeaders.addListener(function(details) { - if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1) { + if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1 || details.url.indexOf("/print-edition/") !== -1) { return; } @@ -232,6 +263,7 @@ browser.webRequest.onBeforeSendHeaders.addListener(function(details) { {urls:["*://*.wsj.com/*"], types:["main_frame"]}, ["blocking"] ); +**/ // Disable javascript for these sites chrome.webRequest.onBeforeRequest.addListener(function(details) { @@ -361,6 +393,17 @@ browser.webRequest.onCompleted.addListener(function(details) { if (cookies[i].firstPartyDomain !== undefined) { cookie.firstPartyDomain = cookies[i].firstPartyDomain; } + + var cookie_domain = cookies[i].domain; + // 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)){ + 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))){ + continue; // only remove specific cookie + } + browser.cookies.remove(cookie); } }); diff --git a/contentScript.js b/contentScript.js index fa57321..0bd5558 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1,113 +1,167 @@ 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 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"; - } + 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 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'; - } + 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'); - 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); - } - } - } - paras[i].removeAttribute('style'); - } - } + const paywall = document.getElementById( + "article-content" + ); + if (paywall) { + 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); + } + } + } + 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(); - } - } - } + 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/')) { - setTimeout(function() { - document.querySelector('.close-btn').click(); - }, 2000); - } + 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(); + if (location.href.includes('/gdpr-consent/')) { + document.querySelector('.gdpr-consent-container .continue-btn.button.free').click(); - setTimeout(function (){ + setTimeout(function () { - const gdprcheckbox = document.querySelector('.gdpr-consent-container .consent-page:not(.hide) #agree'); - if (gdprcheckbox) { - gdprcheckbox.checked = true; - gdprcheckbox.dispatchEvent(new Event('change')); + 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) - } + 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 = contains('div', bottomMessageText); - + const DOMElementsToTextDiv = pageContains('div', bottomMessageText); if(DOMElementsToTextDiv[2]) removeDOMElement(DOMElementsToTextDiv[2]); } +if (window.location.href.indexOf("bloomberg.com") !== -1) { + const paywall = document.getElementById('paywall-banner'); + removeDOMElement(paywall); +} + +if (window.location.href.indexOf('telegraaf.nl') !== -1) { + const paywall = document.getElementById('TEMPRORARY_METERING_ID'); + if (paywall) { + window.location.reload(1); + } +} + +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("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); + }); +} + function removeDOMElement(...elements) { for (let element of elements) { if (element) element.remove(); } } -function contains(selector, text) { +function pageContains(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 +} diff --git a/manifest.json b/manifest.json index 1f58a10..052c628 100644 --- a/manifest.json +++ b/manifest.json @@ -5,10 +5,19 @@ "content_scripts": [ { "matches": [ - "*://*.bizjournals.com/*", - "*://*.businessinsider.com/*", - "*://*.haaretz.co.il/*", - "*://*.repubblica.it/*" + "*://*.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"] } @@ -121,7 +130,15 @@ "*://*.wired.com/*", "*://*.thediplomat.com/*", "*://*.theatlantic.com/*", - "*://*.qz.com/*" + "*://*.qz.com/*", + "*://*.ad.nl/*", + "*://*.ed.nl/*", + "*://*.groene.nl/*", + "*://*.parool.nl/*", + "*://*.telegraaf.nl/*", + "*://*.trouw.nl/*", + "*://*.vn.nl/*", + "*://*.lemonde.fr/*" ], - "version": "1.5.9" + "version": "1.6.0" } diff --git a/options.js b/options.js index 694161e..19a0d34 100644 --- a/options.js +++ b/options.js @@ -1,4 +1,5 @@ var defaultSites = { + 'Algemeen Dagblad': 'ad.nl', 'Baltimore Sun': 'baltimoresun.com', 'Barron\'s': 'barrons.com', 'Bloomberg': 'bloomberg.com', @@ -11,9 +12,11 @@ var defaultSites = { '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', @@ -26,6 +29,7 @@ var defaultSites = { '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', @@ -41,10 +45,12 @@ var defaultSites = { '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', @@ -73,7 +79,9 @@ var defaultSites = { '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' }; diff --git a/updates.json b/updates.json index f5c08fa..994ceed 100644 --- a/updates.json +++ b/updates.json @@ -30,7 +30,9 @@ { "version": "1.5.8", "update_link": "https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.5.8/bypass_paywalls-1.5.8-an+fx.xpi" }, { "version": "1.5.9", - "update_link": "https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.5.9/bypass_paywalls-1.5.9-an+fx.xpi" } + "update_link": "https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.5.9/bypass_paywalls-1.5.9-an+fx.xpi" }, + { "version": "1.6.0", + "update_link": "https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.6.0/bypass_paywalls-1.6.0-an+fx.xpi" } ] } }