2011-06-15 70 views
1

我已将这种情况与拍卖网站进行了比较。 trada.net有时他们离线了几个小时,目前的位置是这样的:offline location,现在,它基本上禁用了我所有的其他GM脚本,因为没有数据可以分析,而且它是错误的位置。现在,我如何添加一个脚本来检查当前位置是否是“离线”位置,如果属实,请点击名称为“实时拍卖”的网站上的按钮,xpath为:.//*[@id='art-main']/div[1]/div[10]/div[2]/div/div[1]/ul/span[1]/li/a/span[3],每5分钟,或任何时间框架。我要执行的时间框架部分,但链接或按钮的发现仍然存在问题,然后还发现我目前的位置是我的另一个障碍。检查当前位置并每隔几分钟点击一个链接按钮

感谢

回答

0

像这样的东西应该这样做,假设脚本火灾的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');