Created
July 3, 2015 01:57
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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