forked from sanooj/Campfire-Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.html
More file actions
60 lines (49 loc) · 1.88 KB
/
Copy pathbackground.html
File metadata and controls
60 lines (49 loc) · 1.88 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
<html>
<head>
<script>
// Called when the user clicks on the browser action.
//chrome.browserAction.onClicked.addListener(function(tab) {
// chrome.tabs.executeScript(
// null, {code:"document.getElementById('message_419252248').style.background='red !important'"});
// });
//
// /*chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
// if(changeInfo.status == "loading"){
// chrome.tabs.executeScript(tabId, { code: "alert('Hello World')" });
// }
// });
// */
// // Bubble Value - Message Count
// chrome.browserAction.setBadgeBackgroundColor({color:[250, 0, 0, 100]});
//
// var msg = 5;
// if(msg >= 0)
// { chrome.browserAction.setBadgeText({text:String(msg)});
// }
// var greeting = "hola, ";
// var button = document.getElementById("message_419252248");
// button.person_name = "Roberto";
// button.addEventListener("click", function() {
// alert(greeting + button.person_name + ".");
// }, false);
</script>
<script>
function onRequest(request, sender, callback) {
if (request.action == 'passContent') {
var msg = request.chatCount;
chrome.browserAction.setBadgeBackgroundColor({color:[250, 0, 0, 100]});
chrome.browserAction.setBadgeText({text:String(msg)});
var notification = webkitNotifications.createNotification(
'icons/icon128.png', // icon url - can be relative
request.person, // notification title
request.search // notification body text
);
notification.show(); // show notification
setTimeout( function() { notification.cancel()}, 10000 ); // notification hiding withing 10 sec
}
};
chrome.extension.onRequest.addListener(onRequest);
//chrome.tabs.get(integer tabId, function callback)
</script>
</head>
</html>