How to use proxies in iMacros Firefox plugin, and adjust firefox settings on the fly!
If you haven’t used iMacros for Firefox yet, you’re missing out. You can do things like record your browsing habbits (button clicks, entered text, responses to dialogs, etc) to automate them. It has CSV support, so you can even use stored data to dynamically execute macros, directly from Firefox on Windows, Mac, and Linux.
The iMacros Firefox plugin is free, but the Pro edition is the best. It supports proxies natively, is much faster, and has many other functions not available to Firefox. Click here to check it out.
But if you’re looking to try it out before buying (or are too broke to get the Pro edition), you might want to keep reading. I’ll show you how to add proxy support to the Firefox plugin, and really change any Firefox config option you want with iMacros!
A little backstory:
I was searching for the ability to use proxies in macros for my own personal use, and wanted an easy language to learn. I spent a few hours searching, and iMacros seemed to be the best. The macro scripting language is super easy to learn, and there’s a ton of examples on their site. So I installed the plugin for Firefox, and started creating my macro.
I quickly discovered that the Firefox plugin doesn’t support proxies! After hours of searching for some other free macro engine that’s web-centric, I found nothing. I thought about writing a Firefox plugin to allow typed addresses in the URL bar to change info in Firefox’s about:config page. That could be bad though. Real bad. If users started installing it, it would only be a matter of time until someone used a hrefs maliciously and there was an epidemic of broken Firefoxes. What to do…
And then, epiphany. I recall some time ago a friend sent me a silly snippet of JavaScript code that you could paste into the address bar, and it would replace all the images with his own. Kind of rude, actually. Funny, but rude.
So, I opened up about:config. If you’re not aware, about:config lets you tweak almost every aspect of Firefox’s behavior and communications. Click here to read about it.
I had to use a few tools to get the source and general idea of what was happening in about:config, since I had never written a Firefox plugin or done any scripting with Firefox. After a few moments, I was able to construct a line of Javascript that changed one of the integer settings in about:config. Awesome! As it turns out, changing string settings is a bit more complicated to do via address bar JavaScript, but after digging deeper into the FireFox chrome source for about:config, I found a way.
If you don’t have FireFox iMacros installed, now would be the time to get it: https://addons.mozilla.org/en-US/firefox/addon/3863
To change a setting in about:config from iMacros (or any other macro engine for Firefox I suppose – just change the syntax), here’s the javascript:
For integer values:
URL GOTO=about:config
URL GOTO=javascript:gPrefBranch.setIntPref("SETTING.NAME",INTEGER_VALUE);
Just change "SETTING.NAME" to the name of the setting, like layout.spellcheckDefault, and INTEGER_VALUE to the desired integer value
For string values, this gets a little more complicated:
URL GOTO=about:config
URL GOTO=javascript:var<SP>prefb<SP>=<SP>Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);var<SP>str<SP>=<SP>Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);str.data<SP>=<SP>"STRING VALUE";prefb.setComplexValue("SETTING.NAME",<SP>Components.interfaces.nsISupportsString,<SP>str);
Change "STRING VALUE" to the desired value, and "SETTING.NAME" to the setting name.
And for boolean values:
URL GOTO=about:config
URL GOTO=gPrefBranch.setBoolPref("SETTING.NAME", true or false);
Once again, change "SETTING.NAME" to the desired Boolean variable, and "true or false" to either true or false.
So, now on to the fun stuff. Using it in a macro to change the proxy. For this example, I created a csv file at C:\sample.csv
In that csv file, I specified the following:
"ExampleURLtoVisit","proxyIP","proxyPort"
"http://whatismyip.com","192.168.1.1", 8080
"http://whatismyip.com","10.10.36.1", 3128
Here’s the code to use it::
VERSION BUILD=6240709 RECORDER=FX
TAB T=1
SET !DATASOURCE example.csv
SET !DATASOURCE_COLUMNS 4
PROMPT Enter<SP>the<SP>App<SP>OAuth<SP>URL: !VAR1
‘Increase the current position in the file with each loop
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
‘clear cookies and cache:
CLEAR
URL GOTO=about:config
’some proxies are slow, set the timeout to 90 seconds:
URL GOTO=javascript:gPrefBranch.setIntPref("network.http.keep-alive.timeout",900);
URL GOTO=about:config
’set the proxy URL
URL GOTO=javascript:var<SP>prefb<SP>=<SP>Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);var<SP>str<SP>=<SP>Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);str.data<SP>=<SP>"{{!COL2}}";prefb.setComplexValue("network.proxy.http",<SP>Components.interfaces.nsISupportsString,<SP>str);
URL GOTO=about:config
’set the proxy port:
URL GOTO=javascript:gPrefBranch.setIntPref("network.proxy.http_port",{{!COL3}});
URL GOTO=about:config
‘turn the proxy on
URL GOTO=javascript:gPrefBranch.setIntPref("network.proxy.type",1);
‘log in:
URL GOTO={{!COL1}}
’see:
WAIT SECONDS=5
‘disable proxy:
URL GOTO=about:config
URL GOTO=javascript:gPrefBranch.setIntPref("network.proxy.type",0);
Obviously the possibilities here are near limitless. Do a few google searches, this can be used for a TON of things. Some ideas:
- Change the user agent (general.useragent.override)
- Stop sending referer headers: (network.http.sendRefererHeader)
- Disable images on the fly for the purpose of faster macros (permissions.default.image)
Note: This is what’s used in the free script on http://www.scriptamp.com/myspaceappsmogul
Have fun, scripters!
Thanks for pass the tip to use proxy on Firefox using iMacros
2 Questions:
1 how do i get imacros act as roboform?
2 how did you get a sponsor, if you don’t mind tell me, i’d love to write up a niche site and get it sponsored by a company.
thanks it was very informative