我正在制作一个机器人来做我从chrome控制台运行的东西。它应该打开某个链接的新选项卡,然后在运行时刷新它。每次刷新后,都应该使用.getElementById来查找内容,如果找到它(它是一个超链接),它应该打开它在新标签中链接的位置。这是我到目前为止所做的事情(充满了错误,对不起)。
var go = true;
var win = window.open("http://www.roblox.com/User.aspx?id=1211749", "_blank");
//WIN IS NULL FOR SOME REASON
function doTheThing()
{
//BECAUSE WIN IS NULL, NOT SURE IF WORKS
win.location.reload();
//BECAUSE WIN IS NULL, NOT SURE IF WORKS
//MUST GRAB ELEMENT FROM THE OTHER REFRESHED WINDOW
var x = win.document.getElementById("ctl00_cphRoblox_rbxUserAssetsPane_UserAssetsDataList_ctl00_AssetNameHyperLink");
var n = x.search("Federation");
//If the link title has "Federation" in it
if (n > -1 && go == true)
{
var win = window.open(x, '_blank');
//MAY NOT WORK SINCE THE OTHER WINDOW.OPEN DOES NOT WORK
//Open the window
if(win)
{
win.focus();
//go to it
}
go = false;
//Keep it from opening 1000 windows
}
}
while (go == true)
{
var zhuLi = setInterval(doTheThing, 1000);
}
答案 0 :(得分:0)
我认为你想使用setInterval(...)函数,而不是setTimeOut(...)。如果您想要退出setInterval循环,可以使用clearInterval()。