2つの異なるコンテンツスクリプトを使用してSafari拡張機能を構築しています。1つのスクリプトをすべてのhttpページに挿入する必要があります(httpsページは挿入しないでください)。もう1つは、スキームに関係なく、google.comページにのみ挿入されます。
これを達成するために、私は次のように設定Extension Website Access
しました。
これは、高レベルでは、私の拡張機能のコンテンツスクリプトがすべてのページにアクセスできる必要があることを意味するはずです。
次に、よりきめ細かい制御を行うために、パターンに一致するURLにコンテンツスクリプトをプログラムで挿入します。
App = {
content: {
// Inject into unsecure pages.
whitelist: ['http://*/*'],
// But not into secure pages.
blackList: ['https://*/*'],
loc: safari.extension.baseURI + 'data/content.js'
},
results: {
// Inject this script into all google.com pages
whiteList: ['http://*.google.com/*', 'https://*.google.com/*'],
// Surely I don't need a blacklist if I specify a whitelist?
blacklist: undefined,
loc: safari.extension.baseURI + 'data/results.js',
}
};
// Inject the first content script.
safari.extension.addContentScriptFromURL(App.content.loc,
App.content.whitelist, App.content.blacklist, false);
// Inject the second content script.
safari.extension.addContentStyleSheetFromURL(App.results.cssLoc,
App.results.whitelist, App.results.blacklist, false);
問題は、両方のスクリプトがすべてのページに挿入されていることです。私のホワイトリストとブラックリストは何もしないかのようです。私は何が間違っているのですか?