Include sites from local js-file (maintenance)

No more custom/updates from json-file on Github.
Preparation for adding custom sites by user.
This commit is contained in:
magnolia1234 2020-02-25 22:47:05 +01:00 committed by GitHub
parent 827e139e82
commit 2cfed0a2c3
6 changed files with 188 additions and 56 deletions

View file

@ -3,8 +3,8 @@
'use strict';
// Cookies from this list are blocked by default (obsolete)
// defaultSites are loaded from sites(_custom).json at installation extension
var defaultSites = {};
// defaultSites are loaded from sites.js at installation extension
// var defaultSites = {};
const restrictions = {
'barrons.com': /.+barrons\.com\/articles\/.+/,
@ -13,7 +13,7 @@ const restrictions = {
}
// Don't remove cookies before page load
// allow_cookies are completed with domains in sites(_custom).json (default allow/remove_cookies)
// allow_cookies are completed with domains in sites.js (default allow/remove_cookies)
var allow_cookies = [
'adelaidenow.com.au',
'barrons.com',
@ -63,7 +63,7 @@ var allow_cookies = [
]
// Removes cookies after page load
// remove_cookies are completed with domains of sites(_custom).json (default allow/remove_cookies)
// remove_cookies are completed with domains of sites.js (default allow/remove_cookies)
var remove_cookies = [
]
@ -209,28 +209,7 @@ browser.storage.onChanged.addListener(function(changes, namespace) {
// Set and show default options on install
browser.runtime.onInstalled.addListener(function (details) {
if (details.reason == "install") {
const url_sites = browser.runtime.getURL('sites.json');
fetch(url_sites)
.then(response => {
if (response.ok) {
response.json().then(json => {
var defaultSites_merge = {...defaultSites, ...json};
defaultSites = defaultSites_merge;
// add custom sites
const url_sites_custom = 'https://raw.githubusercontent.com/magnolia1234/bypass-paywalls-firefox-clean/master/sites_custom.json';
fetch(url_sites_custom)
.then(response => {
if (response.ok) {
response.json().then(json => {
var defaultSites_merge = {...defaultSites, ...json};
defaultSites = defaultSites_merge;
setDefaultOptions();
})
} else { setDefaultOptions(); }
} );
})
} else { setDefaultOptions(); }
} );
setDefaultOptions();
} else if (details.reason == "update") {
// User updated extension
}

View file

@ -1,6 +1,6 @@
{
"background": {
"scripts": ["background.js"]
"scripts": ["sites.js", "background.js"]
},
"content_scripts": [
{

View file

@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bypass Paywalls Clean Options</title>
<style>
#bypass_sites label {
@ -30,6 +31,7 @@
<button id="select-all">Select all</button>
<button id="select-none">Select none</button>
</span>
<script src="sites.js"></script>
<script src="options.js"></script>
<script src="version.js"></script>
</body>

View file

@ -1,5 +1,5 @@
// defaultSites are loaded from sites(_custom).json at installation extension (and are saved to local storage)
var defaultSites = {};
// defaultSites are loaded from sites.js at installation extension (and are saved to local storage)
// var defaultSites = {};
// Saves options to browser.storage
function save_options() {
@ -30,35 +30,9 @@ function save_options() {
browser.tabs.reload({bypassCache: true});
}
//Fetch sites.json & sites_custom.json
function renderOptions() {
const url_sites = browser.runtime.getURL('sites.json');
fetch(url_sites)
.then(response => {
if (response.ok) {
response.json().then(json => {
var defaultSites_merge = {...defaultSites, ...json};
defaultSites = defaultSites_merge;
// add custom sites
const url_sites_custom = 'https://raw.githubusercontent.com/magnolia1234/bypass-paywalls-firefox-clean/master/sites_custom.json';
fetch(url_sites_custom)
.then(response => {
if (response.ok) {
response.json().then(json => {
var defaultSites_merge = {...defaultSites, ...json};
defaultSites = defaultSites_merge;
renderOptions_default();
})
} else { renderOptions_default(); }
} );
})
} else { renderOptions_default(); }
} );
}
// Restores checkbox input states using the preferences
// stored in browser.storage.
function renderOptions_default() {
function renderOptions() {
browser.storage.sync.get({
sites: {}
}, function(items) {

View file

@ -1,5 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div style="width:275px;"><strong>Bypass Paywalls Clean <span id="version"></span></strong>
<br><a href="options.html">Options</a> | <a href="https://github.com/magnolia1234/bypass-paywalls-firefox-clean/blob/master/README.md" target=”_blank”>GitHub</a> | <strong><span id="version_new"></span></strong></div>

174
sites.js Normal file
View file

@ -0,0 +1,174 @@
var defaultSites =
{
"Adweek": "adweek.com",
"Algemeen Dagblad": "ad.nl",
"American Affairs": "americanaffairsjournal.org",
"American Banker": "americanbanker.com",
"Baltimore Sun": "baltimoresun.com",
"Barron's": "barrons.com",
"Bendigo Advertiser": "bendigoadvertiser.com.au",
"Bloomberg": "bloomberg.com",
"Bloomberg Quint (free articles only)": "bloombergquint.com",
"Business Insider": "businessinsider.com",
"Cairns Post": "cairnspost.com.au",
"Caixin Global": "caixinglobal.com",
"Central Western Daily": "centralwesterndaily.com.au",
"Challenges": "challenges.fr",
"Chemical & Engineering News": "cen.acs.org",
"Chicago Tribune": "chicagotribune.com",
"Clarín": "clarin.com",
"CommonWealth Magazine Taiwan": "cw.com.tw",
"Corriere Della Sera": "corriere.it",
"Crain's Chicago Business": "chicagobusiness.com",
"Dagblad van het Noorden": "dvhn.nl",
"Dagens Nyheter": "dn.se",
"Daily Liberal": "dailyliberal.com.au",
"Daily Press": "dailypress.com",
"Dark Reading": "darkreading.com",
"De Tijd": "tijd.be",
"DeMorgen": "demorgen.be",
"Digiday": "digiday.com",
"El Mercurio": "elmercurio.com",
"El País": "elpais.com",
"Encyclopedia Britannica": "britannica.com",
"ET Prime": "prime.economictimes.indiatimes.com",
"Exame": "exame.abril.com.br",
"Financial News": "fnlondon.com",
"Financial Times": "ft.com",
"First Things": "firstthings.com",
"Folha de S. Paulo": "folha.uol.com.br",
"Foreign Policy": "foreignpolicy.com",
"Fortune": "fortune.com",
"Glassdoor": "glassdoor.com",
"Gold Coast Bulletin": "goldcoastbulletin.com.au",
"Groene Amsterdammer": "groene.nl",
"Haaretz English": "haaretz.com",
"Haaretz": "haaretz.co.il",
"Handelsblatt": "handelsblatt.com",
"Harper's Magazine": "harpers.org",
"Hartford Courant": "courant.com",
"Harvard Business Review": "hbr.org",
"Harvard Business Review Taiwan": "hbrtaiwan.com",
"Herald Sun": "heraldsun.com.au",
"Het Financieel Dagblad": "fd.nl",
"Inc.com": "inc.com",
"Illawarra Mercury": "illawarramercury.com.au",
"Kleine Zeitung": "kleinezeitung.at",
"L'Écho": "lecho.be",
"La Nación": "lanacion.com.ar",
"La Repubblica": "repubblica.it",
"La Stampa": "lastampa.it",
"La Tercera": "latercera.com",
"Le Devoir": "ledevoir.com",
"Le Journal du Dimanche": "lejdd.fr",
"Le Monde": "lemonde.fr",
"Le Parisien": "leparisien.fr",
"Leeuwarder Courant": "lc.nl",
"Les Échos": "lesechos.fr (free articles only)",
"Libération (free articles only)": "liberation.fr",
"Loeb Classical Library": "loebclassics.com",
"London Review of Books": "lrb.co.uk",
"Los Angeles Business Journal": "labusinessjournal.com",
"Los Angeles Times": "latimes.com",
"Medium (all sites)": "medium.com",
"Mexico News Daily": "mexiconewsdaily.com",
"Miami Herald": "miamiherald.com",
"MIT Sloan Management Review": "sloanreview.mit.edu",
"MIT Technology Review": "technologyreview.com",
"Modern Healthcare": "modernhealthcare.com",
"Mountain View Voice": "mv-voice.com",
"National Post": "nationalpost.com",
"National Review": "nationalreview.com",
"New York Magazine": "nymag.com",
"New Zealand Herald": "nzherald.co.nz",
"Newcastle Herald": "newcastleherald.com.au",
"Nikkei Asian Review": "asia.nikkei.com",
"NK News": "nknews.org",
"Northern Territory News": "ntnews.com.au",
"NRC Handelsblad": "nrc.nl",
"O Estado de S. Paulo": "estadao.com.br",
"O Globo": "globo.com",
"Orange County Register": "ocregister.com",
"Orlando Sentinel": "orlandosentinel.com",
"Palo Alto Online": "paloaltoonline.com",
"Parool": "parool.nl",
"Pittsburgh Post Gazette": "post-gazette.com",
"Quartz": "qz.com",
"Quora": "quora.com",
"San Diego Union Tribune": "sandiegouniontribune.com",
"San Francisco Chronicle": "sfchronicle.com",
"Scientific American (free articles only)": "scientificamerican.com",
"Scribd (documents only)": "scribd.com",
"SOFREP": "sofrep.com",
"Statista": "statista.com",
"SunSentinel": "sun-sentinel.com",
"Tech in Asia": "techinasia.com",
"Telegraaf": "telegraaf.nl",
"The Advertiser": "adelaidenow.com.au",
"The Advocate": "theadvocate.com.au",
"The Age": "theage.com.au",
"The American Interest": "the-american-interest.com",
"The Athletic": "theathletic.com",
"The Atlantic": "theatlantic.com",
"The Australian Financial Review": "afr.com",
"The Australian": "theaustralian.com.au",
"The Border Mail": "bordermail.com.au",
"The Boston Globe": "bostonglobe.com",
"The Business Journals": "bizjournals.com",
"The Canberra Times": "canberratimes.com.au",
"The Christian Science Monitor": "csmonitor.com",
"The Courier": "thecourier.com.au",
"The Courier-Mail": "couriermail.com.au",
"The Daily Advertiser": "dailyadvertiser.com.au",
"The Daily Beast (free articles only)": "thedailybeast.com",
"The Daily Telegraph": "dailytelegraph.com.au",
"The Denver Post": "denverpost.com",
"The Diplomat": "thediplomat.com",
"The Economist": "economist.com",
"The Examiner": "examiner.com.au",
"The Globe and Mail": "theglobeandmail.com",
"The Hindu": "thehindu.com",
"The Irish Times (free articles only)": "irishtimes.com",
"The Japan Times": "japantimes.co.jp",
"The Marker": "themarker.com",
"The Mercury News": "mercurynews.com",
"The Mercury Tasmania": "themercury.com.au",
"The Morning Call": "mcall.com",
"The Nation": "thenation.com",
"The New Statesman": "newstatesman.com",
"The New York Times": "nytimes.com",
"The New Yorker": "newyorker.com",
"The News-Gazette": "news-gazette.com",
"The Northern Daily Leader": "northerndailyleader.com.au",
"The Philadelphia Inquirer": "inquirer.com",
"The Sacramento Bee (free articles only)": "sacbee.com",
"The Saturday Paper": "thesaturdaypaper.com.au",
"The Seattle Times": "seattletimes.com",
"The Spectator": "spectator.co.uk",
"The Spectator Australia": "spectator.com.au",
"The Standard": "standard.net.au",
"The Sydney Morning Herald": "smh.com.au",
"The Telegraph": "telegraph.co.uk",
"The Times": "thetimes.co.uk",
"The Times Literary Supplement": "the-tls.co.uk",
"The Toronto Star": "thestar.com",
"The Wall Street Journal": "wsj.com",
"The Washington Post": "washingtonpost.com",
"The Weekly Times": "weeklytimesnow.com.au",
"Towards Data Science": "towardsdatascience.com",
"Townsville Bulletin": "townsvillebulletin.com.au",
"Trouw": "trouw.nl",
"Valeurs Actuelles": "valeursactuelles.com",
"Vanity Fair": "vanityfair.com",
"Volkskrant": "volkskrant.nl",
"Vrij Nederland": "vn.nl",
"WAtoday": "watoday.com.au",
"Winston-Salem Journal": "journalnow.com",
"Wired": "wired.com",
"World Politics Review": "worldpoliticsreview.com",
"——— Block Paywall-scripts ———": "###",
"Outbrain": "outbrain.com",
"Poool.fr": "poool.fr",
"TinyPass": "tinypass.com",
"Piano.io": "piano.io"
}