iMacros for Chrome in Ubuntu coding random numb help please.

Discussions and Tech Support specific to the iMacros for Chrome extension.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
ve_krin
Posts: 1
Joined: Mon Feb 01, 2010 9:35 am

iMacros for Chrome in Ubuntu coding random numb help please.

Post by ve_krin » Mon Feb 01, 2010 12:01 pm

Hello, I am sorry if this somehow had been answered, because I couldn't find the answer.

I just installed iMacros for Chrome in Ubuntu and would like to make a code to refresh a page, which then I will loop it.
The code might have been:

Code: Select all

URL GOTO=http://www.google.com/
WAIT SECONDS=600
But the problem comes when I want to have a random time for refreshing. Let say the page would be google and the time is 10 minutes +- 10 seconds.

I found http://wiki.imacros.net/Random-Numbers.vbs which might help me create random number to use in the iMacros script. But how to integrate the vbs and iMacros coding? where do I put the scripts? How to run them?

Another question:
Can we have javascript and run it in Google Chrome? via iMacros?
How to open iMacros window for recording and playing?

Thanks bunch for the help. ;)
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: iMacros for Chrome in Ubuntu coding random numb help please.

Post by Daniel, Tech Support » Tue Feb 02, 2010 2:35 pm

Hello,

Unfortunately scripting is currently unavailable with Chrome plugin, although it is planned. However you can easily use scripting with Firefox plugin. Javascript is the scripting language that Firefox understands.

Here are some links to start with:
http://wiki.imacros.net/Web_Scripting#C ... _Interface
http://wiki.imacros.net/JavaScript

And here is a JavaScript that you can run in your Firefox iMacros plugin, which will do what you wanted to accomplish:

Code: Select all

var macro, iret;
var min = 5; //Minimum of 5 seconds for testing - change to real value
var max = 10; //Maximum of 10 seconds for testing - change to real value

function getRandomInt(min, max)
{
	return Math.floor(Math.random() * (max - min + 1)) + min;
}

function startMacro(delay)
{
	macro = "CODE:";
	macro += "VERSION BUILD=6311226 RECORDER=FX\n";
	macro += "URL GOTO=http://www.google.com\n";
	macro += "WAIT SECONDS=" + delay;
	iret = iimPlay(macro)
}

var stop=0; //you can delete this variable, I put it simply to avoid an endless loop.
do
{
	startMacro(getRandomInt(min, max));
	stop++; //same as previous comment
}
while(stop<10) //set a real-life condition here and remove stop variable afterwards.
Feel free to ask any further questions that will arise!
Daniel, iOpus Support
Post Reply