In greasemonkey for chrome I’m using a function addJQuery(callback) that load jQuery and execute the callback function. So I call addJQuery(main). Inside main() i have a function colorizeMe() that i must call every 5 seconds.
function main() {
//change something using jQuery
$("#myid").css("width", "10%");
function colorizeMe(){
//colorize something using jQuery
$("#myid").css("color", "red");
}
setInterval("colorizeMe()", 5000);
}
addJQuery(main);
This doesn’t work and i have the error
Uncaught ReferenceError: colorizeMe is not defined
where and how i have to define the function colorizeMe() ? If i put colorizeMe() out of main i can use jQuery inside…
Try this:
Then the main of your user script should be: