-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
31 lines (27 loc) · 1.09 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
document.getElementById('closeTabsButton').addEventListener('click', function () {
chrome.runtime.sendMessage({ action: 'closeTabs' });
});
document.addEventListener('DOMContentLoaded', function () {
const domainsTextarea = document.getElementById('domains');
const saveButton = document.getElementById('saveDomainsButton');
const closeButton = document.getElementById('closeTabsButton');
// Load saved domains
chrome.storage.local.get(['domains'], function (result) {
if (result.domains) {
domainsTextarea.value = result.domains.join(',');
}
});
// Save domains to local storage
saveButton.addEventListener('click', function () {
const domains = domainsTextarea.value.split(',').map(domain => domain.trim());
chrome.storage.local.set({ domains: domains }, function () {
console.log('Domains saved:', domains);
});
});
// Send message to background script to close tabs
closeButton.addEventListener('click', function () {
chrome.runtime.sendMessage({ action: 'closeTabs' }, function (response) {
console.log(response.result);
});
});
});