2017-07-08 19:40:29 +02:00
|
|
|
var defaultSites = {
|
|
|
|
'The Age': 'theage.com.au',
|
|
|
|
'Baltimore Sun': 'baltimoresun.com',
|
2017-09-15 07:17:10 +02:00
|
|
|
'Barron\'s': 'barrons.com',
|
2017-07-08 19:40:29 +02:00
|
|
|
'Crain\'s Chicago Business': 'chicagobusiness.com',
|
|
|
|
'Chicago Tribune': 'chicagotribune.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',
|
2018-04-06 08:22:58 +02:00
|
|
|
'Dagens Nyheter': 'dn.se',
|
2017-07-08 19:40:29 +02:00
|
|
|
'The Economist': 'economist.com',
|
|
|
|
'Financial Times': 'ft.com',
|
|
|
|
'Glassdoor': 'glassdoor.com',
|
2017-09-15 07:17:10 +02:00
|
|
|
'Haaretz': 'haaretz.co.il',
|
2018-04-23 11:20:40 +02:00
|
|
|
'Haaretz English': 'haaretz.com',
|
2017-07-08 19:40:29 +02:00
|
|
|
'Hartford Courant': 'courant.com',
|
|
|
|
'Harvard Business Review': 'hbr.org',
|
2017-09-15 07:17:10 +02:00
|
|
|
'Het Financieele Dagblad': 'fd.nl',
|
2017-07-08 19:40:29 +02:00
|
|
|
'Inc.com': 'inc.com',
|
2017-09-15 07:17:10 +02:00
|
|
|
'Le Temps': 'letemps.ch',
|
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',
|
|
|
|
'Nikkei Asian Review': 'asia.nikkei.com',
|
|
|
|
'NRC': 'nrc.nl',
|
2018-01-31 06:08:11 +01:00
|
|
|
'The Boston Globe': 'bostonglobe.com',
|
|
|
|
'The Mercury News': 'mercurynews.com',
|
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',
|
|
|
|
'OrlandoSentinel': 'orlandosentinel.com',
|
|
|
|
'Quora': 'quora.com',
|
|
|
|
'SunSentinel': 'sun-sentinel.com',
|
|
|
|
'The Seattle Times': 'seattletimes.com',
|
|
|
|
'The Sydney Morning Herald': 'smh.com.au',
|
|
|
|
'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);
|
|
|
|
|