-
Notifications
You must be signed in to change notification settings - Fork 3
/
grab_cookie.js
35 lines (34 loc) · 1.52 KB
/
grab_cookie.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
function exportCookies() {
chrome.tabs.query({"status":"complete","windowId":chrome.windows.WINDOW_ID_CURRENT,"active":true}, function(tab){
chrome.cookies.getAll({
domain: undefined
}, function (cookies) {
domain = ""; flag = ""; path = "";
secure = ""; expiration = ""; name = ""
value = ""; tab="\t";
return_block= "# Netscape HTTP Cookie File\n# This file was generated by the export-cookies Chrome extension.\n";
for (var i = 0; i < cookies.length; i++) {
domain=cookies[i].domain;
cookies[i].sameSite == "strict" ? flag="FALSE":flag="TRUE";
cookies[i].secure ? secure="TRUE":secure="FALSE";
if (!cookies[i].expirationDate) {
expiration=Math.floor(Date.now() / 1000) + 600;
} else {
expiration=parseInt(cookies[i].expirationDate, 10)
};
name=cookies[i].name;
value = cookies[i].value;
line=domain + tab + flag + tab + path + tab + secure + tab + expiration + tab + name + tab + value + "\n";
return_block = return_block + line;
}
chrome.storage.local.get(null, function() {
url = 'data:text;base64,' + btoa(return_block);
chrome.downloads.download({
url: url,
filename: 'cookies.txt'
});
});
});
});
};
exportCookies();