I wanted to write a very simple greasemonkey script because I hate the "are you sure?" javascript confirmation on a site I use a lot. I figured it would be pretty easy since I do use javascript a lot, this is my first greasemonkey script though. I'm just going to use it for personal use, not going to publish it or anything. After some googling I found http://wiki.greasespot.net/UnsafeWindow explaining what it seems that I want to do.
The source code for the page I want is like this
var message = "Are you sure?";
function confirmIt(message) {
var result = confirm(message);
return result;
}
I want to replace confirmIt(message) with just return true;
So I made a script
var oldFunction = unsafeWindow.confirmIt(message);
unsafeWindow.confirmIt(message) = function() {
return true;
};
I get the error "message is not defined."
I'm not sure if I'm going about this right (I'm thinking not), but I'd appreciate some guidance from someone with more experience in greasemonkey, about how to replace a javascript function on a page.