I have this userscript:
// ==UserScript==
// @name test
// @namespace test
// @description show\'s an alert on load
// @include http://*
This call may be being loaded too late on the page. Add this code to the very top of the page and see if that fixes it.
If that isn't it please post some additional information. (Where the call is being made? Some more information on the page? Is this being called from an external .js file?)
The cause of the problem is that the Content script is sometimes executed when the document has already fully loaded. This is illustrated using the following Content script ("User Script"):
// ==UserScript==
// @name Test
// @namespace Test
// @include *
// ==/UserScript==
window.addEventListener('load', function(){alert("loaded");}, false);
alert(document.readyState); // When this prints "complete", onload never runs
To solve the issue, use the @run-at document-start meta-rule, which causes the script to execute before the document is created:
...
// @run-at document-start
// ==/UserScript==