-
Notifications
You must be signed in to change notification settings - Fork 3
/
background.html
32 lines (29 loc) · 1.07 KB
/
background.html
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
<script>
var ua = "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18";
// It seems that enough of the webRequest experimental API has been
// implkemented as of 16.0.912.12 (Official Build 107048) dev;
// see the bug for the full details.
// http://crbug.com/60101
chrome.webRequest.onBeforeSendHeaders.addListener(
handleBeforeSend, {urls: ['https://*/*', "http://*/*"]}, ['blocking', 'requestHeaders']);
function handleBeforeSend(details) {
for (var i = 0; i < details.requestHeaders.length; i++) {
var header = details.requestHeaders[i];
if ('User-Agent' === header.name) {
header.value = ua;
break;
}
}
// Unfortunately, we can't just return details, because Chrome complains
// about all the extra properties in it.
return {requestHeaders: details.requestHeaders};
}
/* For debugging:
chrome.experimental.webRequest.onSendHeaders.addListener(
handleSent, {}, ['requestHeaders']);
function handleSent(details) {
console.log(details.url);
console.log(details.requestHeaders);
}
*/
</script>