Html 检查当前位置并每隔几分钟单击一个链接按钮
我在一个拍卖网站上看到了这种现状。有时他们会离线几个小时,当前位置如下:,现在,它基本上禁用了我的所有其他GM脚本,因为没有数据要分析,而且它是错误的位置。现在,我如何添加一个脚本来检查当前位置是否为“离线”位置,如果为真,则每5分钟点击一个名为“Live Auctions”的按钮,xpath为:Html 检查当前位置并每隔几分钟单击一个链接按钮,html,xpath,location,greasemonkey,Html,Xpath,Location,Greasemonkey,我在一个拍卖网站上看到了这种现状。有时他们会离线几个小时,当前位置如下:,现在,它基本上禁用了我的所有其他GM脚本,因为没有数据要分析,而且它是错误的位置。现在,我如何添加一个脚本来检查当前位置是否为“离线”位置,如果为真,则每5分钟点击一个名为“Live Auctions”的按钮,xpath为:/*[@id='art-main']/div[1]/div[10]/div[2]/div/div/div[1]/ul/span[1]/li/a/span[3],或者任何时间范围。我要执行的时间段部分,但
/*[@id='art-main']/div[1]/div[10]/div[2]/div/div/div[1]/ul/span[1]/li/a/span[3]
,或者任何时间范围。我要执行的时间段部分,但找到链接或按钮仍然是个问题,然后找到我当前的动作也是我的另一个障碍
谢谢假设脚本为
http://www.trada.net/*
:
//--- Is this the offline page?
if (/errorPage/i.test (window.location.href) )
{
//--- Wait 5 minutes and try the main page again.
var timeDelay = 5 * 60 * 1000; //-- 5 min, in milliseconds.
setTimeout (function() {
//--- Get "button" target. Nominally, http://www.trada.net/p_home.aspx
var desiredPage = $('div#art-main div.art-nav ul.art-menu span li a.active')[0].href;
window.location.replace (desiredPage);
}, timeDelay);
return; //-- Don't process the rest of the script since we are not yet on target page(s).
}
请注意,您可能只需跳过
desiredPage
部分,只需使用:
window.location.replace ('http://www.trada.net/p_home.aspx');