-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbg.js
27 lines (21 loc) · 744 Bytes
/
bg.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
var background = chrome.extension.getBackgroundPage();
localStorage.setItem('goTime', false);
function initPage() {
var requestListener = function(details) {
if (details.type !== 'main_frame' || localStorage.getItem('goTime') === 'false') {
return;
}
for (var i = 0; i < details.requestHeaders.length; ++i) {
if (details.requestHeaders[i].name === 'Cookie') {
details.requestHeaders[i].value = localStorage.getItem('cookies');
break;
}
}
localStorage.setItem('goTime', false);
return {requestHeaders: details.requestHeaders}
};
chrome.webRequest.onBeforeSendHeaders.addListener(requestListener, {
urls: ["<all_urls>"]
}, ["requestHeaders", "blocking"]);
}
initPage();