如何通过 Javascript 设置循环 iMacros?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14147290/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 20:49:58  来源:igfitidea点击:

How can i set loop iMacros by Javascript?

javascriptimacros

提问by hcttepe

1) I can't add set loop imacros by javascript, How can i add it ?

1) 我无法通过 javascript 添加 set loop imacros,我该如何添加?

var macro;
    macro =  "CODE:";
    macro +=  "VERSION BUILD=8011895" + "\n"; 
    macro +=  "TAB T=1" + "\n"; 
    macro +=  "SET !ERRORIGNORE YES" + "\n"; 
    macro +=  "SET !EXTRACT_TEST_POPUP NO" + "\n"; 
    macro +=  "SET !TIMEOUT 3" + "\n"; 
    macro +=  "SET !EXTRACT NULL" + "\n"; 
    //macro +=  "SET !LOOP 1" + "\n"; 
    macro +=  "TAG POS={{loop}} TYPE=A ATTR=CLASS:twitter-timeline-link EXTRACT=TXT" + "\n"; 
    macro +=  "SAVEAS TYPE=EXTRACT FOLDER=* FILE=twitter.csv" + "\n"; 
    var extractedtext=iimGetLastExtract();
    iimPlay(macro);

2) How can i use that code on imacros without javascript ? ( on iim)

2) 如何在没有 javascript 的情况下在 imacros 上使用该代码?(在 iim 上)

var extractedtext=iimGetLastExtract(); 

回答by Noah

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

将您的 imacros 代码指定为 javscript 字符串并使用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);
}

回答by macroscripts

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

而不是 word link 用 * 替换它,这意味着任何字符,然后它就可以工作

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 部分,它是这样的。

iimSet("variable",i)

回答by Bestmacros

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

1) 要循环 javascript 代码,您可以添加如下for语句:

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

where n is number of loops to perform

其中 n 是要执行的循环数

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

2) 在 iim 中你不需要它,因为!extract参数已经提取了值

回答by 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:

我了解如何使用 javascript 为 firefox 循环制作 imacros,但问题是变量如何在此处传递到被调用的宏中:

iimPlay(macro);

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

第一次假设你想点击链接 pos=1

then 2nd time on link pos=2

然后第二次在链接 pos=2 上

if your called iim script is:

如果您调用的 iim 脚本是:

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?

脚本如何知道下一次如何查看位置 2 (POS=2) 以及接下来的时间如何查看 POS=3?

is it correct to type the following?

键入以下内容是否正确?

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