Skip to content

Instantly share code, notes, and snippets.

@miketaylr
Created November 7, 2012 17:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miketaylr/4032962 to your computer and use it in GitHub Desktop.
Save miketaylr/4032962 to your computer and use it in GitHub Desktop.
// ==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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment