简体   繁体   中英

Is there a way to disable alert/confirm boxes using chrome extensions for a particular website?

I am trying to make a chrome extension that opens a url that prompts the user to open an external application. The chrome browser prompts the user with a confirm box(OK or Cancel). I want to disable the confirm box for that website only (for security reasons) so that it opens the application without it.

Edit: It is not exactly a confirm box. It is box that says, [Cancel] and [Open With external application].

In the page context, you could overwrite window.confirm so that it returns true immediately, rather than opening the modal:

 window.confirm = () => true; if (confirm('OK?')) { console.log('Going...'); }

If the confirm modal opens immediately on pageload, make sure to have the extension run at document_start so that confirm gets overwritten immediately, rather than after a delay.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM