Firefox アドオンで、この Web サイトのボタンの URL に HTTPRequest を送信したいと思います: www.google.com/ads/preferences。私がやろうとしているのは、ボタンを含むフォームを取得し、アクション属性に HTTP リクエストを作成することです (目標は、サーバーが送信するダブルクリック Cookie を取得することです)。問題は、フォームを取得すると XRayWrapper が取得され、その属性を取得する方法がわからないことです (私はすでにやろうとしました:
// unwrap is not available on older branches (3.5 and 3.6) - Bug 533596
if (XPCNativeWrapper && "unwrap" in XPCNativeWrapper) {
try {
return XPCNativeWrapper.unwrap(thing);
} catch(e) {
// Unwrapping will fail for JS literals - numbers, for example. Catch
// the exception and proceed, it will eventually be returend as-is.
}
}
if (thing['wrappedJSObject']) {
return thing.wrappedJSObject;
}
また、フォームと innerHTML へのアクセスを含む id="content-pane" を持つ div を取得すると、空の文字列が取得されることがわかりました。でも、別のアドオンであるfirebugでこれらのコンテンツを見ることができるので、それは可能に違いありません....
私は本当に迷っています、あなたの助けに感謝します!
編集:アドオンSDKを使用しているため、これらすべてを処理するページワーカーを作成しました:
createDoubleClick: function() {
new PageWorker.Page({
contentURL: "http://www.google.com/ads/preferences",
contentScriptFile: data.url('contentScripts/getCookie.js'),
contentScriptWhen: "end",
onMessage: function(message) {
console.log(message);
}
});
}
次に、contetScript で DOM を取得しようとします。
// Get button
var idPanel = "content-pane";
// Get content panel
var panel = document.getElementById(idPanel);
console.log(panel.innerHTML);
結果:
info: