There are some imacro with Javascript questions on here, but nothing that gave me what I need... I tried this question: Imacros: Random wait time? and this question: How to loop only a series of steps in iMacros (this was helpful, but now what I have is a bit buggy). I can't figure out why this isn't working...
What I want to do is follow people on Tumblr using imacros. I added the Math.random()
function because I want it to choose a random amount of time within 0 to 11 seconds in which it follows a new person.
I only want the imacro to run this part of the code once because it only needs to be run once:
window.location = "URL GOTO = https://www.tumblr.com/search/pony/recent" + "\n";
var rand = "Math.random()*7 + 5";
var macro = "CODE:SET !REPLAYSPEED FAST" + "\n";
var macro = "CODE:SET !ERRORIGNORE YES" + "\n";
macro += "TAG POS={{i}} TYPE=I ATTR=CLASS:icon_view_list&&TXT:" + "\n";
Then I want it to loop this part of the code (the actual following steps):
macro += "TAG POS={{i}} TYPE=DIV ATTR=TITLE:Like&&CLASS:post_control<SP>like&&TXT: " + "\n";
macro += "WAIT SECONDS={{rand}}";
It loops it using this:
for(var i=0;i<100;i++)
{
iimDisplay(i);
iimSet("i", i);
iimSet("rand", rand);
iimPlay(macro);
}
This works well except these lines of code: macro += "TAG POS={{i}} TYPE=I ATTR=CLASS:icon_view_list&&TXT:" + "\n";
and var rand = "Math.random()*7 + 5;"
do not seem to be working properly. The first part of code is to make it so it selects the "list view" instead of the "grid view" on tumblr because I cannot get the grid view to work (if anyone has any insight as to why it doesn't work that'd be great, but not a big deal). The second part of the code isn't working properly because it will always set rand
to 11 seconds... so it looks like the Math.random()
function isn't working properly and I cannot figure it out.
Here's my entire code:
window.location = "URL GOTO = https://www.tumblr.com/search/pony/recent" + "\n";
var rand = "Math.random()*7 + 5";
var macro = "CODE:SET !REPLAYSPEED FAST" + "\n";
var macro = "CODE:SET !ERRORIGNORE YES" + "\n";
macro += "TAG POS={{i}} TYPE=I ATTR=CLASS:icon_view_list&&TXT:" + "\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=TITLE:Like&&CLASS:post_control<SP>like&&TXT: " + "\n";
macro += "WAIT SECONDS={{rand}}";
for(var i=0;i<100;i++)
{
iimDisplay(i);
iimSet("i", i);
iimSet("rand", rand);
iimPlay(macro);
}