Using JQuery with iMacros

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
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
cbelerique
Posts: 4
Joined: Fri Aug 18, 2017 6:25 pm

Using JQuery with iMacros

Post by cbelerique » Fri Aug 18, 2017 7: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
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Using JQuery with iMacros

Post by iimfun » Wed Aug 23, 2017 6:38 am

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.
cbelerique
Posts: 4
Joined: Fri Aug 18, 2017 6:25 pm

Re: Using JQuery with iMacros

Post by cbelerique » Wed Aug 23, 2017 3:11 pm

How do I actually use that? Would I put that at the top and then add standard JQuery underneath it? Thanks.
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Using JQuery with iMacros

Post by iimfun » Fri Aug 25, 2017 7:15 am

Why don't you try anything?.. Just write your script below the loading part and enjoy jQuery. What's the problem?
cbelerique
Posts: 4
Joined: Fri Aug 18, 2017 6:25 pm

Re: Using JQuery with iMacros

Post by cbelerique » Fri Sep 08, 2017 3:11 pm

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.
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Using JQuery with iMacros

Post by iimfun » Mon Sep 11, 2017 6:23 am

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($);
Post Reply