Extend Your Firefox iMacros

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
blueX324
Posts: 1
Joined: Sun Apr 29, 2012 4:00 am

Extend Your Firefox iMacros

Post by blueX324 » Sun Apr 29, 2012 4:46 am

Hi All,

I want to share my little work on imaros mods.

Add some useful functions:

1. file read/write
2. register function: remember the status of your script
3. sqlite function: extract web data into database
4. delay play your imacros

The more useful I think is: extension support. Write your extension and place it into Exts directory adn load it in code.
For example, there is a jquery extension in attach. You can use jquery like this:

iimLoadExt('jquery.js');

alert(jQuery.trim(' abcd '));

iimPlay("CODE:URL GOTO=http://www.baidu.com");
$("#su").val('Google');

-----------------------------------------------------------------------------------------------------------------
This is how:

First download the attachment, and extract to your imacros working directory. It looks like this:

imacros
-- Macros
-- Datasources
-- Datasources
-- Exts

Then open the imacros.jar, find the file browserOverlay.xul, add:

<script type="application/x-javascript;version=1.7" src="chrome://imacros/content/ext.js"/>

Save it!

Last, drop file "ext.js" into the imacros.jar.

Now it should work.
Attachments
Exts.rar
(51.39 KiB) Downloaded 561 times
stevenp
Posts: 16
Joined: Tue Jun 18, 2013 12:27 am

Re: Extend Your Firefox iMacros

Post by stevenp » Sat Sep 14, 2013 10:26 pm

Hmmm!
What a nice library, so pity that i've come across it only now.

Code: Select all

//Execute imacro command directly, can use [SP] - ' ', [LF] - '\r', [BR] - '\n'
//eg. iimPlayExt('URL GOTO=http://www.iopus.com/');
function iimPlayExt(command) {
	return iimPlay('code:' + command);
}
I checked the iimPlayExt function and now wondering what's the reason behind this function.
it just prepends the code with "CODE:"
it would be great if it could at least convert handle " " spaces to "<SP>" where appropriate, e.g. "TAG POS=1 ... ATTR=CLASS:some<SP>classes"

I've found iimSqlite functions in ext.js, but is it possible to connect to some NoSQL Database like MongoDB?

Will jQuery work in different contexts once loaded?
How about the famous "TypeError: can't access dead object"?

Thanks for your hard work
viking
Posts: 244
Joined: Sun Mar 16, 2008 7:22 am

Re: Extend Your Firefox iMacros

Post by viking » Sun Sep 15, 2013 8:07 pm

This should be made a sticky!
It would also be great if there were some more documentation, in particular for those less experienced with programming.

I tried to use the delay function, but I couldn't get it to work
1. I followed the installation instructions above; when re-saving the jar file, I saved it as imacros.zip and then simply renamed it to imacros.jar
2. I then created a macro and javascript:
A. junk.iim

Code: Select all

PROMPT ("Hello")
b. junk.js

Code: Select all

iimTaskDelayExt(junk.iim, 5);
Executing junk.iim works fine, but when I try to execute junk.js, I get an error:
ReferenceError: iimTaskDelayExt is not defined, line: 1 (Error code: 991)

I guess that I did not install the extension properly, but I cannot figure out what I did wrong....

I use FF22 & iMacros v8.3.0
ravi_npatty
Posts: 22
Joined: Sat May 07, 2011 6:12 am

Re: Extend Your Firefox iMacros

Post by ravi_npatty » Mon Apr 17, 2017 6:21 pm

blueX324 wrote: I want to share my little work on imaros mods.
Thanks blueX324 for such a nice library. I started using sqlite for my work and it is good alternative for csv file to store and retrieve data.

As long as I use simple query, it works. But I could not get parameterized query working with it. Please find my code below

Code: Select all

        var db=new iimSqlite("test_v1.sqlite");
	db.exec('create table if not exists test ([ID] text primary key,[col 1] text,[col 2] number,[col 3] text);');
	alert("create table ok");
	sql='insert or replace into test ([ID],[col 1],[col 3],[col 2]) values(:id, :col1, :col3, :col2);';
	param=[{name:"id",value:"255"},{name:"col1",value:"col1 text"},{name:"col2",value:458752},{name:"col3",value:"col3 text"},]
	alert(sql);
	db.exec(sql,param);
	alert("insert ok");
	db.close();
Please point out what mistake I am doing.

Thanks.
ravi_npatty
Posts: 22
Joined: Sat May 07, 2011 6:12 am

Re: Extend Your Firefox iMacros

Post by ravi_npatty » Thu Apr 20, 2017 2:48 pm

I have solved this issue. There was problem in binding parameter inside the library (iimext.js). I am posting the modified code here so that people need not solve it again.
I have commented old code for reference purpose.

A small change in approach now.
In earlier code, parameter was passed as param=[{name:"paramname1",value:"paramvalue1"},{name:"paramname2",value:"paramvalue2"},...]
In my modified code, I use param={paramname1:paramvalue1,paramname2:paramvalue2,...}

