I'm trying to run an IMacros macro written in javascript on a webpage, like so:
for (var i = 1; i < 18; i++) {
document.querySelector(".foo table > tbody > tr:nth-child(" + i + ") > .goo:nth-child(2) > a").click();
document.querySelector(".foo > a").click();
if (i % 17===0) {
alert('Reset i');
i = 1;
}
}
Everything seems to work fine from the js console, but when I run the macro, I get:
"ReferenceError: document is not defined, line 2 (Error code: -991)"
I've loaded JQuery into iMacros with this, and put my code between:
$(document).ready(function () {
//
});
But I keep getting this error if I use JQuery:
TypeError: $ is not a function, line 28 (Error code: -991)
And if I only use JS, I get the same 'document is not defined' error as before.
So my question is, do I need to define the document, and how do I do it?