Random select drop down menu imacros

2019-07-29 12:00发布

问题:

I am trying to figure out how to randomized a drop down menu in iMacros.

This is the current script.

TAG POS=1 TYPE=SELECT FORM=ACTION:/es/crear-tu-blog/ ATTR=NAME:domain CONTENT=$activos-blog.net

There are like 30 alternative for this drop down menu, I want to make it select a random alternative. How can i do this?.

回答1:

You need something like this:

SET !VAR1 EVAL("var randomDomain=Math.floor(Math.random()*30 + 1); randomDomain;")
TAG POS=1 TYPE=SELECT FORM=ACTION:/es/crear-tu-blog/ ATTR=NAME:domain CONTENT=%{{!VAR1}}

Where 30 is the number of elements in the drop down menu, and the % indicates we are selecting the option by its value.

For example, I'm expecting the option to be:

<option value="12">activos-blog.net</option>

If the value is a string, then you should select the option by its index, using #.



回答2:

You can select the dropdown menu like this.

This is the current script.

TAG POS=1 TYPE=SELECT FORM=ACTION:/es/crear-tu-blog/ ATTR=NAME:domain CONTENT=#5

In some cases, I saw %5 so I am not sure is it % or # before the number. The number 5, in this case, is just an example.

Here is what it says on iMacros.

http://wiki.imacros.net/TAG

Scroll down to where it says dropdown menu.

The next step is to create a random number with use of JavaScript. On the link below, you can get the functions for that purpose.

Generating random whole numbers in JavaScript in a specific range?

After you've mastered that the next step is to implement it in iMacros. You have to use JavaScript scripting.

var macro;

macro ="CODE:";
macro +="TAG POS=1 TYPE=SELECT FORM=ACTION:/es/crear-tu-blog/ ATTR=NAME:domain CONTENT=#{{number}}";


iimSet("number",some_random_number)
iimPlay(macro)