Similar change is required in query function also.

My code is here

Code: Select all

	iimSqlite.prototype.exec = function(sql, params) 
	{
		  //this.dbConn.executeSimpleSQL(sql);
		var stmt = this.dbConn.createStatement(sql);
		if (typeof(params) =="object") 
		{
			var bp;
			var _params = stmt.newBindingParamsArray();
			if(typeof(params.length)=="undefined")
			{				
				bp = _params.newBindingParams();  
				for(var prm in params) bp.bindByName(prm, params[prm]); 
				
				_params.addParams(bp); 	
			}
			else
			{
				
				alert("error");
			}
			
			
			//for (var i = 0, j = params.length; i < j; i++) 
			//{  
			//	var bp = _params.newBindingParams();  
			//  	bp.bindByName(params[i].name, params[i].value);  
		    //		_params.addParams(bp); 		    		
			//}			
			stmt.bindParameters(_params); 				
		}
		stmt.execute();		
		stmt.finalize();		
	}
	
	//params: {name1: value1,name2:value2,...}
	iimSqlite.prototype.query = function(sql, params) 
	{
		var stmt = this.dbConn.createStatement(sql);
		var results = new Array();
		if (typeof(params) =="object") 
		{
			var bp;
			var _params = stmt.newBindingParamsArray();
			if(typeof(params.length)=="undefined")
			{				
				bp = _params.newBindingParams();  
				for(var prm in params) bp.bindByName(prm, params[prm]); 
				
				_params.addParams(bp); 	
			}
			else
			{
				
			}
		}
		
		var colNames = new Array();
		var i = 0;
		while(1) 
		{
			try 
			{
				var colName = stmt.getColumnName(i++);
				colNames.push(colName);
			}	
			catch(e) 
			{
				break;
			}	
		}
					
		try 
		{
			while(stmt.executeStep()) 
			{
				var aRow = new Object();
			  	for (var i = 0, j = colNames.length; i < j; i++) 
			  	{
			  		aRow[colNames[i]] = stmt.row[colNames[i]];
				}
				results.push(aRow);
			}
		} 
		catch(aError) 
		{
			iimDisplay("Error: " + aError.message);
		}
		stmt.finalize();
		
		if (results.length == 0) 
		{
			return null;
		}
		else if (results.length == 1) 
		{
			return results[0];
		}
		return results;
	}
	
	
zhedielj
Posts: 19
Joined: Wed Apr 02, 2014 3:08 pm

Re: Extend Your Firefox iMacros

Post by zhedielj » Fri Apr 19, 2019 9:48 am

My Env: Win10 X64 FF53 iMacros8.9.7
The iMacros plugin disappeared after modified. Which version dose this method supported?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extend Your Firefox iMacros

Post by chivracq » Fri Apr 19, 2019 1:45 pm

zhedielj wrote:
Fri Apr 19, 2019 9:48 am
My Env: Win10 X64 FF53 iMacros8.9.7
The iMacros plugin disappeared after modified. Which version dose this method supported?
Yep, it should work in your FCI, I think, as I used it a bit recently (for some similar Customization) a few months ago on v10.0.2 for FF ('Free') + FF63 (I think), and it was still working... (Except that FF63 I was using is now "tighter" on Security and the "Model" for Add-ons got completely revamped with WebExtensions like you must know, and I had to use the Developer's Mode to be able to add/use "my own" Add-on, and I didn't bother to self-sign it as it was just for a "Test"...)

I don't understand your "disappeared"...?, or do you mean you tried to modify the 'imacros.jar' "directly" from the Add-on already installed to FF in your FF Profile...?
I'm not sure that would work indeed, and I've never tried, but that wouldn't be the "best" Method anyway, because if you ever update the Add-on and/or want to reinstall v8.9.7, your Changes will get lost. :oops:

The Method I use myself is to first download locally the '.xpi' File for the Add-on.
Make a Copy to keep the "Original".
Using '7Zip', unpack the '.xpi. File (=> 'Open Archive'), and do any Modification to any File from inside '7Zip' (=> 'Edit') before saving the/each '.xul' or '.js' File(s), and the whole '.xpi' "Container" still from '7Zip'.
Then add that new '.xpi'/Add-on to FF by drag&drop onto the Add-ons Page. Both the "original" and your customized Version can "live" together in a same FF Profile if you want, I usually customize also stg "visual" from the Side Panel to know which one is which one(!), or you may sometimes click on the "wrong" Icon to start iMacros. 8)

And you keep your customized '.xpi' if you ever need to reinstall it, or to install it to different FF Profiles.
And if you ever update iMacros to some later Version, your Customization(s) get lost and you need to customize again the new Version. But that shouldn't really apply anymore with v8.9.7 as iMacros would then update directly to v10.0.2 with WebExtensions (provided you also update FF to v60/65) but the Content of the '.xpi' is now pretty different..., and v10.0.2 doesn't support '.js' Scripts anyway...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
zhedielj
Posts: 19
Joined: Wed Apr 02, 2014 3:08 pm

