mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-02 15:40:13 +00:00
Initial commit
This commit is contained in:
commit
d9bef80d19
43
README.md
Normal file
43
README.md
Normal file
@ -0,0 +1,43 @@
|
||||
"# README"
|
||||
Updates--
|
||||
2017-06-15 v1.08: Added browser_action icon, removed Barron's, fixed Financial Times (ft.com), added options link to popup
|
||||
2017-05-14: Ported to Firefox
|
||||
2017-04-16: Added MIT Technology Review (technologyreview.com), NRC (nrc.nl), The Courier Mail (couriermail.com.au).
|
||||
2017-04-05: Added 'Nikkei Asian Review'.
|
||||
2017-02-25: If you are trying to view NYT articles or tired of the WSJ popup, try installing an adblocker (I recommend 'uBlock Origin').
|
||||
2017-02-16: Added 'The Australian'.
|
||||
2017-02-09: WSJ working again (bypass paywall)! Also added glassdoor, nytimes, seattletimes.
|
||||
|
||||
Bypass the following sites' paywalls:
|
||||
|
||||
The Age (theage.com.au)
|
||||
The Australian (theaustralian.com.au)
|
||||
Baltimore Sun (baltimoresun.com)
|
||||
Barron's (barrons.com)
|
||||
Crain's Chicago Business (chicagobusiness.com)
|
||||
Chicago Tribune (chicagotribune.com)
|
||||
Daily Press (dailypress.com)
|
||||
The Economist (economist.com)
|
||||
Financial Times (ft.com)
|
||||
Glassdoor (glassdoor.com)
|
||||
Hartford Courant (courant.com)
|
||||
Harvard Business Review (hbr.org)
|
||||
Inc.com (inc.com)
|
||||
Los Angeles Times (latimes.com)
|
||||
Medscape (medscape.com)
|
||||
MIT Technology Review (technologyreview.com)
|
||||
Nikkei Asian Review (asia.nikkei.com)
|
||||
NRC (nrc.nl)
|
||||
The Courier Mail (couriermail.com.au)
|
||||
The Morning Call (mcall.com)
|
||||
The Nation (thenation.com)
|
||||
The New York Times (nytimes.com)
|
||||
The New Yorker (newyorker.com)
|
||||
OrlandoSentinel (orlandosentinel.com)
|
||||
Quora (quora.com)
|
||||
SunSentinel (sun-sentinel.com)
|
||||
The Seattle Times (seattletimes.com)
|
||||
The Sydney Morning Herald (smh.com.au)
|
||||
The Telegraph (telegraph.co.uk)
|
||||
The Washington Post (washingtonpost.com)
|
||||
The Wall Street Journal (wsj.com)
|
212
background.js
Normal file
212
background.js
Normal file
@ -0,0 +1,212 @@
|
||||
'use strict';
|
||||
|
||||
var defaultSites = {
|
||||
'The Age': 'theage.com.au',
|
||||
'The Australian': 'theaustralian.com.au',
|
||||
'Baltimore Sun': 'baltimoresun.com',
|
||||
'Crain\'s Chicago Business': 'chicagobusiness.com',
|
||||
'Chicago Tribune': 'chicagotribune.com',
|
||||
'Daily Press': 'dailypress.com',
|
||||
'The Economist': 'economist.com',
|
||||
'Financial Times': 'ft.com',
|
||||
'Glassdoor': 'glassdoor.com',
|
||||
'Hartford Courant': 'courant.com',
|
||||
'Harvard Business Review': 'hbr.org',
|
||||
'Inc.com': 'inc.com',
|
||||
'Los Angeles Times': 'latimes.com',
|
||||
'Medscape': 'medscape.com',
|
||||
'MIT Technology Review': 'technologyreview.com',
|
||||
'Nikkei Asian Review': 'asia.nikkei.com',
|
||||
'NRC': 'nrc.nl',
|
||||
'The Courier Mail': 'couriermail.com.au',
|
||||
'The Morning Call': 'mcall.com',
|
||||
'The Nation': 'thenation.com',
|
||||
'The New York Times': 'nytimes.com',
|
||||
'The New Yorker': 'newyorker.com',
|
||||
'OrlandoSentinel': 'orlandosentinel.com',
|
||||
'Quora': 'quora.com',
|
||||
'SunSentinel': 'sun-sentinel.com',
|
||||
'The Seattle Times': 'seattletimes.com',
|
||||
'The Sydney Morning Herald': 'smh.com.au',
|
||||
'The Telegraph': 'telegraph.co.uk',
|
||||
'The Washington Post': 'washingtonpost.com',
|
||||
'The Wall Street Journal': 'wsj.com'
|
||||
};
|
||||
|
||||
var restrictions = {
|
||||
'barrons.com': 'barrons.com/articles'
|
||||
}
|
||||
|
||||
// Don't remove cookies before page load
|
||||
var allow_cookies = [
|
||||
'theaustralian.com.au',
|
||||
'asia.nikkei.com',
|
||||
'nytimes.com',
|
||||
'wsj.com',
|
||||
'couriermail.com.au',
|
||||
'ft.com'
|
||||
]
|
||||
|
||||
// Removes cookies after page load
|
||||
var remove_cookies = [
|
||||
'theaustralian.com.au',
|
||||
'asia.nikkei.com',
|
||||
'couriermail.com.au',
|
||||
'ft.com'
|
||||
]
|
||||
|
||||
function setDefaultOptions() {
|
||||
browser.storage.sync.set({
|
||||
sites: defaultSites
|
||||
}, function() {
|
||||
browser.runtime.openOptionsPage();
|
||||
// browser.tabs.create({ 'url': 'browser://extensions/?options=' + browser.runtime.id });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var blockedRegexes = [
|
||||
/.+:\/\/.+\.tribdss\.com\//,
|
||||
/thenation\.com\/.+\/paywall-script\.php/
|
||||
];
|
||||
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
browser.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
||||
if (blockedRegexes.some(function(regex) { return regex.test(details.url); })) {
|
||||
return { cancel: true };
|
||||
}
|
||||
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
||||
var requestHeaders = details.requestHeaders;
|
||||
var tabId = details.tabId;
|
||||
|
||||
var setReferer = false;
|
||||
|
||||
// if referer exists, set it to google
|
||||
requestHeaders = requestHeaders.map(function(requestHeader) {
|
||||
if (requestHeader.name === 'Referer') {
|
||||
if (details.url.indexOf("wsj.com") !== -1) {
|
||||
requestHeader.value = 'https://www.facebook.com/';
|
||||
} else {
|
||||
requestHeader.value = 'https://www.google.com/';
|
||||
}
|
||||
|
||||
setReferer = true;
|
||||
}
|
||||
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/'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 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: ['<all_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<cookies.length; i++) {
|
||||
browser.cookies.remove({url: cookies[i].secure ? "https://" : "http://" + cookies[i].domain + cookies[i].path, name: cookies[i].name});
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
BIN
bypass.png
Normal file
BIN
bypass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 693 B |
6
bypass.svg
Normal file
6
bypass.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg fill="currentColor" width="1em" height="1em" viewBox="0 0 40 40" preserveAspectRatio="xMidYMid meet" style="vertical-align:middle;display:inline-block;" data-reactid=".0.4:$/=10.2.0">
|
||||
<g data-reactid=".0.4:$/=10.2.0.0">
|
||||
<path d="m20 12.5h-7.5v7.5h7.5v-7.5z m2.5 12.5v2.5h-12.5v-2.5h12.5z m0-15v12.5h-12.5v-12.5h12.5z m12.5 15v2.5h-10v-2.5h10z m0-5v2.5h-10v-2.5h10z m0-5v2.5h-10v-2.5h10z m0-5v2.5h-10v-2.5h10z m-30 18.75v-18.75h-2.5v18.75q0 0.5075000000000003 0.37124999999999986 0.8787500000000001t0.8787500000000001 0.37124999999999986 0.8787500000000001-0.37124999999999986 0.37124999999999986-0.8787500000000001z m32.5 0v-21.25h-30v21.25q0 0.6449999999999996-0.21499999999999986 1.25h28.965q0.5075000000000003 0 0.8787499999999966-0.37124999999999986t0.3712500000000034-0.8787500000000001z m2.5-23.75v23.75q0 1.5625-1.09375 2.65625t-2.65625 1.09375h-32.5q-1.5625 0-2.65625-1.09375t-1.09375-2.65625v-21.25h5v-2.5h35z" data-reactid=".0.4:$/=10.2.0.0.0"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.0 KiB |
BIN
bypass_wsj_extension_screenshot.png
Normal file
BIN
bypass_wsj_extension_screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 208 KiB |
42
changelog.txt
Normal file
42
changelog.txt
Normal file
@ -0,0 +1,42 @@
|
||||
Updates--
|
||||
2017-06-15 v1.08: Added browser_action icon, removed Barron's, fixed Financial Times (ft.com), added options link to popup
|
||||
2017-05-14: Ported to Firefox
|
||||
2017-04-16: Added MIT Technology Review (technologyreview.com), NRC (nrc.nl), The Courier Mail (couriermail.com.au).
|
||||
2017-04-05: Added 'Nikkei Asian Review'.
|
||||
2017-02-25: If you are trying to view NYT articles or tired of the WSJ popup, try installing an adblocker (I recommend 'uBlock Origin').
|
||||
2017-02-16: Added 'The Australian'.
|
||||
2017-02-09: WSJ working again (bypass paywall)! Also added glassdoor, nytimes, seattletimes.
|
||||
|
||||
Bypass the following sites' paywalls:
|
||||
|
||||
The Age (theage.com.au)
|
||||
The Australian (theaustralian.com.au)
|
||||
Baltimore Sun (baltimoresun.com)
|
||||
Barron's (barrons.com)
|
||||
Crain's Chicago Business (chicagobusiness.com)
|
||||
Chicago Tribune (chicagotribune.com)
|
||||
Daily Press (dailypress.com)
|
||||
The Economist (economist.com)
|
||||
Financial Times (ft.com)
|
||||
Glassdoor (glassdoor.com)
|
||||
Hartford Courant (courant.com)
|
||||
Harvard Business Review (hbr.org)
|
||||
Inc.com (inc.com)
|
||||
Los Angeles Times (latimes.com)
|
||||
Medscape (medscape.com)
|
||||
MIT Technology Review (technologyreview.com)
|
||||
Nikkei Asian Review (asia.nikkei.com)
|
||||
NRC (nrc.nl)
|
||||
The Courier Mail (couriermail.com.au)
|
||||
The Morning Call (mcall.com)
|
||||
The Nation (thenation.com)
|
||||
The New York Times (nytimes.com)
|
||||
The New Yorker (newyorker.com)
|
||||
OrlandoSentinel (orlandosentinel.com)
|
||||
Quora (quora.com)
|
||||
SunSentinel (sun-sentinel.com)
|
||||
The Seattle Times (seattletimes.com)
|
||||
The Sydney Morning Herald (smh.com.au)
|
||||
The Telegraph (telegraph.co.uk)
|
||||
The Washington Post (washingtonpost.com)
|
||||
The Wall Street Journal (wsj.com)
|
1
contentScript.js
Normal file
1
contentScript.js
Normal file
@ -0,0 +1 @@
|
||||
window.localStorage.clear();
|
29
manifest.json
Normal file
29
manifest.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"background": {
|
||||
"scripts": ["background.js"]
|
||||
},
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "iamadamdev@hotmail.com"
|
||||
}
|
||||
},
|
||||
"browser_action": {
|
||||
"default_popup": "popup.html",
|
||||
"default_icon": {
|
||||
"128": "bypass.png"
|
||||
}
|
||||
},
|
||||
"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", "<all_urls>", "storage", "webRequest", "webRequestBlocking"],
|
||||
"version": "1.0.8"
|
||||
}
|
34
options.html
Normal file
34
options.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bypass Paywalls Options</title>
|
||||
<style>
|
||||
#bypass_sites label {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
width:350px;
|
||||
height:600px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
Selected sites will have their cookies cleared and referer set to Google. You should
|
||||
uncheck sites you have an account with or else you will be logged out at every visit.
|
||||
</div>
|
||||
<br/>
|
||||
<div id='bypass_sites'>
|
||||
</div>
|
||||
<br/>
|
||||
<div id="status"></div>
|
||||
<div id="error"></div>
|
||||
<br/>
|
||||
<button id="save">Save</button>
|
||||
<span style='float:right;'>
|
||||
<button id="select-all">Select all</button>
|
||||
<button id="select-none">Select none</button>
|
||||
</span>
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
</html>
|
106
options.js
Normal file
106
options.js
Normal file
@ -0,0 +1,106 @@
|
||||
var defaultSites = {
|
||||
'The Age': 'theage.com.au',
|
||||
'The Australian': 'theaustralian.com.au',
|
||||
'Baltimore Sun': 'baltimoresun.com',
|
||||
'Crain\'s Chicago Business': 'chicagobusiness.com',
|
||||
'Chicago Tribune': 'chicagotribune.com',
|
||||
'Daily Press': 'dailypress.com',
|
||||
'The Economist': 'economist.com',
|
||||
'Financial Times': 'ft.com',
|
||||
'Glassdoor': 'glassdoor.com',
|
||||
'Hartford Courant': 'courant.com',
|
||||
'Harvard Business Review': 'hbr.org',
|
||||
'Inc.com': 'inc.com',
|
||||
'Los Angeles Times': 'latimes.com',
|
||||
'Medscape': 'medscape.com',
|
||||
'MIT Technology Review': 'technologyreview.com',
|
||||
'Nikkei Asian Review': 'asia.nikkei.com',
|
||||
'NRC': 'nrc.nl',
|
||||
'The Courier Mail': 'couriermail.com.au',
|
||||
'The Morning Call': 'mcall.com',
|
||||
'The Nation': 'thenation.com',
|
||||
'The New York Times': 'nytimes.com',
|
||||
'The New Yorker': 'newyorker.com',
|
||||
'OrlandoSentinel': 'orlandosentinel.com',
|
||||
'Quora': 'quora.com',
|
||||
'SunSentinel': 'sun-sentinel.com',
|
||||
'The Seattle Times': 'seattletimes.com',
|
||||
'The Sydney Morning Herald': 'smh.com.au',
|
||||
'The Telegraph': 'telegraph.co.uk',
|
||||
'The Washington Post': 'washingtonpost.com',
|
||||
'The Wall Street Journal': 'wsj.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);
|
||||
|
7
popup.html
Normal file
7
popup.html
Normal file
@ -0,0 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<div style="width:220px;">Bypass Paywalls v1.08 by Adam
|
||||
<a href="options.html">Options</a></div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user