循环有问题 iMacros/JS

Have an issue with loop iMacros/JS

我这里有 iMacros/JS Facebook 脚本,它需要从 CSV 文件登录到 FB 帐户,然后脚本有第二个循环 j,正在发送 来自 1 个帐户的 20 个好友请求。

问题是当您更改帐户时会弹出一条消息,要求您验证 phone 号码,在这种情况下,我需要跳过此帐户并转到另一个帐户。

此代码意味着如果页面上出现消息,它必须从 j 循环中中断:

if(iimPlayCode('TAG POS=1 TYPE=DIV ATTR=CLASS:"_2e9n"')>0) {
    break;}

问题是当脚本跳过此帐户时,它也会跳过其他 CSV 文件中的 20 个好友 URL。

因此 j 循环必须始终在它停止的地方继续,如果“20”请求发送从位置“21”开始,但是当它跳过帐户时它也会跳过 CSV 文件中的 20 行。

var accounts = 10;
var total = 100;
var timeout = 'SET !TIMEOUT_STEP 0\n';
var speed = 'SET !REPLAYSPEED FAST\n';
var error = 'SET !ERRORIGNORE YES\n';

var x = 0;//if no error

//Login to account from csv file
for(var i = 1; i <= accounts; i++) {

    function LogIn() {
        iimPlayCode(speed+'SET !DATASOURCE Facebooklogin.csv\nSET !DATASOURCE_LINE '+i+'\nTAG POS=1 TYPE=INPUT:EMAIL ATTR=ID:"email" CONTENT={{!COL1}}\nTAG POS=1 TYPE=INPUT:PASSWORD ATTR=ID:"pass" CONTENT={{!COL2}}\nTAG POS=1 TYPE=LABEL ATTR=class:"uiButton uiButtonConfirm"\n')
    }

    //Check if already logged in then  relog to account from csv file
    if(iimPlayCode(speed+timeout+'TAG POS=1 TYPE=A ATTR=CLASS:"_2s25"')>0) {
        iimPlayCode(timeout+'TAG POS=1 TYPE=DIV ATTR=ID:"userNavigationLabel"\nTAG POS=2 TYPE=SPAN ATTR=TXT:Log<SP>Out')
        LogIn();
    } else { LogIn(); }   

 if(x==0) {
        var j = j*20-19;
    } else if (j > 20) {
        x = 0;
    }

    for (j; j <= total; j++) {

        //If Security Check
        if(iimPlayCode('TAG POS=1 TYPE=DIV ATTR=CLASS:"_2e9n"')>0) {
            x = 1;
            var j = j - 19;
            break;

         } else {
            x = 0;
         }

            //Send Message and Add Friend
            iimPlayCode(speed+error+'SET !TIMEOUT_STEP 0\nSET !DATASOURCE FacebookFriends.csv\nSET !DATASOURCE_LINE '+j+'\nURL GOTO={{!COL1}}\nSET !EXTRACT {{!URLCURRENT}}\nSAVEAS TYPE=EXTRACT FOLDER=* FILE={{!NOW:yyyy/mm/dd}}.csv\nTAG POS=1 TYPE=A ATTR=HREF:/messages/thread/*\nTAG POS=1 TYPE=TEXTAREA ATTR=CLASS:"br *" CONTENT=""\nTAG POS=1 TYPE=TEXTAREA ATTR=ID:"composerInput" CONTENT=""\nTAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:composer_form ATTR=NAME:send\nURL GOTO={{!COL1}}\n')

            if(j==20*i) { break; }
        }
    };//End of loop

我想你需要这样的东西:

var accounts = 10;
var total = 100;
var timeout = 'SET !TIMEOUT_STEP 0\n';
var speed = 'SET !REPLAYSPEED FAST\n';
var error = 'SET !ERRORIGNORE YES\n';

var x = 1;  // variable instead of 'i' in 'j'-loop 

//Login to account from csv file
for(var i = 1; i <= accounts; i++) {

    function LogIn() {
        iimPlayCode(speed+'SET !DATASOURCE Facebooklogin.csv\nSET !DATASOURCE_LINE '+i+'\nTAG POS=1 TYPE=INPUT:EMAIL ATTR=ID:"email" CONTENT={{!COL1}}\nTAG POS=1 TYPE=INPUT:PASSWORD ATTR=ID:"pass" CONTENT={{!COL2}}\nTAG POS=1 TYPE=LABEL ATTR=class:"uiButton uiButtonConfirm"\n')
    }

    //Check if already logged in then  relog to account from csv file
    if(iimPlayCode(speed+timeout+'TAG POS=1 TYPE=A ATTR=CLASS:"_2s25"')>0) {
        iimPlayCode(timeout+'TAG POS=1 TYPE=DIV ATTR=ID:"userNavigationLabel"\nTAG POS=2 TYPE=SPAN ATTR=TXT:Log<SP>Out')
        LogIn();
    } else { LogIn(); }   

    j = 20 * x - 19;
    for (j; j <= total; j++) {

        //If Security Check
        if(iimPlayCode('TAG POS=1 TYPE=DIV ATTR=CLASS:"_2e9n"')>0)
            break;

        //Send Message and Add Friend
        iimPlayCode(speed+error+'SET !TIMEOUT_STEP 0\nSET !DATASOURCE FacebookFriends.csv\nSET !DATASOURCE_LINE '+j+'\nURL GOTO={{!COL1}}\nSET !EXTRACT {{!URLCURRENT}}\nSAVEAS TYPE=EXTRACT FOLDER=* FILE={{!NOW:yyyy/mm/dd}}.csv\nTAG POS=1 TYPE=A ATTR=HREF:/messages/thread/*\nTAG POS=1 TYPE=TEXTAREA ATTR=CLASS:"br *" CONTENT=""\nTAG POS=1 TYPE=TEXTAREA ATTR=ID:"composerInput" CONTENT=""\nTAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:composer_form ATTR=NAME:send\nURL GOTO={{!COL1}}\n')

        if (j == 20 * x) {
            x++;
            break;
        }
    }
};//End of loop