Update options (excluded sites)
parent
299e3d22ad
commit
b0437a67e6
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Bypass Paywalls Clean Options Excluded</title>
|
||||
<style>
|
||||
#excluded_sites label {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
font-size: 100%;
|
||||
}
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Excluded Sites</h2>
|
||||
<div style="width:90%;">
|
||||
Add excluded sites/domains (for your subscriptions) as a comma-separated list (www.-prefix and spaces are removed).<br>
|
||||
You can also exclude a specific domain which is grouped in options.<br>
|
||||
Checked sites in options are ignored (to still enable select all).<br>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
<div style="width:90%;">
|
||||
<h3>Sites</h3>
|
||||
</div>
|
||||
<br>
|
||||
<div id='excluded_sites'></div>
|
||||
<br>
|
||||
<div id="status"></div>
|
||||
<div id="error"></div>
|
||||
<span style='float:left;padding-bottom:50px'>
|
||||
<button id="save">Save</button>
|
||||
<button id="sort">Sort</button>
|
||||
<button><a href="options.html" style="text-decoration:none;color:inherit">Options</a></button>
|
||||
</span>
|
||||
|
||||
<script src="options_excluded.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,52 @@
|
||||
var ext_api = chrome || browser;
|
||||
|
||||
// Saves options to ext_api.storage
|
||||
function save_options() {
|
||||
var textareaEl = document.querySelector('#excluded_sites textarea');
|
||||
var sites_excluded = [];
|
||||
if (textareaEl.value !== '')
|
||||
var sites_excluded = textareaEl.value.split(',').map(function(item) { return item.trim().replace('www.', ''); });
|
||||
ext_api.storage.local.set({
|
||||
sites_excluded: sites_excluded
|
||||
}, function () {
|
||||
// Update status to let user know excluded sites were saved.
|
||||
var status = document.getElementById('status');
|
||||
status.textContent = 'Excluded sites saved.';
|
||||
});
|
||||
}
|
||||
|
||||
// Sort json by key in textarea
|
||||
function sort_options() {
|
||||
var textareaEl = document.querySelector('#excluded_sites textarea');
|
||||
var sites_excluded = [];
|
||||
if (textareaEl.value !== '') {
|
||||
var sites_excluded = textareaEl.value.split(',').map(function(item) { return item.trim().replace('www.', ''); });
|
||||
var sites_excluded_sorted = sites_excluded.sort();
|
||||
textareaEl.value = sites_excluded_sorted.join();
|
||||
}
|
||||
// Update status to let user know excluded sites were sorted.
|
||||
var status = document.getElementById('status');
|
||||
status.textContent = 'Excluded sites sorted (not saved yet)';
|
||||
}
|
||||
|
||||
function renderOptions() {
|
||||
ext_api.storage.local.get({
|
||||
sites_excluded: []
|
||||
}, function (items) {
|
||||
var sites_excluded = items.sites_excluded;
|
||||
var sitesEl = document.getElementById('excluded_sites');
|
||||
sitesEl.innerHTML = '';
|
||||
var labelEl = document.createElement('label');
|
||||
var textareaEl = document.createElement('textarea');
|
||||
textareaEl.placeholder = 'example1.com,example2.com';
|
||||
textareaEl.value = sites_excluded.join();
|
||||
textareaEl.rows = 12;
|
||||
textareaEl.cols = 40;
|
||||
labelEl.appendChild(textareaEl);
|
||||
sitesEl.appendChild(labelEl);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', renderOptions);
|
||||
document.getElementById('save').addEventListener('click', save_options);
|
||||
document.getElementById('sort').addEventListener('click', sort_options);
|
Loading…
Reference in New Issue