これはおそらく私が何かばかげたことをしているのですが、私は何が分かりません。私は、Google Chromeのページ拡張デモのサンプルを入手しようとしています。デモのソースはここで見つけることができます: http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/pageAction/Google Chromeで働いているGoogle PageActionサンプルエクステンションを提供するにはどうすればよいですか?
それは2つのコードファイルを持つ単純なプログラムだ - マニフェストとbackground.jsファイル。ここbackground.jsです:
// Called when the url of a tab changes.
function checkForValidUrl(tabId, changeInfo, tab) {
// If the letter 'g' is found in the tab's URL...
if (tab.url.indexOf('g') > -1) {
// ... show the page action.
chrome.pageAction.show(tabId);
}
};
// Listen for any changes to the URL of any tab.
chrome.tabs.onUpdated.addListener(checkForValidUrl);
そしてここでは、manifest.jsonをファイルです:書かれたよう
{
"name": "Page action by URL",
"version": "1.0",
"description": "Shows a page action for urls which have the letter 'g' in them.",
"background": { "scripts": ["background.js"] },
"page_action" :
{
"default_icon" : "icon-19.png",
"default_title" : "There's a 'G' in this URL!"
},
"permissions" : [
"tabs"
],
"icons" : {
"48" : "icon-48.png",
"128" : "icon-128.png"
},
"manifest_version": 2
}
、このコードは私のために動作しません。 Chromeは拡張機能をうまく読み込みますが、URLにgが含まれているページに移動すると、アイコンが表示されません。
私はこの答えを見つけた: How do I make page_action appear for specific pages?
だから私はfollowing-
がbackground.htmlファイルを作成しようとした:
<html><head><script> ... cut and pasted contents of background.js above </script></head></html>
はmanifest_versionを持ってmanifest.jsonをを変更しました:マニフェストの代わりに1:2
- はbackground_pageするmanifest.jsonを背景プロパティを変更: "background.html"
は、これは完全に働きました。
しかし、私は絶対にbackground.jsファイルとmanifest_versionで実行されているこの事を取得することはできないのですが=
2.だから私はmanifest_version = 2とbackground.jsファイルで作業物事を取得する方法を思ったんだけど。また、これは重要ですか?つまり、誰もがmanifest_version = 1を使用していて、このようなことについて心配していないのですか?
素晴らしいキャッチ - 私はそれが問題だと仮定していますので、Ubuntuの上のクロム17上です。 –
うん、そうだろう;) – PAEz