Call Imacros from JS Under FireFox

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
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
OrkyDD
Posts: 11
Joined: Thu Sep 20, 2007 2:57 pm

Call Imacros from JS Under FireFox

Post by OrkyDD » Fri Sep 21, 2007 2:19 am

Is it possible to call iimPlay from Javascript running in Firefox? I can make this work in IE by creating an activexobject("imacros") object, but is there any way to call the methods in the extension from a standalone javascript under FireFox?

I'd like to be able to generate the scripts on the fly and have the user execute them in firefox.
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Fri Sep 21, 2007 11:16 am

Hi,

Just to clarify: You do not mean the Javascript Scripting Interface inside iMacros (like in the "Si-Run-Test.js" example) but you want to trigger iMacros directly from Javascript that is embedded in your website?

In this case I recommend that you use http://run.imacros.net/?code=YOURCODEHERE
(Example imacros here)

You can generate the YOURCODEHERE string on-the-fly using (for example) Javascript, PHP, ASP or ASP.NET. The string (macro) is Base64 encoded. You can find function snippets for standard BASE64 encoding in any programming language on the web. Here is the code that is used in iMacros itself:

Base64 Encoder

Code: Select all

function encodeBase64(str){
    setBase64Str(str);
    var result = '';
    var inBuffer = new Array(3);
    var lineCount = 0;
    var done = false;
    while (!done && (inBuffer[0] = readBase64()) != END_OF_INPUT){
        inBuffer[1] = readBase64();
        inBuffer[2] = readBase64();
        result += (base64Chars[ inBuffer[0] >> 2 ]);
        if (inBuffer[1] != END_OF_INPUT){
            result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]);
            if (inBuffer[2] != END_OF_INPUT){
                result += (base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]);
                result += (base64Chars [inBuffer[2] & 0x3F]);
            } else {
                result += (base64Chars [((inBuffer[1] << 2) & 0x3c)]);
                result += ('=');
                done = true;
            }
        } else {
            result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30)]);
            result += ('=');
            result += ('=');
            done = true;
        }
        lineCount += 4;
      }
    }
    return result;
} 
Base64 Decoder (used inside iMacros to convert the YOURCODEHERE string back to a macro)

Code: Select all

function decodeBase64(str){
    setBase64Str(str);
    var result = "";
    var inBuffer = new Array(4);
    var done = false;
    while (!done && (inBuffer[0] = readReverseBase64()) != END_OF_INPUT
        && (inBuffer[1] = readReverseBase64()) != END_OF_INPUT){
        inBuffer[2] = readReverseBase64();
        inBuffer[3] = readReverseBase64();
        result += ntos((((inBuffer[0] << 2) & 0xff)| inBuffer[1] >> 4));
        if (inBuffer[2] != END_OF_INPUT){
            result +=  ntos((((inBuffer[1] << 4) & 0xff)| inBuffer[2] >> 2));
            if (inBuffer[3] != END_OF_INPUT){
                result +=  ntos((((inBuffer[2] << 6)  & 0xff) | inBuffer[3]));
            } else {
                done = true;
            }
        } else {
            done = true;
        }
    }
    return result;
}
  
Both functions use:

Code: Select all

function readReverseBase64(){   
    if (!base64Str) return END_OF_INPUT;
    while (true){      
        if (base64Count >= base64Str.length) return END_OF_INPUT;
        var nextCharacter = base64Str.charAt(base64Count);
        base64Count++;
        if (reverseBase64Chars[nextCharacter]){
            return reverseBase64Chars[nextCharacter];
        }
        if (nextCharacter == 'A') return 0;
    }
    return END_OF_INPUT;
}
You can also test the base64 encoding and decoding with an online service .
Image
Last edited by Tech Support on Tue Nov 13, 2007 11:27 pm, edited 1 time in total.
OrkyDD
Posts: 11
Joined: Thu Sep 20, 2007 2:57 pm

Post by OrkyDD » Fri Sep 21, 2007 2:22 pm

Yes, call it from outside.

And thanks, that is about the coolest thing I've ever seen from a vendor!
JSager
Posts: 5
Joined: Thu Mar 16, 2006 1:28 am

Post by JSager » Tue Dec 18, 2007 11:11 pm

Hi guys -

I am trying to use this feature. I am successfully base 64 encoding my command string, and I used the website you pointed us to in order to test to make sure that an independent base 64 decoder can read my string.

When I enter the URL into my browser, it just sits there forever.

Here's the string, it's just a simple URL goto on iopus's page. I was't sure whether I needed to proceed my string with CODE so here it is

without CODE:

http://run.imacros.net/?code=VVJMIEdPVE ... Zvcm0uYXNw

and with CODE:

http://run.imacros.net/?code=Q09ERTpVUk ... 9ybS5hc3A=


Any thoughts? I appreciate any help you can offer.
JSager
Posts: 5
Joined: Thu Mar 16, 2006 1:28 am

Post by JSager » Tue Dec 18, 2007 11:15 pm

By the way, when I click on the example imacros on delicious, I get the same behavior.

I am able to run macros using the firefox plugin just fine.
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Wed Dec 19, 2007 1:39 am

Your macro ("Without CODE:" version) runs well when I click on it:

