I'm working on a Greasemonkey script that occasionally reloads a page and checks for updates. I'd like to be able to do a full-page reload without the side effect of having the page's title show "Loading..." each time.
Here's what I have so far. The jQuery loading code is from http://joanpiedra.com/jquery/greasemonkey/
// Add jQuery
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
// Check if jQuery's loaded
function GM_wait() {
if(typeof unsafeWindow.jQuery == 'undefined') {
window.setTimeout(GM_wait,100);
}
else { $ = unsafeWindow.jQuery; letsJQuery(); }
}
GM_wait();
// All your GM code must be inside this function
function letsJQuery() {
$(document).ready(main);
}
function main() {
setInterval(reload, 5000);
}
I thought this might make it work:
function reload() {
$(document).load('/');
}
However, on every invocation of reload()
I get a blank page and the following error from Firefox (3.0.13):
Error: H is undefined
Source File: http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js Line: 19