Skip to content

Instantly share code, notes, and snippets.

@mbrock
Created February 17, 2014 10:31
Show Gist options
  • Save mbrock/9048254 to your computer and use it in GitHub Desktop.
Save mbrock/9048254 to your computer and use it in GitHub Desktop.
javascript:document.addEventListener('DOMNodeInserted',function(e){if(!e.target.setAttribute)return;e.target.setAttribute('data-trace',(new Error).stack.split("\n").splice(6).join("\n").replace(/( +at )|\([^()]+\)/g,"").replace(/\n/g,"/ "));e.target.style.border='1px dotted salmon'});
@mbrock
Copy link
Author

mbrock commented Feb 17, 2014

The expanded source:

document.addEventListener('DOMNodeInserted', function (e) {
  if (!e.target.setAttribute) return;

  e.target.setAttribute(
    'data-trace'
    (new Error).stack
      .split("\n").splice(6).join("\n")
      .replace(/( +at )|\([^()]+\)/g, "")
      .replace(/\n/g, "/ "));

  e.target.style.border = '1px dotted salmon';
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment