Skip to content

Instantly share code, notes, and snippets.

@tomhodgins
Created July 3, 2015 01:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomhodgins/29910f1576c869fa4361 to your computer and use it in GitHub Desktop.
Save tomhodgins/29910f1576c869fa4361 to your computer and use it in GitHub Desktop.
Browser Script: Adds an invisible checkbox to the top-right corner of Reddit.com that hides the sidebar when checked. You can add this code to extstyler.js in Extstyler to use this script in Chrome https://github.com/tomhodgins/extstyler
// Add this code to Reddit.com
/* Hide the Side */
if (document.getElementsByTagName('html')[0].classList.contains('reddit')) {
var input = document.createElement('input'),
inputCSS = document.createElement('style'),
inputJS = document.createElement('script');
input.id = 'hTS';
input.setAttribute('type','checkbox');
input.setAttribute('onclick','hideTheSide()');
if (localStorage.hTS == 'true') {
input.setAttribute('checked', 'yes')
}
inputCSS.innerHTML = '#hTS{position:fixed;top:0;right:0;z-index:999}\
#hTS:checked ~ .side{display:none}\
#hTS:checked ~ .content{margin-right:0}';
inputJS.innerHTML = 'function hideTheSide() {\
if (localStorage.hTS == "true") {localStorage.hTS = "false"}\
else {localStorage.hTS = "true"}\
}';
document.getElementsByTagName('body')[0].insertBefore(input, document.getElementById('header'));
document.getElementsByTagName('body')[0].insertBefore(inputCSS, document.getElementById('header'));
document.getElementsByTagName('body')[0].insertBefore(inputJS, document.getElementById('header'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment