我有一点困难,即要履行“once<>>> /em”的Script功能,而且只有当一个多功能元素完全装满时。 I ve 尝试了setInterval
s,setimeout
s,FOR
loops,WHILE
loops, et gotten no where.
我确实设法让它一劳永逸地工作,但由于我只能让它去工作,将职能推迟了2秒(这不错,因为它没有确切说明它需要多长时间),并迅速重新履行同样职能和职能,这同样是好的。
我只需要不断扫描该网页,以了解某一要素是否存在并具有内容(inner Abdulaziz != unfin
,或某种),一旦装上(而且仅一次)然后停止扫描该页。
是否有人找到了这样做的方法? 此外,我还需要Java,而不是 j。
Thanks.
Original Code
function injectLink_Bridge(){
setTimeout(function(){
injectLink();
}, 2000);
}
function injectLink(){
var headerElement = document.getElementsByClassName("flex-module-header");
if (headerElement.innerHTML == undefined) {
console.log("Element doesn t exist. Restarting function");
setTimeout(function(){
injectLink_Bridge(); //I can t remember if the bridge is necessary or not
}, 2000);
} else {
console.log("Element exists. Injecting");
setTimeout(function(){
headerElement[1].innerHTML += "code" //Inject code into the second instance of the class-array
}, 2000);
}
}
Finished code
function injectLink(){
var headerElement = document.getElementsByClassName("flex-module-header")[1]; //Get the second instance
if(headerElement && headerElement.innerHTML != ""){
console.log("Element exists and has content. Injecting code...");
headerElement.innerHTML += "code"; //Currently revising, due to T.J. Crowder s side-note
} else {
console.log("Element doesn t exist or has no content. Refiring function...");
setTimeout(injectLink, 250);
}
}