Greasemonkey发现文本问题

时间:2016-03-24 11:35:48

标签: javascript jquery greasemonkey

我正在使用此脚本(下方)查找特定单词并提醒我,但操作是ajax意味着页面不刷新。它被包裹在一个范围内;

<span id="res">Use your arrow keys to begin</span>

此跨度显示单击箭头后的结果。该脚本有效,但由于跨度通过ajax更新,因此无法找到新结果,我该如何解决这个问题?

interval = setInterval(function() {                         
if (/Shiny/i.test (document.body.innerHTML)){
   clearInterval(interval)
   alert ("Found it!");
 }
}, Math.random()*300+500)

1 个答案:

答案 0 :(得分:0)

解决方案:

if(window.location.pathname == "/map_final.php") {
   if (/Shiny/i.test (document.getElementById('res').innerHTML)){
     if(confirm("Found it!")) { clearInterval(interval); }
   }
}, 1000);
}

通过抓取特定ID,它将显示更新的结果;

document.getElementById('res').innerHTML)