summaryrefslogtreecommitdiff
path: root/backend/instance/nocookies/data/options.js
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-02-17 22:39:42 +0100
committeraura <nw@moneybot.cc>2026-02-17 22:39:42 +0100
commit636b0323075225c584b62719ed51e75521bb7ffb (patch)
tree61b02271b6d0695a4beffc23fb6eb062a7da22c3 /backend/instance/nocookies/data/options.js
push source
Diffstat (limited to 'backend/instance/nocookies/data/options.js')
-rw-r--r--backend/instance/nocookies/data/options.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/backend/instance/nocookies/data/options.js b/backend/instance/nocookies/data/options.js
new file mode 100644
index 0000000..56d04d8
--- /dev/null
+++ b/backend/instance/nocookies/data/options.js
@@ -0,0 +1,38 @@
+function save_options()
+{
+ var whitelist = document.getElementById('whitelist').value.split("\n"),
+ whitelisted_domains = {};
+
+ whitelist.forEach(function(line){
+ line = line.trim().replace(/^\w*\:?\/+/i, '').replace(/^w{2,3}\d*\./i, '').split('/')[0].split(':')[0];
+
+ if (line.length > 0 && line.length < 100)
+ whitelisted_domains[line] = true;
+ });
+
+ chrome.storage.local.set({whitelisted_domains:whitelisted_domains}, function(){
+ document.getElementById('status_saved').style.display = 'inline';
+
+ setTimeout(function() {
+ document.getElementById('status_saved').style.display = 'none';
+ }, 2000);
+
+ chrome.runtime.sendMessage('update_whitelist');
+ });
+}
+
+function restore_options() {
+ chrome.storage.local.get({
+ whitelisted_domains: {}
+ }, function(items) {
+ document.getElementById('whitelist').value = Object.keys(items.whitelisted_domains).sort().join("\n");
+ });
+}
+
+document.title = document.getElementById('title').textContent = chrome.i18n.getMessage("optionsTitle") + ' - ' + chrome.i18n.getMessage("extensionName");
+document.getElementById('whitelist_label').textContent = chrome.i18n.getMessage("optionsWhitelist");
+document.getElementById('save').setAttribute('value', chrome.i18n.getMessage("optionsButton"));
+document.getElementById('status_saved').textContent = chrome.i18n.getMessage("optionsSaved");
+
+document.addEventListener('DOMContentLoaded', restore_options);
+document.getElementById('save').addEventListener('click', save_options); \ No newline at end of file