我这里有Facebook的iMacros / JS脚本,需要从CSV文件登录到FB帐户,然后脚本有第二个循环j
,这是发送
来自1个账户的20位朋友请求。
问题是,当您更改帐户时,有一条弹出消息需要您验证电话号码,在这种情况下我需要跳过此帐户并转到其他帐户。
此代码表示如果在页面上显示消息,则必须从j
循环中断:
if(iimPlayCode('TAG POS=1 TYPE=DIV ATTR=CLASS:"_2e9n"')>0) {
break;}
问题是,当脚本跳过此帐户时,它会跳过其他CSV文件中的20个朋友网址。
所以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
答案 0 :(得分:1)
我认为你需要这样的东西:
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