Firefox で Chrome と Greasemonkey のユーザースクリプトを実行しようとしています。
両方のプラットフォームで動作するはずなので、GM_xmlhttpRequest を使用しています。要求コードは両方のブラウザーで機能するようですが、Firefox では、予想される応答が得られる Chrome とは対照的に、responseText は空です。
ユーザースクリプトコード:
// ==UserScript==
// @include *.website.org/Forum/Read.aspx?*
// ==/UserScript==
getstr = "thread="+thread+"&day="+getday;
GM_xmlhttpRequest({
method: "POST",
url: "http://www.other.org/js/gm/get.php",
data: getstr,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Content-type":"charset=utf-8"
},
onload: function(response) {
alert(response.responseText);
}
});
「other.org」サイトの php スクリプト:
$json = json_encode($array);
echo $json;
ユーザースクリプトは JSON.parse() で応答を処理しますが、ここでは重要ではありません。
Chrome ではこれは完全に機能しますが、firefox では responseText が空です。
これは同一生成元ポリシーに関係している可能性があると読みました。しかし、これがどのようになるのか、どうすれば修正できるのかわかりません。すべてのヘルプは大歓迎です!