ノティフィケーション | 春菊のブログ

春菊のブログ

ブログの説明を入力します。

参照元:http://dev.classmethod.jp/ria/google-chrome-extension-6/

Chromeの拡張機能エクステンション
ノティフィケーションを作りたかったとき。
(画面の右下から出てくる奴)

内容としてはツールバーボタンをクリックしたら、
ノティフィケーションが出る仕様らしい。

↓manifest.jso


{
"name": "NotificationSample",
"version": "1.0",
"background_page": "background.html",
"permissions": [
"notifications"
],
"browser_action": {
"default_icon": "icon_128.png",
"name": "Notification"
}
}

「permissionsに”notifications”を指定」
とのこと


webkitNotifications.createNotification({表示するアイコンのパス}, {タイトル}, {メッセージ});

これをhtml形式で作ってやって数値をそれぞれ代入していくと…


<html>
<head>
<script>
chrome.browserAction.onClicked.addListener(
function(tab){
var notification = webkitNotifications.createNotification(
chrome.extension.getURL("icon_128.png"), "クリック!!", "ツールバーボタンがクリックされました。");
notification.show();
}
);
</script>
</head>
</html>


これを.htmlで保存して終了ですと。

jsonをぶち込むか、拡張機能のパッケージ化なんかで
インストすればいい感じですかね?

そうかっ!わからんヽ(`Д´#)ノ

注意事項