Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use JavaScript in imacros?

I can't figure out how to use imacros with JavaScript. I have looked at their Help, have seen countless examples here on Stack Overflow, but don't know what am missing. It has not been explained clearly anywhere.

Here is what I tried:

  1. Used the example explained in their help file here: http://wiki.imacros.net/JavaScript

    But nothing happens when I click the 'Click Here to Run' link (even in IE with ActiveX). NOTE: I don't have imacros for IE - the example shown above has image of the macro start in IE, but run in Firefox. And no further explanation..

  2. Tried to import a JS file into imacros, but it doesn't seem to be working for me.

When I use code like the following:

var macro;
macro = "CODE:";
macro += "XXXXXX" + "\n";
macro += "XXXXXX" + "\n";

....
iimPlay(macro);

It says:

"Error -1100: Unknown command: VAR at line: 1"
  1. Tried to use the above inside a script tag of an HTML page, & load the functions on page-load/click. But that doesn't work either.

What am I doing wrong, and what do I need to do?

Soon after I posted this, I think I got it to work for a while. I was able to open a JS file which opened a URL. So I had deleted the Q. But now it isn't working again, and I can't figure out why.. Can somebody help?

Basically I am having the exact same problem as this person here: Javascript and Imacro to Open Google.com I get the same 'unknown command: var' as him. And their question remains unresolved too.

like image 837
user3001859 Avatar asked Aug 21 '14 14:08

user3001859


2 Answers

If you're experiencing this problem while using Chrome to run iMacros; the answer is really simple:

Download Firefox and run the iMacros plugin on there.

I experienced the same problem, receiving the error message: "Error -1100: Unknown command: VAR at line: 1", while using Chrome.

But with Firefox I can now run javascript files, have more options to play around with, and less bugs to disrupt my scrapes.

like image 171
troy Avatar answered Oct 12 '22 08:10

troy


It looks like you are trying to run javascript inside an iim file. Open notepad or another text editor and paste the following code:

var test;
test ="CODE:";
test +="SET !ERRORIGNORE YES "+"\n";
test +="URL GOTO=www.google.com "+"\n";

iimPlay(test)

Save the file with a .js extension. Next open up firefox and the iMacros addon. Go to Manage -> Settings -> Paths Tab -> Folder Datasource. Enter the path where you saved the file above. Refresh iMacros by clicking the iMacro button on and off. The javascript file should show up in the left pane. Run the file to test.

Folder DataSource

You should notice the icon to the left of the file name is different for the javascript files and the extension is ".js" instead of ".iim".

like image 23
Creamstout10 Avatar answered Oct 12 '22 08:10

Creamstout10