UPDATE
をあまりにも悪い音はありません。 私が行うことは、ローカルストレージから必要な設定を取得し、コンテンツスクリプトが取得したメッセージの親に送信するスクリプトを持つ、拡張機能のページを指すiframeを作成することです.....コードはそれをよく言っています;).......
コンテンツスクリプト
// create the iframe for our page that sends the settings
var el = document.createElement("iframe");
el.setAttribute('src', chrome.extension.getURL("gimmeSettings.html"));
el.style.visibility="hidden";
document.body.appendChild(el);
// create the listner that listens for a message from our page that sends the settings
window.addEventListener("message", receiveSettings, false);
// function that gets called when we recieve a message from the page that sends the settings
function receiveSettings(event) {
//check to make sure the message came from our page
if (event.origin !== "chrome-extension://"+chrome.i18n.getMessage("@@extension_id")) return;
//message came from our extension, do stuff with it
console.debug(event.data);
// clean up
window.removeEventListener("message", receiveSettings, false);
el.parentNode.removeChild(el);
}
gimmeSettings.htmlのJS
// post the message with our settings
parent.postMessage(localStorage.getItem("testing"), "*");
Options.htmlのJS
localStorage.setItem("testing","bleh");
のマニフェスト
{
"name": "Getting at an extensions local storage from a content script",
"description" : "Getting at an extensions local storage from a content script. Be aware that other pages/extensions can use this to get at your settings, but not change them...so dont include sensitvie data.",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js" : ["myscript.js"],
"run_at":"document_idle"
}
],
"permissions": [
"tabs", "<all_urls>"
],
"manifest_version": 2,
"web_accessible_resources": [
"gimmeSettings.html"
],
"options_page": "options.html",
"version":"1.0"
}
いくつかの点に注意する....
他のページや機能拡張が簡単にので、この方法で機密データを使用していけない、またあなたの拡張機能の設定を取得するためにこれを使用することができます。
誰かが分かっていれば、そのページを介してあなたの設定を変更する方法はありません。
マニフェストバージョン2を使用しており、ページgimmeSettingsをアクセス可能に設定しました。違いを知ることができない場合は、バージョン2を追加してください。http://code.google.com/chrome/extensions/trunk/manifestVersion.html
そして、実用的な例が必要な場合は.....
http://forum.valorsolo.com/viewtopic.php?f=36&t=375
ありがとう、これはすばらしいニュースです。また、私はちょうどライブラリにラップすることができたと思っています(Chrome開発者がもっときれいなAPIを作っていれば、その前にそれを見つけることができたらやります)。実際にこの答えは、私はそれのためだけにオプションのページで拡張をしたい:) :)おめでとう。 –
ああ、私はアイデアを持っていました。おそらく機密性の高い設定が、[非対称暗号化](http://www.hanewin.net/encrypt/)(暗号化を実装していませんが、出発点です)を使用して送信される可能性があります。しかし、それは多くのハックワークの地獄のようだ。しかし、楽しいと聞こえる!このようなことをするには、1日に数時間以上かかるはずです。 –