Can I call function() of my custom Greasemonkey from my page?
For example,
I created a GM script that contains do_this() function. I want my-web-site.com call the do_this() function. But I can't.
I know, I can by doing unsafeWindow.do_this() but doing so prevents me from calling GM_xmlhttpRequest().
Any ideas?
here the example that working, first create element then addEventListener
// ==UserScript==
// @name GM addEventListener Function Test
// @namespace ewwink.com
// @description GM addEventListener Function Test
// @include http://*
// ==/UserScript==
document.body.innerHTML+='<input type="image" id="alertMeID" onclick="do_this()" style="position:fixed;top:0;left:0" src="http://i55.tinypic.com/2nly5wz.gif" />';
document.getElementById('alertMeID').addEventListener('click', do_this, false);
function do_this(){
alert('hello World!, today is: '+new Date())
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With