forked from ghyghoo8/ADclearer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
26 lines (25 loc) · 816 Bytes
/
background.js
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
chrome.extension.onConnect.addListener(function (port) {
var msgName = port.name;
console.log("msgName:" + msgName);
port.onMessage.addListener(function (msg) {
switch (msgName) {
case 'notification':
notification(msg);
break;
default:
break;
}
});
});
function notification(msg) {
if (!msg.body||msg.body=="nothing here")return false;
var note = webkitNotifications.createNotification(
msg.icon || 'http://botaoenergy-wordpress.stor.sinaapp.com/uploads/icon48.png', // icon url - can be relative
msg.title || 'ADclearer running...', // notification title
msg.body // notification body text
);
note.show();
setTimeout(function(){
note.cancel();
},2000);
}