Skip to content

Instantly share code, notes, and snippets.

@r-k-b
Created June 23, 2016 02:53
Show Gist options
  • Save r-k-b/f804b3c2e7f6800f4c326ec11a190b8d to your computer and use it in GitHub Desktop.
Save r-k-b/f804b3c2e7f6800f4c326ec11a190b8d to your computer and use it in GitHub Desktop.
Break on alert()
// ==UserScript==
// @name Break on alert()
// @namespace https://gist.github.com/r-k-b/
// @version 1.0.0
// @description Where is that damned `alert()` called from? This drops the trace in the console. If the Dev Tools are open, it'll also pause execution.
// @author Robert K. Bell
// @homepage https://gist.github.com/r-k-b/f804b3c2e7f6800f4c326ec11a190b8d
// @downloadURL https://gist.github.com/r-k-b/f804b3c2e7f6800f4c326ec11a190b8d/raw/break-on-alert.user.js
// @match *://*/*
// @grant none
// @run-at document-start
// ==/UserScript==
/* jshint esnext: true */
(() => {
'use strict';
const oldAlert = alert;
alert = function() {
console.trace('here\'s the trace for an `alert()`, called with args:', arguments);
debugger;
oldAlert(...arguments);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment