Can I prevent an alert() with a Google Chrome Extension

Drew LeSueur picture Drew LeSueur · Jun 3, 2010 · Viewed 12k times · Source

Can I create a Google chrome extension to prevent the page from doing an alert() ?

Answer

Mohamed Mansour picture Mohamed Mansour · Jun 5, 2010

Yes you can, alert() is just a JavaScript method, you can override its functionality by doing.

window.alert = function alert(msg) {
  console.log('Hidden Alert ' + msg);
};

Just remember to run that content script at document_start within the manifest via run_at manifest content script modifier.

I believe there is an extension that just does that. The developer names it Nice Alert. https://chrome.google.com/extensions/detail/ehnbelnegmgdnjaghgomaakjcmpcakhk