Convert Javascript to Imacros

Discussions and Tech Support related to the iMacros Google Chrome extension.
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
girlygurl761
Posts: 1
Joined: Wed Dec 20, 2017 5:25 pm

Convert Javascript to Imacros

Post by girlygurl761 » Wed Dec 20, 2017 5:34 pm

Looking to convert javascript macros used in Firefox back to .iim for use in Chrome. Here is one of the scripts I've been using. I've seen converters that will take .iim and convert to .js, but not the other way around.

Code: Select all

//imacros-js:showsteps no
var sleep = 5; //seconds to sleep beetween each egg set
var phrases = ["This egg smells faintly like brine",
               "This egg gleams with a reddish shine",
               "This egg is very reflective",
               "This egg shimmers like gold",
               "This egg has icicles forming on it",
               "This egg is almost too hot to touch",
               "This egg gives off a beautiful glow",
               "Whenever you go near this egg your hair stands on end",
               "This egg looks like it doesn't belong",
               "Oh my. There is a Leetle Tree among the eggs",
			   ]; //you can edit phrases
var location = "http://dragcave.net/locations/3";

var eggsfound=0;
do {
    var macro;
    macro =  "CODE:";
    macro +=  "URL GOTO="+ location+ "\n";
    var iret = iimPlay(macro);
    if (iret==-101)Abort();

    for (var i=1;i<=3;i++)
    {
        //click on egg
        var macro;
        macro =  "CODE:";
        macro +=  "SET !TIMEOUT_TAG 2" + "\n";
        macro +=  "TAG XPATH = \"(//div[text()[contains(.,\\\""+phrases.join("\\\") or contains(.,\\\"")+"\\\")]]/a)["+i+"]\"" + "\n";
        var iret = iimPlay(macro);
        if (iret==-101)Abort();

        //click Back if egg was found and clicked
        if (iret>0)
        {
            var macro;
            macro =  "CODE:";
            macro +=  "BACK" + "\n";
            iimPlay(macro);
            eggsfound++;
			iimDisplay(eggsfound)
        }
        else {
            break;
        }
    }
	iimDisplay(eggsfound)
    var macro;
    macro =  "CODE:";
    macro +=  "WAIT SECONDS=" + sleep + "\n";
    var iret = iimPlay(macro);
    if (iret==-101)Abort();
    iimDisplay(eggsfound)

}
while (true);

function Abort()
{
    throw "Aborted by user"
}
Operating System: macOS 10.13.1
IMacros Version: VERSION BUILD=1000
Chrome Version: Version 63.0.3239.84
Demo Macros work fine
Post Reply