iMacro: JavaScript loops with variables

iMacro is a cool firefox plugin able to record and play macros on the browser.

It can be used as a functional testing tool, like Selenium ( although Selenium is really better ), or as a showcase/annoying operation tool.

Today I faced it for the first time with the need to bomb URLs progressively, some bombing kinda like:

GET /news/1 GET /news/2 GET /news/3 for 16K urls¹.

Basically, what I needed was a loop with a variable.

Unfortunately, iMacro doesn’t natively support for loops, but has bridges for any kind of language ( VBS, PHP, JavaScript… ) so I only needed to use a JS script ( which can be direcly run on iMacro’s web interface):

1
2
3
4
5
for (i = 0; i < N; i++)
{
  iimSet('-var_ID', i);
  iimPlay("/home/odino/iMacros/Macros/BombingIsCool.iim");
}

the BombingIsCoolMacro simply goes to an URL with the imported variable ( ID ):

1
URL GOTO=http://mydomain.com/news/
comments powered by Disqus