Skip to content

Instantly share code, notes, and snippets.

@winkler1
Last active August 29, 2015 14:13
Show Gist options
  • Save winkler1/027237941426b24ea151 to your computer and use it in GitHub Desktop.
Save winkler1/027237941426b24ea151 to your computer and use it in GitHub Desktop.
Print DOM elements, dimensions, React ID's
console.clear();
var all = document.getElementsByTagName("*");
var TAGS_TO_SKIP=['BODY','HEAD','HTML','IFRAME','LABEL','LINK','NOSCRIPT','SCRIPT','STYLE','TITLE'];
for (var i=0, max=all.length; i < max; i++) {
var el=all[i];
if (TAGS_TO_SKIP.indexOf(el.tagName) == -1 ) {
// var reactID=el.dataset.reactid; // You might want to do something with this..
console.log(i, el.tagName,el, el.getBoundingClientRect());
}
}
//--- As a bookmarklet:
javascript:(function(){ var all,TAGS_TO_SKIP,i,max,el;for(console.clear(),all=document.getElementsByTagName("*"),TAGS_TO_SKIP=["BODY","HEAD","HTML","IFRAME","LABEL","LINK","NOSCRIPT","SCRIPT","STYLE","TITLE"],i=0,max=all.length;max>i;i++)el=all[i],-1==TAGS_TO_SKIP.indexOf(el.tagName)&&console.log(i,el.tagName,el,el.getBoundingClientRect()) })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment