Created
December 11, 2013 05:30
-
-
Save jonathanconway/7905527 to your computer and use it in GitHub Desktop.
A few handy functions to use with jQueryGo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.jquerygocontrib = function () { | |
var $ = require('jquerygo'); | |
$.evaluate = function (functionToEvaluate, callback, args) { | |
$.getPage(function (page) { | |
page.evaluate(functionToEvaluate, callback, args); | |
}); | |
}; | |
$.getlength = function (selector, callback) { | |
$.evaluate(function (args) { | |
return $(args.selector).length; | |
}, function (err, returnVal) { | |
callback(returnVal); | |
}, { | |
selector: selector | |
}); | |
}; | |
$.followLink = function (selector, callback) { | |
$.evaluate(function (args) { | |
document.location = $(args.selector).attr('href'); | |
}, function (err, returnVal) { | |
callback(); | |
}, { | |
selector: selector | |
}); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment