chrome拡張機能では、ルールとして必ず マニフェストファイルを作成する必要があるらしい。
現時点の最新バージョンは3だが、wildfireはバージョン2を採用している。
Googleのアナウンスによると、いずれバージョン2は使えなくなるらしい
以下、manifest.jsonの記載内容でポイントになるであろう部分をピックアップ
- applications キー
- author キー
- background キー + scripts キー
- browser_action キー default_popup キー
- commands キー
- content_scripts キー
- content_security_policy キー
- description キー
- externally_connectable キー
- icons キー
- key キー
- manifest_version キー
- minimum_opera_version キー
- name キー
- offline_enabled キー
- permissions キー
- short_name キー
- update_url キー
- version キー
- web_accessible_resources キー
applications キー
{
"applications": {
"gecko": {
"id": "support@wildfire.ai",
"strict_min_version": "48.0"
}
},
早速? applications ? MDN によると"applications" は Google Chrome でサポートされていません。 とのこと とりあえず無視
author キー
"author": "wildfire.ai",
製作者さんのこと、すてきなツールをありがとうございます。
background キー + scripts キー
"background": {
"scripts": [ "tesseract/tesseract.js", "jquery-2.2.4.min.js", "main.js", "aes.js", "exprparse.js", "fuzzyset/fuzzyset.js" ]
},
MDNによると、background を使って拡張機能に 1 つ以上のバックグラウンドスクリプトや、オプションとしてバックグラウンドページを含めます。バックグラウンドスクリプトは、特定のウェブページやブラウザーウィンドウとは独立した、長い期間の状態や、長い期間の操作を維持する必要があるコードを置く場所です。 scripts は、そのためのスクリプトファイルのパスを書くとのこと
wildfireでは、OCR機能(なぜ?)のための tesseract.js 、ライブラリで有名なjquery、スペルミスや文字列の一致を確認するため(?)の fuzzyset.js の他独自実装のスクリプトが動いているようだ
browser_action キー default_popup キー
"browser_action": {
"browser_style": false,
"default_icon": {
"16": "icon-16.png",
"32": "icon-32.png"
},
"default_popup": "popup.html"
},
browser actionはあなたのブラウザーのツールバーに拡張機能のボタンを追加します。ボタンはアイコンと、オプションでHTML、CSSとJavaScriptを使用した、ポップアップコンテンツを使用できます。
そして、 その実態がpopup.html
commands キー
"commands": {
"play-workflow-1": {
"description": "Play Favorited Workflow #1",
"suggested_key": {
"default": "Ctrl+Shift+1",
"mac": "MacCtrl+Shift+1"
}
},
"play-workflow-2": {
"description": "Play Favorited Workflow #2",
"suggested_key": {
"default": "Ctrl+Shift+2",
"mac": "MacCtrl+Shift+2"
}
},
"play-workflow-3": {
"description": "Play Favorited Workflow #3"
},
"run-current-workflow": {
"description": "Play Current Workflow",
"suggested_key": {
"default": "Ctrl+Shift+9",
"mac": "MacCtrl+Shift+9"
}
},
"stop-simulation": {
"description": "Stop Simulation",
"global": true,
"suggested_key": {
"default": "Ctrl+Shift+0"
}
}
},
commands キーはオブジェクトで、それぞれのショートカットはそのプロパティです。プロパティ名はショートカットの名前
play-workflow-1 、 play-workflow-2 … stop-simulation” は、 これらのコマンドの最初を下記のようにリッスンさせるために定義しているらしい。
browser.commands.onCommand.addListener(function(command) {
if (command == "toggle-feature") {
console.log("toggling the feature!");
}
});content_scripts キー
"content_scripts": [ {
"all_frames": true,
"js": [ "jquery-2.2.4.min.js", "content.js" ],
"match_about_blank": true,
"matches": [ "http://*/*", "https://*/*" ]
} ],
与えられたパターンに URL がマッチしているページにコンテンツスクリプトをロードすることをブラウザに教えます。
all_frames が true ということは、指定した URL要求にマッチするすべてのフレームに(タブの最上位フレームでなくても)挿入される
jsは、 URL要求にマッチしたページに挿入される JavaScript ファイル
match_about_blank がtrue ということは、コンテンツスクリプトを "about:blank" もしくは"about:srcdoc"のURLを持つページに挿入することらしい。詳細なMDN
matches はマッチパターンの配列。wildfireでは、http,httpsにかかわるすべてのサイトがマッチ対象
content_security_policy キー
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
いわゆるセキュリティポリシー、 ありがたいわかりやすいサイトを参照
wildfireでは、こんな条件になるのかな。
script-src ‘self’ : スクリプト関連の権限を制限する 現在のオリジンと一致するサブドメインは除外 の条件で
‘unsafe-eval’ : evalなどのtext-to-JavaScriptの仕組みを許可する
object-src ‘self’ : Flashなどのプラグインの種類を制限する 現在のオリジンと一致するサブドメインは除外 の条件で
description キー
"description": "Record browser actions then replay immediately. Craft your own custom automation workflows.",
いわゆる説明
拙い翻訳をすると、ブラウザのアクションを記録し、すぐに再生します。独自のカスタム自動化ワークフローも作成します。といった感じ。
ほんとうにありがたいです。
externally_connectable キー
"externally_connectable": {
"matches": [ "https://wildfire.ai/*", "https://www.wildfire.ai/*", "https://api.wildfire.ai/*", "https://cloud.wildfire.ai/*" ]
},
runtime.connectおよびruntime.sendMessageを介して拡張機能に接続できる拡張機能、アプリ、および Web ページを宣言します。これは、 wildfire のhpと通信可能ということ??
icons キー
"icons": {
"128": "icon-128.png",
"16": "icon-16.png",
"32": "icon-32.png",
"48": "icon-48.png"
},
張機能のアイコン
key キー
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtlggGhizqpz/re1CbIfJezkRUBcWgpts6vKDNZGchNiQseAACsCGiNJCAVpslArTYhdOfqa3QY6qkSdSxsSWhYqPN+ijHWbXSo4ox27nuPso29Yqxsv/sCCIn70gJmju/4gAOX0TcFV+E7LvuqFlgTSk7PV9MEjZv3sFxRSvwPMmjXUIs4GlOTQe+FD73WNVAdGXAaSaz4uSIbe2zxb6CCEtmPBGR/ItsXudk7xSx8LVHDRGjbfoxS6Bf4VkMRBtK9uQc2rX5JchL5VcHkJMXGmlLRePQLt21Tj0rz+yCFzu8OJx8btrCCU07GMQZs96gK6tQw2VaRlrrV3Pwwz8iwIDAQAB",
キーはアップロードしたりパッケージ化した時などに自動で付与される
manifest_version キー
"manifest_version": 2,
Wirdfireはバージョン2 最新のマニュフェストはバージョン3
minimum_opera_version キー
"minimum_opera_version": "33.0",
Opera 用のキーみたい
拡張機能が必要とする Opera のバージョン (存在する場合)。この文字列の形式は、バージョン フィールドの形式と同じです。
name キー
"name": "Wildfire",
拡張機能の名前
offline_enabled キー
"offline_enabled": true,
非標準:この機能は非標準であり、標準トラックには存在しません。Web に面した運用サイトでは使用しないでください。また、実装間に大きな非互換性が存在する可能性があり、今後の動作が変化する可能性があります。 とのこと。
permissions キー
"permissions": [ "alarms", "clipboardRead", "clipboardWrite", "contextMenus", "nativeMessaging", "browsingData", "proxy", "webRequest", "webRequestBlocking", "cookies", "tabs", "webNavigation", "storage", "tabCapture", "notifications", "http://*/", "https://*/", "\u003Call_urls>", "unlimitedStorage", "debugger" ],
拡張機能が特別な権限を必要とする際には permissions キーを使用します。このキーには文字列の配列を指定し、各文字列が権限を要求します。とのこと
つまり、 Wildfire では、これだけの権限を有効にしているということ。
short_name キー
"short_name": "Wildfire",
ショートネーム
update_url キー
"update_url": "https://clients2.google.com/service/update2/crx",
拡張機能 を自動でアップデートする仕組みのためのキー
version キー
"version": "1.3.10",
Wildfireのバージョン
web_accessible_resources キー
"web_accessible_resources": [ "embedded.js" ] }
拡張機能に何らかのリソース – たとえば、画像や HTML、CSS、JavaScript – をパッケージして、ウェブページで使用できるようにしたい場合に設定するらしい。

コメント