-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
32 lines (32 loc) · 1.02 KB
/
background.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
32
chrome.browserAction.onClicked.addListener(function () {
chrome.tabs.query({ active: true, currentWindow: true }, ([currentTab]) => {
const currentDomain = currentTab.url
.replace('http://', '')
.replace('https://', '')
.split(/[/?#]/)[0];
console.log(currentDomain);
const subDomains = currentDomain.split('.');
const subDomainsLength = subDomains.length;
for (let i = subDomainsLength - 1; i >= 1; i--) {
const subDomain = '.'.concat(
subDomains.slice(subDomainsLength - 1 - i).join('.')
);
chrome.cookies.getAll({ domain: subDomain }, function (cookies) {
cookies.map(function (cookie) {
chrome.cookies.remove(
{
name: cookie.name,
url: currentTab.url,
},
function (removedCookie) {
console.log('Removed: ', removedCookie);
}
);
});
});
}
chrome.tabs.executeScript(currentTab.id, {
code: 'window.location.reload()',
});
});
});