使用SET!VAR1 EVAL与javascript iMacros

时间:2017-11-30 08:31:20

标签: javascript url imacros

我有一个.js iMacros文件转到url,它看起来像这样:

for ( var k = 0; k<3; k++){
var congdong; 
congdong =  "CODE:";
congdong +=  "VERSION BUILD=8970419 RECORDER=FX" + "\n";
congdong +=  "SET !ERRORIGNORE YES" + "\n";
congdong +=  "SET !VAR1 EVAL(\"var letters = ['link1','link2','link3','link4','link5','link6','link7','link8']; var  results = []; for (var i = 0; i < 3; i++) {var pos = parseInt(Math.random()  * (letters.length - 1));results.push(letters[pos]);letters.splice(pos, 1);} results[i];\")" + "\n";
congdong +=  "TAB T=1" + "\n";
congdong +=  "URL GOTO={{!VAR1}}" + "\n";
iimPlay(congdong)
}

我的目标是每次去1个不同的网址时运行3次。但是,当我让它运行时,它不会转到任何网址,也不报告错误。关于如何让这个工作的任何想法?

非常感谢!

3 个答案:

答案 0 :(得分:1)

这样的事,也许?

// ...
congdong += "SET !VAR1 EVAL(\"var links = ['link1','link2','link3','link4','link5','link6','link7','link8']; links[Math.floor(Math.random() * links.length)];\")" + "\n";
// ...

请记住,如果你使用

SET !ERRORIGNORE YES

你不会看到任何错误。

答案 1 :(得分:1)

我的代码正在运行

var linkcd= [
'link1',
'link2',
'link3',
'link4',
'link5',
'link6',
'link7'
];
var resultscd = [];
for (var k = 0; k < 6; k++) {
var pos = parseInt(Math.random() * (linkcd.length - 1));
resultscd.push(linkcd[pos]);
linkcd.splice(pos, 1);
}

for (var k = 0; k < 3; k++) {
var congdong; 
congdong =  "CODE:";
congdong +=  "VERSION BUILD=8970419 RECORDER=FX" + "\n";
congdong +=  "SET !ERRORIGNORE YES" + "\n";
congdong +=  "SET !VAR1 \"" + resultscd[k] + "\"\n";
congdong +=  "TAB T=1" + "\n";
congdong +=  "URL GOTO={{!VAR1}}" + "\n";
iimPlay(congdong)
}

谢谢!

答案 2 :(得分:0)

由于我的浏览器存在问题,请不要对此进行测试,请检查以下代码并告诉我这是否可以解决您的问题!

cf_units