Using JQuery with iMacros

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

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.

Using JQuery with iMacros

by cbelerique on Fri Aug 18, 2017 12:43 pm

Greetings all, I am a long time lurker first time poster.

I've found a few posts on the web about using JQuery in iMacros but none seem to work.

Here is one:

Code: Select all
function loadScriptFromURL(url) {
    var request = Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Components.interfaces.nsIXMLHttpRequest),
        async = false;
    request.open('GET', url, async);
    request.send();
    if (request.status !== 200) {
        var message = 'an error occurred while loading script at url: ' + url + ', status: ' + request.status;
        iimDisplay(message);
        return false;
    }
    eval(request.response);
    return true;
}

// load JQuery
loadScriptFromURL('http://mysupersecret.blob.core.windows.net/share/jquery-2.0.3.min.js');
$ = window.$,
JQuery = window.JQuery;


Is this correct? Do I have to add this to each macro I plan to use it with or can I reference it somehow? I've tried adding it to a js file with JQuery but it doesn't like the line "$ = window.$,"

Any advice would be appreciated, thanks!

Using Firefox 55.0.2 (32-bit) and whatever iMacros is the latest as of 08-18-2017
cbelerique
 
Posts: 4
Joined: Fri Aug 18, 2017 11:25 am

Re: Using JQuery with iMacros

by iimfun on Tue Aug 22, 2017 11:38 pm

Hi, your script seems to work fine. And I run with no problem this one

Code: Select all
function loadScriptFromURL(url) {
   var request = Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Components.interfaces.nsIXMLHttpRequest),
   async = false;
   request.open('GET', url, async);
   request.send();
   if (request.status !== 200) {
      var message = 'an error occurred while loading script at url: ' + url + ', status: ' + request.status;
      iimDisplay(message);
      return false;
   }
   eval(request.response);
   return true;
}

loadScriptFromURL("https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js");
$ = window.$,
JQuery = window.JQuery;
alert($);

Tested on Firefox Portable 47.0.1, iMacros for Firefox 8.9.7.
iimfun
 
Posts: 238
Joined: Tue Jul 19, 2016 6:06 am

Re: Using JQuery with iMacros

by cbelerique on Wed Aug 23, 2017 8:11 am

How do I actually use that? Would I put that at the top and then add standard JQuery underneath it? Thanks.
cbelerique
 
Posts: 4
Joined: Fri Aug 18, 2017 11:25 am

Re: Using JQuery with iMacros

by iimfun on Fri Aug 25, 2017 12:15 am

Why don't you try anything?.. Just write your script below the loading part and enjoy jQuery. What's the problem?
iimfun
 
Posts: 238
Joined: Tue Jul 19, 2016 6:06 am

Re: Using JQuery with iMacros

by cbelerique on Fri Sep 08, 2017 8:11 am

Sorry for the late response I've been dealing with Hurricane Harvey. I did try what you suggested but I got error messages and thought I was doing it wrong.

I got:

Error: Accessing content window is not supported in multiprocess Firefox, line 382 (Error code: -991)

Is there a browser that supports multiprocess besides downgrading FF? Thanks.
cbelerique
 
Posts: 4
Joined: Fri Aug 18, 2017 11:25 am

Re: Using JQuery with iMacros

by iimfun on Sun Sep 10, 2017 11:23 pm

Well, here is a note taken from the wiki
Please note that iMacros version 8.9.7 will work with Firefox 48 and later if multi process (e10s) is disabled. See also How to downgrade iMacros

So you have to downgrade iMacros only.


You can also try to use jQuery under iMacros for Chrome through the 'URL GOTO' command like this

Code: Select all
URL GOTO=javascript:document.body.appendChild(document.createElement("script")).src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";
WAIT SECONDS=3
URL GOTO=javascript:alert($);
iimfun
 
Posts: 238
Joined: Tue Jul 19, 2016 6:06 am


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 4 guests

-->