From iMacros Firefox to Userscript (Tampermonkey)

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
rapieragnay
Posts: 11
Joined: Sun Jan 24, 2021 11:06 am

From iMacros Firefox to Userscript (Tampermonkey)

Post by rapieragnay » Mon Mar 15, 2021 9:42 am

iMacros : 8.9.7
FF : 54
Win 7, 64bit


Good morning all,

With imacros javascript scripting, I created a small js script that fills out forms, browse and upload an image, register, retrieve the activation code by email and validate the account ...

To do this I used a lot of iimPlayCode() in my js.

Now I am limited because my js can only run with an older version of iMacros 8.9.7 with Firefox based browser. I cannot run my script in Opera, Chrome, or other browser. (It's unreliable to fake with the user agent).

So I plan to rewrite everything under Tampermonkey. In that case, do you have any idea how I can exploit imacros snippets in my new userscript?
Basically the Imacros commands I use revolve around:

Code: Select all

EVENT TYPE=CLICK
EVENTS TYPE=KEYPRESS
TAG POS=1 TYPE=INPUT:FILE
URL GOTO=
WAIT SECONDS=
and

with Components such us :

Code: Select all

const XMLHttpRequest  = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1", "nsIXMLHttpRequest");
Components.utils.import("resource://gre/modules/Services.jsm"); 
var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
var wm              = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
var window          = wm.getMostRecentWindow("navigator:browser");
var mainWindow      = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);
Thank you for your answers
Post Reply