-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCookieMonster.js
34 lines (32 loc) · 898 Bytes
/
CookieMonster.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
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message == "Me want cookie!") {
getCookies("https://www.oculus.com", "oc_ac_at", sendResponse);
return true;
}
});
function getCookies(domain, name, callback) {
chrome.cookies.get({ url: domain, name: name }, function (cookie) {
callback(cookie ? cookie.value : null);
});
}
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.url) {
chrome.tabs.sendMessage(
tabId,
{
message: "urlChanged",
url: changeInfo.url,
},
(response) => {
if (chrome.runtime.lastError) {
console.warn(
"Could not send message to content script:",
chrome.runtime.lastError.message,
);
} else {
console.log("Message sent successfully:", response);
}
},
);
}
});