public
Created

  • Download Gist
scooby-doo.user.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
// ==UserScript==
// @include http://*/*
// @include https://*/*
// ==/UserScript==
 
//applies a "main-content" style to the first top-level element that isn't
//a header, nav, aside or footer
 
var style = document.createElement('style');
style.innerHTML = ".main-content {outline: 5px dotted deeppink !important;}"
document.body.appendChild(style);
 
var kids = [].slice.apply(document.body.children);
 
for (var i = 0, l = kids.length; i < l; i++) {
switch(kids[i].tagName.toLowerCase()){
case "header":
case "nav":
case "aside":
case "footer":
break;
default:
kids[i].classList.add('main-content');
break;
}
//comment out the following break if you want to apply main-content to all
//non-header/nav/aside/footer elms which doens't really make sense.
break;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.