-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
27 lines (25 loc) · 775 Bytes
/
main.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
// stores the url in the block-list
storeUrl = (url) => {
if (!url || url.trim().length === 0 || url === "https://i.imgur.com" || !url.startsWith("https://")) {
return;
}
chrome.storage.sync.set({
[url]: url
}, () => {
window.close();
});
};
// adds current tab's url (origin) in block-list
document.querySelector("#add-to-blocklist").onclick = () => {
chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => {
storeUrl(new URL(tabs[0].url).origin);
});
}
// opens block-list
document.querySelector('#go-to-options').onclick = () => {
if (chrome.runtime.openOptionsPage) {
chrome.runtime.openOptionsPage();
} else {
window.open(chrome.runtime.getURL('options.html'));
}
}