-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.html
More file actions
63 lines (55 loc) · 1.66 KB
/
background.html
File metadata and controls
63 lines (55 loc) · 1.66 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<html>
<head>
<script>
var pollInterval = 1000*60; //10 min
var requestTimeout = 1000*2; //5 sec
var InboxUrl = "http://forum.searchengines.ru/private.php";
var requestTimerId;
var unread_count = "?";
function init() {
canvas = document.getElementById('canvas');
loggedInImage = document.getElementById('logged_in');
canvasContext = canvas.getContext('2d');
chrome.browserAction.setBadgeBackgroundColor({color:[208, 0, 24, 255]});
chrome.browserAction.setIcon({path: "unread_icon.png"});
getInboxcount();
setInterval(function() {
getInboxcount();
}, 600000);
}
function getInboxcount() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', 'http://forum.searchengines.ru/pmunread.php', true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if(xmlhttp.status == 200 && xmlhttp.responseText != "") {
unread_count = xmlhttp.responseText;
}
if (unread_count == "0") {
unread_count = "";
};
chrome.browserAction.setBadgeText ({text: unread_count});
}
};
xmlhttp.send(null);
}
function goToInbox() {
// chrome.tabs.getAllInWindow(undefined, function(tabs) {
// for (var i = 0, tab; tab = tabs[i]; i++) {
// if (tab.url && InboxUrl) {
// chrome.tabs.update(tab.id, {selected: true});
// return;
// }
// }
chrome.tabs.create( {url: "http://forum.searchengines.ru/private.php"});
}
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
goToInbox();
});
</script>
</head>
<body onload="init()">
<img id="logged_in" src="unread_icon.png">
<canvas id="canvas" width="16" height="16">
</body>