-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.html
24 lines (24 loc) · 974 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
<html>
<script>
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if (request.method == "getKey") {
sendResponse({key: localStorage.securekey});
} else if (request.method == "setKey") {
localStorage.securekey = request.key;
sendResponse({});
} else if (request.method == "postUpdate") {
var params = "key=" + request.key
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://die2nite.gamerz.org.uk/plugin", true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
sendResponse({text: xhr.responseText});
}
}
xhr.send(params);
}
});
</script>
</html>