-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
36 lines (28 loc) · 978 Bytes
/
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
33
34
35
36
var count = 0;
chrome.cookies.getAll({},function(cookies){
count=cookies.length;
document.getElementById("cookie-counter").innerHTML = count;
});
// document.addEventListener('DOMContentLoaded', function() {
// document.getElementById('clear-cookies').addEventListener('click', clearAllCookies);
// });
function clearAllCookies(){
console.log("cookies cleared");
chrome.cookies.getAll({}, function(cookies) {
for (var i in cookies) {
removeCookie(cookies[i]);
}
});
}
function removeCookie(cookie) {
var url = "http" + (cookie.secure ? "s" : "") + "://" + cookie.domain +
cookie.path;
chrome.cookies.remove({"url": url, "name": cookie.name});
}
document.addEventListener('DOMContentLoaded', function() {
var link = document.getElementById('clear-cookies');
// onClick's logic below:
link.addEventListener('click', function() {
clearAllCookies();
});
});