Created
May 8, 2011 15:39
-
-
Save ReSTARTR/961440 to your computer and use it in GitHub Desktop.
chrome notification snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function() { | |
var def_notification_timeout=5000; | |
var def_username = 'yoshida'; | |
function show(msg) { | |
var noti = webkitNotifications.createNotification( | |
'icon.png', | |
'From: my notification', | |
msg | |
); | |
noti.show(); | |
setTimeout(function() { | |
noti.cancel(); | |
}, def_notification_timeout); | |
} | |
// 接続時に自分のIDを入力させることで、全体へのメッセージブロードキャストを防ぐ | |
var ws = null; | |
function connect() { | |
ws=new WebSocket("ws://localhost:8080/tw/?id=" + def_username); | |
} | |
connect(); | |
ws.onopen = function(e){show('connected: as @' + def_username);}; | |
ws.onclose = function(e){connect();}; | |
ws.onerror = function(e){show('error!');}; | |
ws.onmessage = function(e) { | |
show(e.data); | |
}; | |
var noti = webkitNotifications.createHTMLNotification('test.html') | |
noti.show(); | |
})(); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "My First Extension", | |
"version": "1.0", | |
"description": "the first extention that I made", | |
"browser_action": { | |
"default_icon": "icon.png" | |
}, | |
"permissions": ["notifications"], | |
"background_page": "background.html" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body id="test" onload=""> | |
<h1>this is test</h1> | |
<h2>sample text is here.</h2> | |
<p><p> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment