【发布时间】:2014-08-26 22:14:59
【问题描述】:
这里有一些带有 Javascript 条件问题的 imacro,但没有任何东西可以满足我的需求...我尝试了这个问题:http://forum.imacros.net/viewtopic.php?f=11&t=14010,但我的问题不同,因为我不需要使用 EXTRACT命令,因为我已经知道文本中的单词...我不知道为什么这不起作用...我感觉这里的逻辑不正确(if(macro=="Follow"){)但我不确定.
我正在尝试设置一个 imacro,以便在 Pinterest 上关注人们。我想要完成的是,一旦它到达它正在关注的人的页面末尾,它将向下滚动以显示更多人关注。
另外,如果我输入一个关键字,第一页上的每个人都已经被关注,我希望它向下滚动,直到它到达我没有关注的用户 - 即使它必须运行此代码(@ 987654324@) 多次传递多个页面以获取我未关注的新一组人。
我使用此代码进行 scoll down:URL GOTO=javascript:window.scrollBy(0,20000)。我遇到了问题,但是因为我无法弄清楚条件... 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);
}
}
【问题讨论】:
标签: javascript for-loop conditional imacros