I'm trying to create a simple Greasemonkey script using jQuery
. jQuery
is already loaded from the page script.
I need a very simple change:
var $ = unsafeWindow.jQuery;
$("body").prepend('<button id="tsDownload">DownloadExcel</button>');
$("#tsDownload").click(function(){
alert("TEST!");
});
The script could add the button, but could not attach the click event, that part is simply ignored. Can you tell me why? Is something related to security?
For example after a few I discovered that I had to add the first line to get jQuery
from "unsafeWindow".
If I try this code from the console, it works! This is why I guess a security limit of Greasemonkey.