firefoxでは、私はツイッターのページはどこでもうまく動作しているgreasemonkeyスクリプトを作った。 TwitterにはJavaScriptプラグインに対する保護機能がありますか?もしそうなら、回避策はありますか?私のgreasemonkeyコードはtwitter以外のどこでも動作しますか?それを動作させる方法はありますか?
// ==UserScript==
// @name teste.js
// @namespace teste.js
// @version 1
// @grant none
// @include *://www.twitter.com*
// @include *://www.google.com*
// @include *://www.facebook.com*
// @run-at document-start
// ==/UserScript==
var pressedKey = 1;
var scroll;
function KeyCheck(e)
{
var x = e.which || e.keyCode;
console.log(e);
if (x == 97)
{
clearInterval(scroll);
if (pressedKey == 1)
{
scroll = setInterval(function(){ window.scrollBy(0,1); }, 50);
pressedKey = -pressedKey;
//document.getElementById("demo").style.backgroundColor = "red";
}
else if (pressedKey == -1)
{
pressedKey = -pressedKey;
//document.getElementById("demo").style.backgroundColor = "blue";
}
}
}
window.addEventListener('keydown', KeyCheck, true);
私たちはあなたに私たちに何か詳細を教えてくれません。このスクリプトは何をしていますか? 「それはうまくいかない」とはどういう意味ですか?それはエラーを起こすか?それが失敗する前にしようとしていることを教えてくれますか? Greasemonkeyはページ上でそれを実行しますか? – Shadow
コードを編集して置いてください。だから、greasymonkeyはtwitterのページでスクリプトを認識していないようだ。私がコンソールに直接置くとスクリプトが動作します。 – Matheus