highlight all divs (bookmarklet)

/ Published in: JavaScript
Save to your folder(s)

Copy this code and paste it in your HTML
  1. javascript:/*Highlight_all_DIVS.js*/(function(){var styleId='ujs_display_div_order'; var className='ujs_display_div_order_details'; function addStyle(){var s=document.getElementById(styleId); if(s){clean(); s.parentNode.removeChild(s); return false;} var s=document.createElement('style'); s.id=styleId; s.setAttribute('type', 'text/css'); s.setAttribute('style', 'display:none !important;'); s.appendChild(document.createTextNode('span.'+ className + ' {color: #000 !important; background: #ffff99 !important; border: 1px solid #ffcc66 !important; display: inline-block !important; font-family: sans-serif !important; font-size: 10px !important; font-style: normal !important; font-variant: normal !important; font-weight: normal !important; letter-spacing: 0 !important; margin: 0 1px 0 0 !important; padding: 1px !important; text-align: left !important; text-decoration: none !important; text-transform: none !important; z-index: 1 !important; opacity: 0.9 !important;} div {outline: 1px solid #ff0000 !important;}')); document.documentElement.appendChild(s); return true;} function clean(){var s=document.selectNodes('//span[@class=\'' + className + '\']'); for(var i=0; i<s.length; i++){s[i].parentNode.removeChild(s[i]);}} function display(){if(!addStyle()){return;} var d=document.getElementsByTagName('div'); for(var i=0; i<d.length; i++){var t='div'; t+=d[i].id ? (' #'+d[i].id) : ''; t+=d[i].className ? (' .'+d[i].className) : ''; t+=' '+(i + 1).toString(); var s=document.createElement('span'); s.className=className; s.title=t; s.innerText=t; d[i].insertBefore(s,d[i].firstChild);}} display();})();

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.