-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.html
41 lines (38 loc) · 1.12 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
33
34
35
36
37
38
39
40
41
<html>
<head>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript" src="util.js"></script>
<script type="text/javascript">
var defaultOptions = "{\"notiInterval\":\"1\"}";
// Start
update();
// Functions
function update() {
var t = new Date().getTime();
$.ajax({
url: "http://www.zhihu.com/_notification/new" + "?" + t,
type: "get",
async: false,
dataType: "json",
success: function (data) {
if (data) {
var notification = data[1];
var count = notification[0];
if (count > 0) {
chrome.browserAction.setBadgeText({ text: String(count) });
}
else
{
chrome.browserAction.setBadgeText({ text: String() });
}
}
}
});
var options = JSON.parse(getLocalStorageVal('options', defaultOptions));
var delayMins = options.notiInterval ? options.notiInterval : 1;
setTimeout(update, delayMins * 60 * 1000);
}
</script>
</head>
</html>