ページに表示されるいくつかの要素の値を (DOM の変更によって) 変更する小さな Greasemonkey スクリプトを作成しようとしています。
私はただの Greasemonkey ユーザーであり、JavaScript の経験はありません。このエラーが発生します: the expression is not a legal expression.
(行: 結果 =...)
また、修正が必要なエラーが他にあるかどうかも知りたいです。
これが私のスクリプトです:
// ==UserScript==
// @name myscript
// @namespace http://www.google.com
// @include http://mysite/
// @version 1
// @grant GM_addStyle
// ==/UserScript==
function waitForKeyElements (selectorTxt, actionFunction) {
if (getElementByXPath(selectorTxt) == null) {
var timeControl = setInterval (function () {
waitForKeyElements (selectorTxt, actionFunction);
},
300
);
} else {
clearInterval (timeControl);
actionFunction();
}
}
var getElementByXPath = function (path) {
result = document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
return result.singleNodeValue;
};
function myFunc (jNode) {
getElementById("foo1").setValue("foo2");
}
waitForKeyElements ("foo3", myFunc);