这里有一些带有 Javascript 条件问题的宏,但没有任何东西能满足我的需求...我试过这个问题:http://forum.imacros.net/viewtopic.php?f=11&t=14010 ,但我的不同,因为我不需要使用 EXTRACT
命令,因为我已经知道文本中的单词......我不明白为什么这不起作用......我感觉这里的逻辑不对 (if(macro=="Follow"){
),但我不确定。
我正在尝试设置一个宏来关注 Pinterest 上的人。我想要完成的是,一旦它到达正在关注人们的页面末尾,它将向下滚动以显示更多关注的人。
此外,如果我输入搜索关键字,其中第一页上的每个人都已被关注,我希望它向下滚动直到它到达我没有关注的用户 - 即使它必须运行此代码(URL GOTO=javascript:window.scrollBy(0,20000)
) 多次传递多个页面以到达我未关注的新人群。
我将这段代码用于向下滚动:URL GOTO=javascript:window.scrollBy(0,20000)
。我遇到了问题,但是因为我无法弄清楚条件......我通过如果没有“关注”文本(没有人关注)来接近它,那么它会跳出 if
语句,以及 else
语句。它会向下滚动,直到它到达某人,然后在它到达某人之后运行宏(不会在 for
循环中浪费另一个增量。
代码如下:
// Location where the imacro goes.
window.location="http://www.pinterest.com/search/boards/?q=ponies" + "\n";
// Gives time for the page to load.
var macro = "WAIT SECONDS=10" + "\n";
// Sets no delay time between each step.
var macro = "CODE:SET !REPLAYSPEED FAST" + "\n";
// Tells imacro to ignore errors.
var macro = "CODE:SET !ERRORIGNORE YES" + "\n";
// Sets the timeout for missing tags to 0 seconds (not 6 seconds).
var macro = "CODE:SET !TIMEOUT_STEP 0" + "\n";
// Clicks the "follow button on Pinterest."
macro += "TAG POS=1 TYPE=BUTTON ATTR=TXT:Follow" + "\n";
// Waits the given number (rand) of time.
macro += "WAIT SECONDS={{rand}}" + "\n";
// -------------------------------------------------------- \\
// Loops 200 times through the two 'macro' steps located above.
for(var i=0;i<200;i++)
{
if(macro=="Follow"){
// Sets a random amount of time for WAIT SECONDS for each step.
var rand = Math.random()*7 + 5;
// Shows what number i is.
iimDisplay(i);
// Replaces i with the new i (after one loop).
iimSet("i", i);
// Replaces rand with the new rand (after one loop).
iimSet("rand", rand);
// Plays the imacro.
iimPlay(macro);
}
else{
// Scrolls down the page.
var macro = "URL GOTO=javascript:window.scrollBy(0,20000)" + "\n";
// Sets a random amount of time for WAIT SECONDS for each step.
var rand = Math.random()*7 + 5;
// Shows what number i is.
iimDisplay(i);
// Replaces i with the new i (after one loop).
iimSet("i", i);
// Replaces rand with the new rand (after one loop).
iimSet("rand", rand);
// Plays the imacro.
iimPlay(macro);
}
}
最佳答案
你可以替换这一行
var macro = "URL GOTO=javascript:window.scrollBy(0,20000)" + "\n";
与
window.scrollTo(0,window.document.body.scrollHeight);
关于javascript - Imacro - 滚动到页面底部的 Javascript 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24593508/