Skip to content

Instantly share code, notes, and snippets.

@Down10
Created March 13, 2011 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Down10/867790 to your computer and use it in GitHub Desktop.
Save Down10/867790 to your computer and use it in GitHub Desktop.
Bookmarklet that toggles a stylesheet that makes text clean and easy to read
javascript:(function(){var%20styles,t='%20!important',bgc='background-color:#FFF'+t+';',fclr='color:#222'+t+';',fsiz='font-size:16px'+t+';',ffam='font-family:Palatino,Palatino%20Linotype,Book%20Antiqua,URW%20Palladio%20L,Bitstream%20Charter,Georgia,Times,serif'+t+';',txr='-webkit-text-shadow:none;text-shadow:none'+t+';text-decoration:none;text-transform:none'+t+';-moz-outline:none;outline:0'+t+';',opac='filter:alpha(opacity=100)'+t+';-moz-opacity:1.0;-khtml-opacity:1.0;opacity:1.0'+t+';',errors=0,cssLink=window.document.getElementById('newcss');styles=('html{font-size:100%'+t+'}*{font-size:1em'+t+';background:transparent%20url(none)'+t+';'+fclr+ffam+opac+'letter-spacing:0'+t+';text-align:left'+t+';vertical-align:baseline'+t+';-webkit-font-smoothing:subpixel-antialiased'+t+';text-rendering:optimizeLegibility;letter-spacing:0'+t+';word-spacing:normal'+t+';border:0%20none'+t+';overflow:visible'+t+';height:auto'+t+'}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block'+t+'}img,fieldset{border:0'+t+';display:inline-block;padding-left:0.5em}ol,ul{list-style:auto}table{border-collapse:separate;border-spacing:0}caption,td,th{text-align:left}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:%22%22;content:none}button,input,select,textarea{'+bgc+fclr+opac+'font:sans-serif;border:1px%20solid%20#CCC'+t+'}button,input,select,textarea{*font-size:100%}legend{'+fclr+'}pre,tt,code,kbd{font-family:monospace,sans-serif}a{'+bgc+fsiz+'vertical-align:baseline'+t+';padding:0'+t+';margin:0'+t+'}*:focus{outline:1px}:link,:link%20*{color:#22D'+t+';text-decoration:inherit'+t+'}:visited,:visited%20*{color:#628'+t+'}:hover,:hover%20*{color:#22D;'+bgc+txr+opac+'}a:hover,a:hover%20*{'+bgc+'text-decoration:underline'+t+'}mark{'+fclr+'background-color:#FFA'+t+';font-style:italic'+t+';font-weight:bold'+t+'}del{text-decoration:line-through'+t+'}ins{'+fclr+'background-color:#FFA'+t+';}abbr[title],dfn[title]{border-bottom:1px%20dotted'+t+';cursor:help'+t+'}body{'+fsiz+bgc+'line-height:160%'+t+';padding:36px%2064px;margin:0}p{'+fsiz+'line-height:1.6'+t+';margin:0%201em%201em%200;display:block'+t+';max-width:600px}h1{font-size:2em'+t+'}h2{font-size:1.75em'+t+'}h3{font-size:1.5em'+t+'}h4{font-size:1.25em'+t+'}h5{font-size:0.9em'+t+'}h6{font-size:0.8em'+t+'}');function%20addCSS(w){if(w.document.createStyleSheet){w.document.createStyleSheet("javascript:'"+styles+"'");}else{var%20docHead=w.document.getElementsByTagName('head')[0],nCSS=w.document.createElement('link'),cssData='data:text/css,'+escape(styles);nCSS.setAttribute('rel','stylesheet');nCSS.setAttribute('type','text/css');nCSS.setAttribute('id','newcss');nCSS.setAttribute('href',cssData);docHead.appendChild(nCSS);}}function%20checkFrames(w){if(w.frames&&w.frames.length>0){for(vari=w.frames.length-1;i>=0;i--){wf=w.frames[i];try{addCSS(wf);}catch(e){errors++;}checkFrames(wf);}}}if(cssLink!=null){cssLink.parentNode.removeChild(cssLink);}else{checkFrames(window);addCSS(window);}if(errors>0){alert('Could%20not%20access%20'+errors+'%20frame(s).');}})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment