Convert Javascript to Imacros

Discussions and Tech Support related to the iMacros Google Chrome extension.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Convert Javascript to Imacros

by girlygurl761 on Wed Dec 20, 2017 10:34 am

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
girlygurl761
 
Posts: 1
Joined: Wed Dec 20, 2017 10:25 am

Return to iMacros for Chrome

Who is online

Users browsing this forum: No registered users and 4 guests

-->