Tampermonkey などの処理で、確認ダイアログ(アラートメッセージ)がポップアップしてきた場合、確認ボタンをJavascript側でクリックするという処理ができない。
調べたところ、その場合は、confirm メソッドをオーバーライドすることで
確認ダイアログをポップアップさせずに、ボタンをクリックさせたことにすることが可能となる。
var realConfirm=window.confirm; window.confirm=function(){ window.confirm=realConfirm; return true; };
参考記事
![](https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a)
How to automatically click a confirm box?
My script clicks an image on a site. The image has an anchor href and an onclick href, but the onclick href has a confir...
![](https://www.grepper.com/images/logo_colors_small.png)
jquery automatically click message alert - Code Examples & Solutions
var realConfirm=window.confirm; window.confirm=function(){ window.confirm=realConfirm; return true; };