我正在尝试使内联脚本(作为书签放在浏览器中的脚本)需要自动刷新网页间隔(15或20秒)并检查元素的变化。如果这些元素符合某些标准,请点击按钮。内联JavaScript以给定的时间间隔自动刷新网页,并检查div元素中的更改
想象一下ebay列表,脚本用价格检查html元素并将其与存储在会话存储中的值进行比较。如果价格低于给定价格,则点击按钮购买该物品。
我不能在网站上放任何代码,我所能做的就是从书签执行内联脚本。
基本上我想点击书签,然后在页面上从那里开始每隔15秒刷新一次,直到关闭标签。
我发现这个代码:
javascript:
var current = location.href,
\t timer = setTimeout('reload()', 20000);
\t
\t //if I put the logic here it only executes once and then does not check for a change in the div element
function reload(){
\t
\t //if I put the logic here it does not have access to the DOM and can't check for the changes.
\t \t
\t setTimeout('reload()',20000);
\t
\t fr4me='<frameset cols=\'*\'>\n<frame src=\''+current+'\'/>';
\t fr4me+='</frameset>';
\t
\t with(document){
\t \t write(fr4me);
\t \t void(close())
\t };
\t
\t
}
但由于在评论中提到 - 的的document.getElementById或者如果放置在顶部,或者它根本不工作,只有一次工作所有如果在重置功能。
有没有什么建议?感谢您的期待