How can i set loop iMacros by Javascript?

我是研究僧i 提交于 2019-12-02 00:23:16

Specify your imacros code as a javscript string and prefix with CODE:

var urls = ['http://google.com', 'http://yahoo.com'];

for (var i in urls) {
  var url = urls[i];
  var returnCode = iimPlay('CODE: URL GOTO='+url);
}

You have to write macro like this

var macro;

macro ="CODE:";
macro +="TAG POS={{i}} TYPE=SPAN ATTR=TITLE:link"+"\n";

///The triggering part

for (var i=1;i<10;i++)
{

iimSet("i",i)
iimPlay(macro)
}

Since you example was kind of unclear I have to say that this command might not work.

TAG POS={{i}} TYPE=SPAN ATTR=TITLE:link

Instead of word link replace it with * which means any character and then it can work

TAG POS={{i}} TYPE=SPAN ATTR=TITLE:*

Also in the macro you can write like this

TAG POS={{variable}} TYPE=SPAN ATTR=TITLE:*

But in the iimSet part it has be like this.

iimSet("variable",i)

1) to loop javascript code you can add for statement like this:

for (i=1;i<=n;i++){
iimPlay(macro);
}

where n is number of loops to perform

2) in iim you do not need it as !extract parameter already has extracted value

questions

I understand how to make imacros for firefox loop using javascript, but the question is how does the variable carry over into the called macro here:

iimPlay(macro);

the first time let's say you want to click on link pos=1

then 2nd time on link pos=2

if your called iim script is:

TAG POS=1 TYPE=SPAN ATTR=TITLE:link

how will the script know how to look at position 2 (POS=2) the next time and POS=3 the subsquent time?

is it correct to type the following?

TAG POS=i TYPE=SPAN ATTR=TITLE:link
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!