Javascript和imacros循环

时间:2014-01-24 15:39:18

标签: javascript loops imacros

我为imacros做了这个javascript cood但是没有用,我得到的错误如下:

  

SyntaxError:SET命令格式错误,行:1(错误代码:-910)

我不知道是什么问题。 该脚本用于登录帐户并进行一些提交,并使用另一个帐户重新登录并进行相同的提交 如果我有4个帐户和10个提交,我应该如何编辑这部分代码:

 iimPlay(login);
    for(i=1;i<4;i++){
    iimSet("i",i);
    iimPlay(submit);
    }

这是imacros脚本:

var login;
    login =  "CODE:";
    login +=  "VERSION BUILD=7601105" + "\n";
    login +=  "CLEAR" + "\n";
    login +=  "TAB T=1" + "\n";
    login +=  "SET !DATASOURCE D:\test\iftt-login.csv" + "\n";
    login +=  "SET !DATASOURCE_COLUMNS 2" + "\n";
    login +=  "SET !DATASOURCE_LINE {{i}}" + "\n";
    login +=  "URL GOTO=https://ifttt.com/login" + "\n";
    login +=  "TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/session ATTR=NAME:login CONTENT={{!COL1}}" + "\n";
    login +=  "SET !ENCRYPTION NO" + "\n";
    login +=  "TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:/session ATTR=NAME:password CONTENT={{!COL2}}" + "\n";
    login +=  "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/session ATTR=NAME:remember_me CONTENT=NO" + "\n";
    login +=  "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/session ATTR=NAME:commit" + "\n";

var submit;
 submit =  "CODE:";
 submit +=  "SET !DATASOURCE D:\tumblr\stuff-to-submit.csv" + "\n";
 submit +=  "SET !DATASOURCE_COLUMNS 3" + "\n";
 submit +=  "SET !DATASOURCE_LINE {{n}}" + "\n";
 submit +=  "URL GOTO=https://ifttt.com/myrecipes/personal/new" + "\n";
 submit +=  "TAG POS=1 TYPE=A ATTR=TXT:this" + "\n";
 submit +=  "TAG POS=1 TYPE=IMG ATTR=ID:channel_4" + "\n";
 submit +=  "TAG POS=1 TYPE=H3 ATTR=TXT:New<SP>feed<SP>item" + "\n";
 submit +=  "SET !ERRORIGNORE YES" + "\n";
 submit +=  "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:new_statement ATTR=ID:statement_live_trigger_attributes_live_trigger_fields_attributes_0_string_value CONTENT={{!COL1}}" + "\n";
 submit +=  "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:new_statement ATTR=ID:validate_trigger_btn" + "\n";
 submit +=  "TAG POS=1 TYPE=A ATTR=TXT:that" + "\n";
 submit +=  "TAG POS=2 TYPE=IMG ATTR=ID:channel_13" + "\n";
 submit +=  "SET !ERRORIGNORE NO" + "\n";
 submit +=  "TAG POS=1 TYPE=H3 ATTR=TXT:Create<SP>a<SP>photo<SP>post" + "\n";
 submit +=  "TAG POS=1 TYPE=TEXTAREA FORM=ID:new_statement ATTR=ID:statement_live_action_attributes_live_action_fields_attributes_1_value CONTENT=" + "\n";
 submit +=  "TAG POS=1 TYPE=DIV ATTR=TXT:Complete<SP>Action<SP>Fieldsstep<SP>6<SP>of<SP>7Create<SP>a*" + "\n";
 submit +=  "TAG POS=1 TYPE=TEXTAREA FORM=ID:new_statement ATTR=ID:statement_live_action_attributes_live_action_fields_attributes_1_value CONTENT={{!COL2}}" + "\n";
 submit +=  "TAG POS=1 TYPE=TEXTAREA FORM=ID:new_statement ATTR=ID:statement_live_action_attributes_live_action_fields_attributes_2_value CONTENT={{!COL3}}" + "\n";
 submit +=  "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:new_statement ATTR=ID:validate_action_btn" + "\n";
 submit +=  "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:new_statement ATTR=ID:statement_create_task_submit" + "\n";

iimPlay(login);
for(i=1;i<4;i++){
iimSet("i",i);
iimPlay(submit);
}

2 个答案:

答案 0 :(得分:0)

尝试更改此

login +=  "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";

用这个

login +=  "SET !DATASOURCE_LINE {{i}}" + "\n";

以及您的代码

for(i=1;i<4;i++){
iimSet("i",i);
iimPlay(login);
iimSet("i",i);
iimPlay(submit);
}

答案 1 :(得分:0)

为什么要使用iimSet?

为什么不使用javascript&#39; s变量?

来自:

login +=  "SET !DATASOURCE_LINE {{i}}" + "\n";

到此:

login +=  "SET !DATASOURCE_LINE " + i + " + "\n";