How to write a greasemonkey script to remove a confim dialog?

I wanted to write a very simple greasemonkey script because I hate "are you sure?" javascript confirmation on site I use a lot. I'm just going to use it for personal use, not going to publish it or anything else. After some Googling, I found http://wiki.greasespot.net/UnsafeWindow , explaining that it seems to me what I want to do.

The source code for the page I want is similar to this

var message = "Are you sure?";
function confirmIt(message) {
    var result = confirm(message);
    return result;
}

I want to replace confirmIt (message) by simply returning true,

So I made a script

var oldFunction = unsafeWindow.confirmIt(message);
    unsafeWindow.confirmIt(message) = function() {
    return true;
};

I get the error "not defined."

, ( ), -, Greasemonkey, , Javascript .

+3
1

unsafeWindow.confirmIt ( ). , , , :

var oldFunction = unsafeWindow.confirmIt;

unsafeWindow.confirmIt = function(message) {
    return true;
};

.

+4

Source: https://habr.com/ru/post/1756665/


All Articles