-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
36 lines (32 loc) · 1.13 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
//define function
function changeMIME() {
var listener = function(details) {
var headers = details.responseHeaders;
var hasChangeMime = false;
//do replace "text/vnd.wap.wml" with "text/html"
headers.forEach(function(head) {
if (head && head.name.toLowerCase() == "content-type" && head.value.toLowerCase().substring(0, 16) == "text/vnd.wap.wml") {
head.value = "text/html";
hasChangeMime = true
}
});
//prevent the wml source being downloaded
if (hasChangeMime) {
headers.forEach(function(head) {
if (head.name.toLowerCase() == "content-disposition") {
head.value = "inline"
}
});
}
return { responseHeaders: headers };
};
var c = chrome.webRequest != undefined ? chrome.webRequest.onHeadersReceived: null;
if (c != null) {
c.addListener(listener, {
urls: ["http://*/*", "https://*/*"]
},
["blocking", "responseHeaders"])
}
};
//start change
changeMIME();