bypass-paywalls-firefox-clean/options.js

177 lines
5.9 KiB
JavaScript
Raw Normal View History

2017-07-08 19:40:29 +02:00
var defaultSites = {
'Algemeen Dagblad': 'ad.nl',
2017-07-08 19:40:29 +02:00
'Baltimore Sun': 'baltimoresun.com',
'Barron\'s': 'barrons.com',
2018-05-06 02:53:07 +02:00
'Bloomberg': 'bloomberg.com',
2019-10-06 19:28:35 +02:00
'Bloomberg Quint': 'bloombergquint.com',
2018-07-08 00:11:09 +02:00
'Business Insider': 'businessinsider.com',
'Caixin Global': 'caixinglobal.com',
2019-01-05 20:39:45 +01:00
'Chemical & Engineering News': 'cen.acs.org',
2017-07-08 19:40:29 +02:00
'Chicago Tribune': 'chicagotribune.com',
'Central Western Daily': 'centralwesterndaily.com.au',
'Crain\'s Chicago Business': 'chicagobusiness.com',
2018-04-06 08:22:58 +02:00
'Corriere Della Sera': 'corriere.it',
2017-07-08 19:40:29 +02:00
'Daily Press': 'dailypress.com',
'DeMorgen': 'demorgen.be',
2018-07-05 03:46:28 +02:00
'Denver Post': 'denverpost.com',
'De Groene Amsterdammer': 'groene.nl',
'De Tijd': 'tijd.be',
'de Volkskrant': 'volkskrant.nl',
2019-12-08 06:50:00 +01:00
'ET Prime': 'prime.economictimes.indiatimes.com',
'The Economist': 'economist.com',
'Eindhovens Dagblad': 'ed.nl',
2018-10-02 04:03:00 +02:00
'Examiner': 'examiner.com.au',
2017-07-08 19:40:29 +02:00
'Financial Times': 'ft.com',
'Foreign Policy': 'foreignpolicy.com',
2017-07-08 19:40:29 +02:00
'Glassdoor': 'glassdoor.com',
'Haaretz': 'haaretz.co.il',
2018-04-23 11:20:40 +02:00
'Haaretz English': 'haaretz.com',
'Handelsblatt': 'handelsblatt.com',
'Harper\'s Magazine': 'harpers.org',
2017-07-08 19:40:29 +02:00
'Hartford Courant': 'courant.com',
'Harvard Business Review': 'hbr.org',
'Inc.com': 'inc.com',
2019-03-10 21:03:53 +01:00
'Investors Chronicle': 'investorschronicle.co.uk',
2018-12-06 22:23:04 +01:00
'La Repubblica': 'repubblica.it',
'Le Monde': 'lemonde.fr',
'Le Parisien': 'leparisien.fr',
'Le Temps': 'letemps.ch',
'Les Echos': 'lesechos.fr',
'London Review of Books': 'lrb.co.uk',
2017-07-08 19:40:29 +02:00
'Los Angeles Times': 'latimes.com',
2018-01-31 06:08:11 +01:00
'Medium': 'medium.com',
2017-07-08 19:40:29 +02:00
'Medscape': 'medscape.com',
'MIT Technology Review': 'technologyreview.com',
2018-10-29 05:44:18 +01:00
'Mountain View Voice': 'mv-voice.com',
'National Post': 'nationalpost.com',
'New Statesman (javascript disabled)': 'newstatesman.com',
2019-02-19 02:25:35 +01:00
'New York Magazine': 'nymag.com',
2019-06-27 05:26:30 +02:00
'New Zealand Herald': 'nzherald.co.nz',
2020-01-05 16:48:54 +01:00
'Newcastle Herald': 'newcastleherald.com.au',
2017-07-08 19:40:29 +02:00
'Nikkei Asian Review': 'asia.nikkei.com',
2019-12-07 22:26:58 +01:00
'NK News': 'nknews.org',
2017-07-08 19:40:29 +02:00
'NRC': 'nrc.nl',
2018-10-29 05:44:18 +01:00
'Orange County Register': 'ocregister.com',
'Orlando Sentinel': 'orlandosentinel.com',
'Palo Alto Online': 'paloaltoonline.com',
'Parool': 'parool.nl',
2019-09-30 03:18:59 +02:00
'Quartz': 'qz.com',
2018-10-29 05:44:18 +01:00
'Quora': 'quora.com',
2019-11-01 18:40:39 +01:00
'Scientific American': 'scientificamerican.com',
2020-01-05 17:41:06 +01:00
'Scribd (documents only)': 'scribd.com',
2019-07-11 19:48:40 +02:00
'Statista': 'statista.com',
2018-10-29 05:44:18 +01:00
'SunSentinel': 'sun-sentinel.com',
2020-01-05 16:31:22 +01:00
'Tech in Asia': 'techinasia.com',
'Telegraaf': 'telegraaf.nl',
2018-10-02 04:03:00 +02:00
'The Advocate': 'theadvocate.com.au',
'The Age': 'theage.com.au',
2020-01-05 13:02:44 +01:00
'The Athletic': 'theathletic.com',
2019-09-30 02:47:26 +02:00
'The Atlantic': 'theatlantic.com',
'The Australian': 'theaustralian.com.au',
2019-09-30 02:34:16 +02:00
'The Australian Financial Review (javascript disabled)': 'afr.com',
'The Boston Globe': 'bostonglobe.com',
2018-06-30 21:48:40 +02:00
'The Business Journals': 'bizjournals.com',
2019-05-13 01:40:27 +02:00
'The Diplomat': 'thediplomat.com',
'The Globe and Mail': 'theglobeandmail.com',
2019-11-02 12:20:28 +01:00
'The Hindu': 'thehindu.com',
2018-09-09 22:21:36 +02:00
'The Japan Times': 'japantimes.co.jp',
2018-10-29 05:44:18 +01:00
'TheMarker': 'themarker.com',
2018-01-31 06:08:11 +01:00
'The Mercury News': 'mercurynews.com',
2019-11-01 02:31:54 +01:00
'The Mercury Tasmania': 'themercury.com.au',
2017-07-08 19:40:29 +02:00
'The Morning Call': 'mcall.com',
'The Nation': 'thenation.com',
'The New York Times': 'nytimes.com',
'The New Yorker': 'newyorker.com',
2019-01-05 20:39:45 +01:00
'The News-Gazette': 'news-gazette.com',
'The Philadelphia Inquirer': 'inquirer.com',
'The Saturday Paper': 'thesaturdaypaper.com.au',
2018-07-23 04:04:27 +02:00
'The Spectator': 'spectator.co.uk',
2017-07-08 19:40:29 +02:00
'The Seattle Times': 'seattletimes.com',
'The Sydney Morning Herald': 'smh.com.au',
'The Telegraph': 'telegraph.co.uk',
'The Times': 'thetimes.co.uk',
2020-01-05 17:08:07 +01:00
'The Toronto Star': 'thestar.com',
2017-07-08 19:40:29 +02:00
'The Washington Post': 'washingtonpost.com',
2018-06-03 20:23:04 +02:00
'The Wall Street Journal': 'wsj.com',
2019-12-05 21:32:20 +01:00
'Times Literary Supplement': 'the-tls.co.uk',
'Towards Data Science': 'towardsdatascience.com',
'Trouw': 'trouw.nl',
'Vanity Fair': 'vanityfair.com',
'Vrij Nederland': 'vn.nl',
2018-10-02 04:03:00 +02:00
'Wired': 'wired.com'
2017-07-08 19:40:29 +02:00
};
// 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');
2018-10-07 07:18:34 +02:00
status.textContent = 'Options saved.';
2017-07-08 19:40:29 +02:00
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) || (key.replace(/\s\(.*\)/, '') in sites);
2017-07-08 19:40:29 +02:00
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);