-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
27 lines (27 loc) · 1000 Bytes
/
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
async function getCurrentTab() {
let queryOptions = { active: true, currentWindow: true };
let [tab] = await chrome.tabs.query(queryOptions);
return tab;
}
document.addEventListener('DOMContentLoaded', function() {
getCurrentTab()
.then(value => {
let url = value.url;
let domain = (new URL(url));
var hostname = domain.hostname;
chrome.storage.sync.get(["toggled"], function(result) {
res = result.toggled;
chrome.storage.sync.set({ "toggled": !res }, function() {
chrome.tabs.query({}, function(tabs) {
for (var o = 0; o < tabs.length; o++) {
chrome.tabs.update(tabs[o].id, { url: tabs[o].url });
}
})
window.close();
})
});
})
.catch(err => {
console.log(err);
});
})