-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
20 lines (19 loc) · 851 Bytes
/
Copy pathpopup.js
File metadata and controls
20 lines (19 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
document.querySelectorAll('.checkbox').forEach(function (element) {
console.log(element)
element.addEventListener('change', function (element) {
console.log(this.name, this.checked)
sendMessage({ 'name': this.name, 'value': this.checked })
})
});
// browser.storage.local.get('popup').then(function(result) {console.log(result)})
function sendMessage(data) {
console.log("Sending message", data)
browser.tabs.query({ active: true, windowId: browser.windows.WINDOW_ID_CURRENT })
.then(tabs => browser.tabs.get(tabs[0].id))
.then(tab => {
console.log(tab)
browser.tabs.sendMessage(tab.id, data)
.then(response => { console.log("Sent",response) })
.catch(error => { console.log("Error",error) })
}).catch(err => { console.log(err) });
}