Is there some way for a Chrome extension to detect an alert box which shows up immediately after an external website's page-load? I understand that once an alert box shows up, JavaScript execution is suspended.
A certain website throws a specific alert and I need to be able to listen for that. Ideally, I want to extract the text within the alert.
You can overwrite the native alert()
function
var native_alert = alert;
alert = function(msg) {
console.log('call to alert() - message: '+msg);
native_alert(msg);
}
alert('intercepted!');
DEMO : http://jsfiddle.net/jHTeK/2/
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.