Hello.
I create a custom script for FireFox (GreaseMonkey plugin). The functions that I declared in UserJS are not available in the page context. For example.
// ==UserScript== // @include * // ==/UserScript== function go(){ alert("Okey"); }; body=document.getElementsByTagName("body")[0]; span=document.createElement("span"); span.innerHTML="<INPUT type=button onclick=\"javascript:go();\" value=click />"; body.appendChild(span);
When clicking on the button in the console, the error falls
go is not defined
That is, there is no such function in the context of the page; it exists only in the context of the GreaseMonkey extension.
How can I solve this problem while maintaining UserJS cross-browser compatibility? I don't want to write something like
if (browser=="firefox"){ span.innerHTML="Вариант для FireFox"; } else { span.innerHTML="Вариант для Chrome, Opera, Safari"; };