Search code examples
javascriptgreasemonkey

How can I get greasemonkey to call a function on a page after it loads


I have a very simple greasemonkey script that I want to call an already existing javascript function on the page. I've read the documentation and nothing seems to work

window.setTimeout(function() { 
    alert('test') // This alert works, but nothing after it does
    myFunction() // undefined
    window.myFunction() // undefined
    document.myFunction() // undefined
}, 1000);

Solution

  • Try using: unsafeWindow.myFunction();

    More details and info - http://wiki.greasespot.net/UnsafeWindow