前回はWebアプリの検索ボックスとコンテキストメニューの拡張を通して,
ほかのWebサイトと連携する
みなさんは,
今回の機能追加では,
Webアプリの構成
今回は,
manifest.
{
"name": "Odometer",
"description": "距離計",
"version": "0.5",
"app": {
"launch": {
"local_path": "main.html"
}
},
"icons": {
"16": "icon_16.png",
"48": "icon_48.png",
"128": "icon_128.png"
},
"omnibox": {
"keyword": "Odometer"
},
"options_page": "options.html",
"background_page": "background.html",
"content_scripts": [
{
"matches": ["*://maps.google.co.jp/*", "*://maps.google.com/*"],
"js": ["js/content_script.js"]
}
],
"permissions": [
"geolocation",
"notifications",
"background",
"contextMenus",
"tabs"
]
}
Content Scriptsを利用するには,
表1 マニフェストファイルのContent Scripts関連項目
フィールド名 | 説明 |
---|---|
content_ | 対象のWebサイトで任意のJavaScriptやCSSを適用する設定項目をオブジェクト配列で指定 |
matches | 対象のWebサイトのURLを配列で指定 "http:// |
css | 挿入するCSSファイルを配列で指定 |
js | 実行するJavaScriptファイルを配列で指定 |
run_ | JavaScriptを実行するタイミングを指定 "document_ |
all_ | すべてのフレーム要素でスクリプトを実行するかどうかを指定 |
include_ | "matches" からさらに適用するパターンを指定 |
exclude_ | "matches" からさらに除外するパターンを指定 |