如何使用iMacros JS for Firefox更改焦点

时间:2016-06-11 15:36:35

标签: javascript jquery imacros

我使用imacros javascript为firefox创建了一个脚本:

我想在打开已经工作的三个选项卡后,创建一个可以聚焦到第一个选项卡的功能 我已经尝试了一些样本,但无法弄清楚如何做到这一点

var macro;
var MyDelay;
MyDelay = Math.round(Math.random() * (5 - 2) + 2);

macro ="CLEAR"+"\n";
macro +="TAB CLOSEALLOTHERS"+"\n";
macro +="SET !ERRORIGNORE YES"+"\n";
macro +="SET !TIMEOUT 10"+"\n";
macro +="SET !TIMEOUT_PAGE 10"+"\n";

tabopen ="SET !ERRORIGNORE YES"+"\n";
tabopen +="SET !TIMEOUT 10"+"\n";
tabopen +="SET !TIMEOUT_PAGE 10"+"\n";
tabopen +="TAB OPEN"+"\n";

tab1 ="TAB T=1"+"\n";
tab1 +="SET !ERRORIGNORE YES"+"\n";
tab1 +="SET !TIMEOUT 10"+"\n";
tab1 +="SET !TIMEOUT_PAGE 10"+"\n";
tab1 +="URL GOTO=http://google.com"+"\n";
tab1 += "WAIT SECONDS=" + MyDelay + "\n";

tab2 ="TAB T=2"+"\n";
tab2 +="SET !ERRORIGNORE YES"+"\n";
tab2 +="SET !TIMEOUT 10"+"\n";
tab2 +="SET !TIMEOUT_PAGE 10"+"\n";
tab2 +="URL GOTO=http://google.com"+"\n";
tab2 +="WAIT SECONDS=" + MyDelay + "\n";

tab3 ="TAB T=-2"+"\n";
tab3 +="SET !ERRORIGNORE YES"+"\n";
tab3 +="SET !TIMEOUT 10"+"\n";
tab3 +="SET !TIMEOUT_PAGE 10"+"\n";
tab3 +="URL GOTO=http://google.com"+"\n";
tab3 +="WAIT SECONDS=" + MyDelay + "\n";

for (var i=1;i<50000;i++) {
    iimDisplay("Total: loop "+i+" here ");
    iimSet("i", i);
    iimPlayCode(macro);
    iimPlayCode(tab1);
    iimPlayCode(tabopen);
    iimPlayCode(tab2);
    iimPlayCode(tabopen);
    iimPlayCode(tab3);
}

我重新命名了这个脚本(woobi.js)

也尝试TAB T=1,但不能正常工作

1 个答案:

答案 0 :(得分:0)

以下脚本是否适合您?

// open three tabs
iimPlayCode (
    "TAB OPEN" + "\n" +
    "TAB T=2" + "\n" +
    "WAIT SECONDS=1" + "\n" +
    "TAB OPEN" + "\n" +
    "TAB T=3" + "\n" +
    "WAIT SECONDS=1" + "\n" +
    "TAB OPEN" + "\n" +
    "TAB T=4" + "\n" +
    "WAIT SECONDS=1" + "\n"
);

// go to the first tab
iimPlayCode (
    "TAB T=-2" + "\n"
);