5 javascript conditional for-loop imacros
这里有一些带有Javascript条件问题的imacro,但没有任何东西能给我我需要的东西......我试过这个问题:http://forum.imacros.net/viewtopic.php?f = 11&t = 14010 ,但我的是不同,因为我不需要使用EXTRACT命令,因为我已经知道文本中的单词...我无法弄清楚为什么这不起作用...我有一种感觉这里的逻辑是关闭的(if(macro=="Follow"){)但是我不确定.
我正试图在Pinterest上建立一个跟随人们的imacro.我想要完成的是,一旦它到达页面的末尾,它跟随人们,它将向下滚动以显示更多人要关注.
此外,如果我输入搜索关键字,其中第一页上的每个人都已被跟踪,我希望它向下滚动直到它到达我没有关注的用户 - 即使它必须多次运行此代码(URL GOTO=javascript:window.scrollBy(0,20000))传递多个页面以获得我没有关注的新人群.
我把这个代码用于scoll down : 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);
}
}
Run Code Online (Sandbox Code Playgroud)
你可以替换这一行
var macro = "URL GOTO=javascript:window.scrollBy(0,20000)" + "\n";
Run Code Online (Sandbox Code Playgroud)
和
window.scrollTo(0,window.document.body.scrollHeight);
Run Code Online (Sandbox Code Playgroud)