diff --git a/options_custom.html b/options_custom.html index 2cbd44a..f0a7f2f 100644 --- a/options_custom.html +++ b/options_custom.html @@ -16,7 +16,7 @@

Custom Sites

- To add new site, enter a unique title/domain (without www.) and select options for Googlebot/block Javascript (block on (sub)domain(s) of site and/or external domains).
+ To add a new site, enter an unique title/domain (without www.) and select options for Googlebot/block Javascript (block on (sub)domain(s) of site and/or external domains).
Custom sites are enabled automatically in options (cookies will be removed by default).

@@ -36,6 +36,7 @@
+
diff --git a/options_custom.js b/options_custom.js index 7e33575..591c769 100644 --- a/options_custom.js +++ b/options_custom.js @@ -160,6 +160,26 @@ function delete_options() { }); } +// Edit custom site (copy to add) +function edit_options() { + var selectEl = document.querySelector('#custom_sites select'); + var sites_custom = {}; + var title = selectEl.value; + + // copy site to add-fields + ext_api.storage.sync.get({ + sites_custom: {} + }, function (items) { + sites_custom = items.sites_custom; + var edit_site = sites_custom[title]; + document.querySelector('input[data-key="title"]').value = title; + document.querySelector('input[data-key="domain"]').value = edit_site.domain; + document.querySelector('input[data-key="googlebot"]').checked = (edit_site.googlebot > 0); + document.querySelector('input[data-key="block_javascript"]').checked = (edit_site.block_javascript > 0); + document.querySelector('input[data-key="block_javascript_ext"]').checked = (edit_site.block_javascript_ext > 0); + }); +} + // Restores checkbox input states using the preferences stored in ext_api.storage. function renderOptions() { ext_api.storage.sync.get({ @@ -233,4 +253,5 @@ document.getElementById('export').addEventListener('click', export_options); document.getElementById('import').onclick = function () {importInput.click()} document.getElementById('importInput').addEventListener("change", import_options, false); document.getElementById('add').addEventListener('click', add_options); -document.getElementById('delete').addEventListener('click', delete_options); \ No newline at end of file +document.getElementById('delete').addEventListener('click', delete_options); +document.getElementById('edit').addEventListener('click', edit_options); \ No newline at end of file