Re: Extend Your Firefox iMacros

Post by zhedielj » Sat Apr 20, 2019 8:47 am

chivracq wrote:
Fri Apr 19, 2019 1:45 pm
zhedielj wrote:
Fri Apr 19, 2019 9:48 am
Thank you so much. I have modified the xpi file with your method, but I can't use the extension command.
When I use function iimLoadExt,i got a error message "ReferenceError: iimLoadExt is not defined, line: 1 (Error code: 991)
I only give one line command : iimLoadExt('jquery.js');
I saved that one line command file as test.js, and I have extract Exts.rar to my imacros working directory.
I found the 3rd floor have the same problem with me.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extend Your Firefox iMacros

Post by chivracq » Sat Apr 20, 2019 4:00 pm

zhedielj wrote:
Sat Apr 20, 2019 8:47 am
zhedielj wrote:
Fri Apr 19, 2019 9:48 am
Thank you so much. I have modified the xpi file with your method, but I can't use the extension command.
When I use function iimLoadExt,i got a error message "ReferenceError: iimLoadExt is not defined, line: 1 (Error code: 991)
I only give one line command : iimLoadExt('jquery.js');
I saved that one line command file as test.js, and I have extract Exts.rar to my imacros working directory.
I found the 3rd floor have the same problem with me.
"... and I have extract Exts.rar to my imacros working directory."
=> No, this is not correct, it is "ext.js" and not "Exts.rar" and you must place it at the exact Location in 'imacros.jar' that you specify in the 'browserOverlay.xul', and that will be: "//imacros/content/" and not your "imacros working directory. :!:

It's 'jquerry.js' that you need to place/copy in your 'iMacros' Working Directory, in the '\Exts\' Folder... Read the Instructions from the 1st Post in this Thread...
Last edited by chivracq on Sun Apr 21, 2019 3:24 am, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
zhedielj
Posts: 19
Joined: Wed Apr 02, 2014 3:08 pm

Re: Extend Your Firefox iMacros

Post by zhedielj » Sun Apr 21, 2019 1:40 am

chivracq wrote:
Sat Apr 20, 2019 4:00 pm
zhedielj wrote:
Sat Apr 20, 2019 8:47 am
zhedielj wrote:
Fri Apr 19, 2019 9:48 am


"... and I have extract Exts.rar to my imacros working directory."
=> No, this is not correct, it is "ext.js" and not "Exts.rar" and you must place it at the exact Location in 'imacros.jar' that you specify in the 'browserOverlay.xul', and that will be: "//imacros/content/" and not your "imacros working directory. :!:

It's 'jquerry.js' that you need to place/copy in your 'iMacros' Working Directory, in the '\Exts\' Folder... Read the Instructions from the 1 Post in this Thread...
Yes, I have followed the 1 post and your's instructions to modify that xpi file.
1. Add two line commands in browserOverlay.xul
2.add ext.js into imacros.jar\content\
3.extract exts.rar to imacros working directory
But all the extension commands will get "* is not defined, line 1 (Error code: -991)"
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extend Your Firefox iMacros

Post by chivracq » Sun Apr 21, 2019 3:36 am

zhedielj wrote:
Sat Apr 20, 2019 8:47 am
Yes, I have followed the 1 post and your's instructions to modify that xpi file.
1. Add two line commands in browserOverlay.xul
2.add ext.js into imacros.jar\content\
3.extract exts.rar to imacros working directory
But all the extension commands will get "* is not defined, line 1 (Error code: -991)"
Ah OK, I had not downloaded and checked the Content of the 'Exts.rar' File attached to the 1st Post which indeed contains some 'jquery.js' Library... (from 2011 btw, must be some "old" Version, you might still want to replace it with a "newer" Version actually...)
Your Setup now looks correct to me, I would think... Then I don't know, I've never tried this Setup as I don't use '.js' Scripts... You would need to wait/hope for sbd using this Method to hopefully be of more assistance than me then... :oops:
Last edited by chivracq on Sun Apr 21, 2019 1:23 pm, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
zhedielj
Posts: 19
Joined: Wed Apr 02, 2014 3:08 pm

Re: Extend Your Firefox iMacros

Post by zhedielj » Sun Apr 21, 2019 4:06 am

chivracq wrote:
Sun Apr 21, 2019 3:36 am
zhedielj wrote:
Sat Apr 20, 2019 8:47 am

Ah OK, I had not downloaded and checked the Content of the 'Exts.rar' File attached to the 1st Post which indeed contains some 'jquery.js' Library...
Your Setup now looks correct to me, I would think... Then I don't know, I've never tried this Setup as I don't use '.js' Scripts... You would need to wait/hope for sbd using this Method to hopefully be of more assistance than me then... :oops:
You have given lots of help, thanks again.
Post Reply