-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
42 lines (40 loc) · 1.27 KB
/
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
37
38
39
40
41
42
/*chrome.webRequest.onBeforeSendHeaders.addListener(function(details) {
var newVal = "BlueDroid/2.3";
var changed = false;
for (var i = 0; i < details.requestHeaders.length; ++i) {
//details.requestHeaders.splice(i, 1);
if (details.requestHeaders[i].name === 'User-Agent') {
details.requestHeaders[i].value = newVal;
changed = true;
}
break;
}
if (!changed) {
details.requestHeaders.push({name: "User-Agent", value: newVal});
}
return {requestHeaders: details.requestHeaders};
}, {urls: ["*://forum.dalton.org/*"]}, ["blocking", "requestHeaders"]);*/
chrome.webRequest.onBeforeSendHeaders.addListener(
function(info) {
console.log("asdf");
// Replace the User-Agent header
var headers = info.requestHeaders;
headers.forEach(function(header, i) {
if (header.name.toLowerCase() == 'user-agent') {
header.value = 'BlueDroid/1.3';
}
});
return {requestHeaders: headers};
},
// Request filter
{
// Modify the headers for these pages
urls: [
"http://forum.dalton.org/*",
"https://forum.dalton.org/*"
],
// In the main window and frames
types: ["xmlhttprequest"]
},
["blocking", "requestHeaders"]
);