情報
種類
- BrowserAction
- PageAction
- Context Script
- Context Menu
準備ファイル
- icon : 19px×19px
- manifest.json : 作成した拡張機能のロード方法について Chrome が認識する必要のある情報は、このファイルに格納される。(ex 拡張機能のタイトル、説明、必要な権限、アイコン参照などの情報)
- その他、表示させるもの、動作を記述するもの(必要に応じ)
manifest.json
必須項目
- manifest_version
- name : 拡張機能の名称
- version": "0.1",
推奨項目
動作によって必要
- permissions : ブラウザからの情報を読み出す際に、その許可を得るために記述する。
ポップアップページ
ページの指定
manifest.jsonに書くか、chrome.browserAction.setPopup(object details)で指定。
ページの幅
body要素にstyle="min-width:250px"の用に指定
注意事項
For the best visual impact, follow these guidelines:
- いろんなページで使える機能をbrowswer actionとして提供する
- 特定のページしか使えないなら、browswer actionで提供する意味が薄い
- 使いやすいアイコンを38x38pxで作っておく。Browser action icons should seem a little bigger and heavier than page action icons.
- Chromeのメニューアイコンに似せない。
- アルファ透過を使って、アイコンにソフトエッジを加えると、テーマを使っているユーザもいい感じに見える。
- アニメはうざいだけ
作成した拡張機能を読み込む
- 拡張機能のページを開く
- デベロッパーモードにする
- 「パッケージ化されていない拡張機能を読み込む」
ページの内容を変える場合の処理
permissions で変更の許可を与える必要あり。
"permissions" : [...]
タブに対する処理
tab
sendMessage で メッセージを送る
integer |
tabId |
タブのID。Tabオブジェクトがあれば、Tab.idで拾える。 |
any |
message |
送るメッセージ |
object |
(optional) options |
|
integer |
(optional) frameId / Send a message to a specific frame identified by frameId instead of all frames in the tab. |
|function|(optional) responseCallback If you specify the responseCallback parameter, it should be a function that looks like this: / function(any response) {...};
any response
The
JSON response object sent by the handler of the message. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and runtime.lastError will be set to the error message.
https://developer.chrome.com/extensions/tabs#method-sendMessage
既に自分のブラウザにインストールしている、誰かのChrome拡張機能のソースを参考にする
- IDを控える
- メニュー(横3本線のアイコン)→設定→拡張機能で、参考にしたい機能のID
- C:\Users\(自分のフォルダ)\AppData\Local\Google\Chrome\User Data\Default\Extensions\(拡張機能ID)\(Version)
最終更新:2015年06月07日 09:22