http://run.imacros.net/?code=VVJMIEdPVE ... Zvcm0uYXNw


Are you using Firefox 3 Beta already? The run.imacros.net feature does not work in this version yet (we are working in it).
JSager
Posts: 5
Joined: Thu Mar 16, 2006 1:28 am

Post by JSager » Wed Dec 19, 2007 3:18 am

I'm running 2.0.0.11

I will start disabling extensions.
JSager
Posts: 5
Joined: Thu Mar 16, 2006 1:28 am

Post by JSager » Wed Dec 19, 2007 3:26 am

Well, that was strange. I disabled all my extensions, and it solved the problem. Then I re-enabled them one by one and now it's still working with all the extensions turned on.

Eh, shrug shoulders, move on.

Thanks for the help.
delfos_90
Posts: 6
Joined: Wed Apr 14, 2010 10:06 am

Re: Call Imacros from JS Under FireFox

Post by delfos_90 » Wed Apr 14, 2010 11:51 pm

I want to use this method to put my script into a webpage but i have to get first some values from a form that is in the same webpage, how i can wet it?
rudiedirkx
Posts: 1
Joined: Wed Jul 07, 2010 6:17 pm

Re: Call Imacros from JS Under FireFox

Post by rudiedirkx » Wed Jul 07, 2010 6:23 pm

I have a online application where sometimes I want the user to automatically upload a file in a predefined location. The perfect way would be to somehow run a macro with Javascript coming from my app (makes only sense), but that seems impossible.
The next best thing is the run.imacros.net website (why can imacros.net run a macro like that, but not me??). The macro should be triggered when the user logs in. My application uses events, one of which is the login event. When a few parameters are present, the macro should run, so I redirect the user/page/browser to the run.imacros.net website. When I get there, it says:

"You tried to run an embedded iMacros script but the iMacros Firefox Add-on is not installed yet. Please install the free, open source iMacros Firefox extension to run the shared browser scripts:"

Then, if I copy the URL in the addressbar and paste it into a new tab, it works perfectly (although it asks if it should run the macro, which is annoying (can you "trust" a website or something??))!

How come Firefox (or run.imacros.net) thinks the addon isn't installed? It is!

Thanks a whole bunch!


Btw the URL with macro is http://run.imacros.net/?code=VVJMIEdPVE ... 9ORFM9Mw== (for now just a redirect back to my app + a wait)
jimbobarto
Posts: 6
Joined: Fri Jan 21, 2011 10:20 am

Re: Call Imacros from JS Under FireFox

Post by jimbobarto » Thu Jan 27, 2011 4:25 pm

This feature is great. For my purposes though it's got one nasty problem. Part of my macros include passwords that I don't want to be sending externally, no matter how safe the service is. Is there any way of doing this without using the http://run.imacros.net/?code= service?
brunoais
Posts: 37
Joined: Sun Feb 17, 2008 2:08 pm

Re: Call Imacros from JS Under FireFox

Post by brunoais » Wed Feb 09, 2011 8:06 am

Well. they could use the events system for the activation of macros inside web pages...
fastviper
Posts: 46
Joined: Tue Mar 15, 2011 1:30 pm

Re: Call Imacros from JS Under FireFox

Post by fastviper » Thu Apr 07, 2011 1:10 pm

WARNING: This feature stopped working in 7.2.0.x version of plugin.
Do not upgrade your plugin!
COSMOS
Posts: 20
Joined: Thu Jul 28, 2016 5:11 am

Re: Call Imacros from JS Under FireFox

Post by COSMOS » Fri Dec 09, 2016 9:09 am

Hey guys,

It's been a while since the last post here. Sorry for bringing this thread alive but I'm in desperate need of this functionality:

"http://run.imacros.net/?code=YOURCODEHERE"

Does this still work ?
I tried adding a simple code in there but it just keeps on loading. Nothing is happening.
Any tips ?

Thank you !
chivracq
Posts: 8620
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Call Imacros from JS Under FireFox

Post by chivracq » Fri Dec 09, 2016 12:25 pm

COSMOS wrote:Hey guys,

It's been a while since the last post here. Sorry for bringing this thread alive but I'm in desperate need of this functionality:

Code: Select all

http://run.imacros.net/?code=YOURCODEHERE
Does this still work ?
I tried adding a simple code in there but it just keeps on loading. Nothing is happening.
Any tips ?

Thank you !
CIM...! :mrgreen: (Always mention your FCI (read my Sig) when you open a Thread or post for the first time in an existing Thread, many Commands are not implemented for all Browsers/Versions or get broken from some specific Version...)

But, yep, I think this Syntax doesn't work anymore since a few years, but [url=imacros://run/?code=VkVSU0lPTiBCVUlMRD04ODIwNDEzIFJFQ09SREVSPUZYDQpVUkwgR09UTz1odHRwOi8vZm9ydW0uaW1hY3Jvcy5uZXQvdmlld3RvcGljLnBocD9mPTExJnQ9MjY3NDUjcDcxMDkx]this one[/url] should work, ah-ah...!
(Tested on iMacros for FF v8.8.2, Pale Moon v26.3.3. (=FF47), Win10-x64.)

And I used this Site to base64-encode my mini-Macro (which simply takes you to some other Thread on the Forum with more Info).
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply