-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbackground.html
40 lines (34 loc) · 1006 Bytes
/
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
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript" src="jquery.js"></script>
<script>
function ajax(sender, args, callback) {
args.complete = function(xhr, textStatus) {
var data = xhr.responseText;
var headers = xhr.getAllResponseHeaders();
headers = headers.split("\r\n");
headerMap = {};
for (var idx = 0; idx < headers.length; idx++) {
keyValue = headers[idx].split(': ');
if (keyValue.length == 2) {
headerMap[keyValue[0]] = keyValue[1];
} else if (keyValue.length > 2) {
headerMap[keyValue[0]] = keyValue.slice(1).join(': ');
}
}
callback({data: data, textStatus: textStatus, headers: headerMap});
};
jQuery.ajax(args);
}
function onRequest(request, sender, callback) {
if (request.action == 'ajax') {
ajax(sender, request.args, callback);
}
}
chrome.extension.onRequest.addListener(onRequest);
</script>
</body>
</html>