Fix WSJ, fix hbr, add newsrep

master
Adam 2019-02-10 15:43:12 -08:00
parent a3a928244c
commit 021ab34bef
5 changed files with 64 additions and 23 deletions

View File

@ -1,6 +1,8 @@
# Bypass Paywalls for Firefox
## [Download and install the latest version](https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.4.8/bypass_paywalls-1.4.8-an+fx.xpi)
## [Download and install the latest version](https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.4.9/bypass_paywalls-1.4.9-an+fx.xpi)
### 2019-02-10: WSJ bypass fixed!
### 2019-02-02: The Wall Street Journal (wsj.com) bypass is currently not working. WSJ seems to have changed their algorithm.
@ -39,6 +41,7 @@ Medscape (medscape.com)\
MIT Technology Review (technologyreview.com)\
Mountain View Voice (mv-voice.com)\
New Statesman (newstatesman.com)\
Newsrep (thenewsrep.com)\
Nikkei Asian Review (asia.nikkei.com)\
NRC (nrc.nl)\
Orange County Register (ocregister.com)\
@ -77,7 +80,7 @@ Wired (wired.com)
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.
### Troubleshooting
* This add-on works best along with [uBlock Origin](https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/)
* This add-on works best alongside [uBlock Origin](https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/).
* For The Denver Post turn off uBlock.
* If a site doesn't work try turning off uBlock and refreshing.

View File

@ -36,6 +36,7 @@ var defaultSites = {
'MIT Technology Review': 'technologyreview.com',
'Mountain View Voice': 'mv-voice.com',
'New Statesman': 'newstatesman.com',
'Newsrep': 'thenewsrep.com',
'Nikkei Asian Review': 'asia.nikkei.com',
'NRC': 'nrc.nl',
'Orange County Register': 'ocregister.com',
@ -82,7 +83,6 @@ const allow_cookies = [
'letemps.ch',
'fd.nl',
'mercurynews.com',
'theage.com.au',
'economist.com',
'bostonglobe.com',
'denverpost.com',
@ -96,8 +96,8 @@ const allow_cookies = [
'examiner.com.au',
'thestar.com',
'washingtonpost.com',
'irishtimes.com'
'irishtimes.com',
'hbr.org',
]
// Removes cookies after page load
@ -127,7 +127,9 @@ const remove_cookies = [
'wsj.com',
'glassdoor.com',
'cen.acs.org',
'irishtimes.com'
'irishtimes.com',
'hbr.org',
'thenewsrep.com',
]
function setDefaultOptions() {
@ -157,7 +159,6 @@ browser.storage.sync.get({
});
});
// Listen for changes to options
browser.storage.onChanged.addListener(function(changes, namespace) {
var key;
@ -172,7 +173,6 @@ browser.storage.onChanged.addListener(function(changes, namespace) {
}
});
// Set and show default options on install
browser.runtime.onInstalled.addListener(function (details) {
if (details.reason == "install") {
@ -182,21 +182,31 @@ browser.runtime.onInstalled.addListener(function (details) {
}
});
// WSJ bypass
browser.webRequest.onBeforeSendHeaders.addListener(function (details) {
if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -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"]
);
browser.webRequest.onBeforeSendHeaders.addListener(function(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;
});
if (!isEnabled) {
if (!isSiteEnabled(details)) {
return;
}
@ -293,3 +303,28 @@ browser.webRequest.onCompleted.addListener(function(details) {
}, {
urls: ["<all_urls>"]
});
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];
}

View File

@ -44,5 +44,5 @@
"webRequest",
"webRequestBlocking"
],
"version": "1.4.8"
"version": "1.4.9"
}

View File

@ -34,6 +34,7 @@ var defaultSites = {
'MIT Technology Review': 'technologyreview.com',
'Mountain View Voice': 'mv-voice.com',
'New Statesman': 'newstatesman.com',
'Newsrep': 'thenewsrep.com',
'Nikkei Asian Review': 'asia.nikkei.com',
'NRC': 'nrc.nl',
'Orange County Register': 'ocregister.com',

View File

@ -10,7 +10,9 @@
{ "version": "1.4.7",
"update_link": "https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.4.7/bypass_paywalls-1.4.7-an+fx.xpi" },
{ "version": "1.4.8",
"update_link": "https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.4.8/bypass_paywalls-1.4.8-an+fx.xpi" }
"update_link": "https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.4.8/bypass_paywalls-1.4.8-an+fx.xpi" },
{ "version": "1.4.9",
"update_link": "https://github.com/iamadamdev/bypass-paywalls-firefox/releases/download/v1.4.9/bypass_paywalls-1.4.9-an+fx.xpi" }
]
}
}