-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
34 lines (30 loc) · 1012 Bytes
/
Copy pathbackground.js
File metadata and controls
34 lines (30 loc) · 1012 Bytes
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
33
34
// Listen for clicks on the extension icon
chrome.action.onClicked.addListener((tab) => {
// Get the current tab's URL
const currentUrl = tab.url;
// Extract the origin (domain) from the URL
const urlObject = new URL(currentUrl);
const origin = urlObject.origin;
// Function to clear cookies and site data for the current website
chrome.browsingData.remove({
"origins": [origin]
}, {
"cookies": true,
"localStorage": true,
"indexedDB": true,
"cacheStorage": true,
"serviceWorkers": true,
"pluginData": true
}, function () {
// Change the extension icon to the success icon
chrome.action.setIcon({ path: "success-icon.png" });
// After 1 second, change the extension icon back to the default icon
setTimeout(function() {
chrome.action.setIcon({ path: "icon.png" });
}, 2000);
// Reload the browser after 1 second
setTimeout(function() {
chrome.tabs.reload(tab.id);
}, 1000);
});
});