163 lines
5.4 KiB
JavaScript
Raw Normal View History

2017-07-08 14:16:27 -07:00
var defaultSites = {
'Algemeen Dagblad': 'ad.nl',
2019-09-26 23:15:04 +02:00
'American Banker': 'americanbanker.com',
2017-07-08 14:16:27 -07:00
'Baltimore Sun': 'baltimoresun.com',
'Barron\'s': 'barrons.com',
2018-05-05 19:08:25 +10:00
'Bloomberg': 'bloomberg.com',
'Business Insider (javascript disabled)': 'businessinsider.com',
2017-07-08 14:16:27 -07:00
'Crain\'s Chicago Business': 'chicagobusiness.com',
'Chicago Tribune': 'chicagotribune.com',
2018-04-05 23:34:36 -07:00
'Corriere Della Sera': 'corriere.it',
2017-07-08 14:16:27 -07:00
'Daily Press': 'dailypress.com',
2018-04-05 23:34:36 -07:00
'Dagens Nyheter': 'dn.se',
'De Groene Amsterdammer': 'groene.nl',
'De Volkskrant': 'volkskrant.nl',
2019-05-25 14:41:10 -07:00
'DeMorgen': 'demorgen.be',
2018-07-04 18:02:08 -07:00
'Denver Post': 'denverpost.com',
'Dynamed Plus': 'dynamed.com',
'The Economist (javascript disabled)': 'economist.com',
2019-03-20 19:03:37 -07:00
'Encyclopedia Britannica': 'britannica.com',
2019-06-02 13:38:20 +02:00
'Eindhovens Dagblad': 'ed.nl',
2018-10-02 12:18:18 +10:00
'Examiner': 'examiner.com.au',
2019-09-23 21:21:21 +03:00
'First Things': 'firstthings.com',
'Financial News': 'fnlondon.com',
2017-07-08 14:16:27 -07:00
'Financial Times': 'ft.com',
'Foreign Policy': 'foreignpolicy.com',
2017-07-08 14:16:27 -07:00
'Glassdoor': 'glassdoor.com',
'Haaretz': 'haaretz.co.il',
2018-04-23 12:21:18 +03:00
'Haaretz English': 'haaretz.com',
2019-01-04 19:32:34 +01:00
'Harper\'s Mag': 'harpers.org',
2017-07-08 14:16:27 -07:00
'Hartford Courant': 'courant.com',
'Harvard Business Review': 'hbr.org',
'Inc.com': 'inc.com',
2019-03-10 14:15:18 -07:00
'Irish Times': 'irishtimes.com',
2018-12-07 13:43:16 +01:00
'La Repubblica': 'repubblica.it',
'Les Echos': 'lesechos.fr',
'Liberation': 'liberation.fr',
2017-07-08 14:16:27 -07:00
'Los Angeles Times': 'latimes.com',
2018-01-30 21:26:21 -08:00
'Medium': 'medium.com',
2019-09-17 18:37:32 +03:00
'Mexico News Daily': 'mexiconewsdaily.com',
2019-06-21 20:42:35 -07:00
'MIT Sloan Management Review': 'sloanreview.mit.edu',
2017-07-08 14:16:27 -07:00
'MIT Technology Review': 'technologyreview.com',
2019-02-17 13:43:21 -08:00
'Newsrep': 'thenewsrep.com',
'New York Magazine': 'nymag.com',
2017-07-08 14:16:27 -07:00
'Nikkei Asian Review': 'asia.nikkei.com',
'NRC': 'nrc.nl',
2019-09-22 17:10:17 -07:00
'New Zealand Herald': 'nzherald.co.nz',
2018-08-26 10:03:12 +10:00
'OrlandoSentinel': 'orlandosentinel.com',
'Parool': 'parool.nl',
2019-05-25 14:25:56 -07:00
'Quartz': 'qz.com',
2018-08-26 10:03:12 +10:00
'Quora': 'quora.com',
'San Francisco Chronicle': 'sfchronicle.com',
2019-04-28 13:43:51 -07:00
'Scientific American': 'scientificamerican.com',
2019-07-04 12:39:49 -08:00
'Statista': 'statista.com',
2018-08-26 10:03:12 +10:00
'SunSentinel': 'sun-sentinel.com',
2019-06-02 13:33:52 +02:00
'Telegraaf': 'telegraaf.nl',
2018-10-02 12:17:55 +10:00
'The Advocate': 'theadvocate.com.au',
'The Age': 'theage.com.au',
2019-09-16 21:07:04 +03:00
'The American Interest': 'the-american-interest.com',
2019-09-18 11:02:56 +02:00
'The Atlantic': 'theatlantic.com',
'The Australian': 'theaustralian.com.au',
'The Australian Financial Review (javascript disabled)': 'afr.com',
2019-09-22 16:50:24 -07:00
'The Boston Globe (javascript disabled)': 'bostonglobe.com',
'The Business Journals (javascript disabled)': 'bizjournals.com',
'The Globe and Mail (javascript disabled)': 'theglobeandmail.com',
2019-03-20 18:55:00 -07:00
'The Japan Times': 'japantimes.co.jp',
'TheMarker': 'themarker.com',
2018-01-30 21:26:21 -08:00
'The Mercury News': 'mercurynews.com',
2017-07-08 14:16:27 -07:00
'The Morning Call': 'mcall.com',
'The Nation': 'thenation.com',
'The News-Gazette': 'news-gazette.com',
2018-08-26 09:59:06 +10:00
'The New Statesman': 'newstatesman.com',
2017-07-08 14:16:27 -07:00
'The New York Times': 'nytimes.com',
'The New Yorker': 'newyorker.com',
'The Seattle Times': 'seattletimes.com',
2018-08-26 10:00:48 +10:00
'The Spectator': 'spectator.co.uk',
2017-07-08 14:16:27 -07:00
'The Sydney Morning Herald': 'smh.com.au',
2019-06-21 20:42:35 -07:00
'The Telegraph': 'telegraph.co.uk',
2019-09-22 17:03:15 -07:00
'The Times': 'thetimes.co.uk',
'The Toronto Star (javascript disabled)': 'thestar.com',
2017-07-08 14:16:27 -07:00
'The Washington Post': 'washingtonpost.com',
2018-06-08 17:14:57 -04:00
'The Wall Street Journal': 'wsj.com',
'Trouw': 'trouw.nl',
'Winston-Salem Journal': 'journalnow.com',
'Vanity Fair': 'vanityfair.com',
'Vrij Nederland': 'vn.nl',
2019-06-21 20:53:21 -07:00
'Wired': 'wired.com',
'Zeit Online': 'zeit.de'
2017-07-08 14:16:27 -07:00
};
// Saves options to chrome.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;
}, {});
chrome.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();
}, 800);
});
}
// Restores checkbox input states using the preferences
// stored in chrome.storage.
function renderOptions() {
chrome.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);