summaryrefslogtreecommitdiff
path: root/options.js
diff options
context:
space:
mode:
Diffstat (limited to 'options.js')
-rw-r--r--options.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/options.js b/options.js
new file mode 100644
index 0000000..aa33ea1
--- /dev/null
+++ b/options.js
@@ -0,0 +1,61 @@
+document.addEventListener('DOMContentLoaded', function() {
+ const domainInput = document.getElementById('domainInput');
+ const addDomainButton = document.getElementById('addDomainButton');
+ const domainList = document.getElementById('domainList');
+
+ // Load the current list of domains
+ browser.storage.sync.get('domains', function(data) {
+ const domains = data.domains || [];
+ if (domains.length === 0) {
+ updateDomainList(["https://gitlab.com"]);
+ } else {
+ updateDomainList(domains);
+ }
+ });
+
+ // Function to update the displayed domain list
+ function updateDomainList(domains) {
+ domainList.innerHTML = '';
+ domains.forEach(function(domain) {
+ const li = document.createElement('li');
+ li.textContent = domain;
+
+ // Add a delete button for each domain
+ const deleteButton = document.createElement('button');
+ deleteButton.textContent = 'Delete';
+ deleteButton.addEventListener('click', function() {
+ // Remove the domain and update the list
+ const updatedDomains = domains.filter(d => d !== domain);
+ browser.storage.sync.set({ 'domains': updatedDomains }, function() {
+ updateDomainList(updatedDomains);
+ });
+ });
+
+ li.appendChild(deleteButton);
+ domainList.appendChild(li);
+ });
+ }
+
+
+ // Add domain button click event
+ addDomainButton.addEventListener('click', function() {
+ const domain = domainInput.value.trim();
+
+ if (domain !== '') {
+ // Update the list of domains
+ browser.storage.sync.get('domains', function(data) {
+ const domains = data.domains || [];
+ domains.push(domain);
+
+ // Save the updated list
+ browser.storage.sync.set({ 'domains': domains }, function() {
+ // Update the displayed list
+ updateDomainList(domains);
+
+ // Clear the input field
+ domainInput.value = '';
+ });
+ });
+ }
+ });
+});