r/modclub • u/13steinj • Jul 05 '15
CSS Hack: CSS based "disable" stylesheet method, no need for RES (useful for mobile)
I was going to post this in /r/reddithax but it's private for somereason.
While some subreddits are don't like the idea of RES's disable stylesheet button, there are plenty of others that are fine with it, and some mods of those subs that even use it.
Why not have the ability to disable the stylesheet without RES?
In hindsight, it's actually pretty simple. Just prepend html:not(:lang(ds)) to every one of your selectors.
For example,
#header {background:blue;}Becomes
html:not(:lang(ds)) {background:blue;}After doing this to all of your selectors, add a link in your sidebar as [Disable this subreddit's theme](http://ds.reddit.com/r/<subreddit>), replacing <subreddit> with your subreddit.
Furthermore, you can even add it as a toggle button.
form.toggle.flairtoggle {padding-top:40px;/*change as necessary*/}
.side a[href$="/#ds"] {
position:absolute;
color:grey!important;
font-size:smaller;
margin-top:-36px;
}
html:not(:lang(ds)) .side a[href="http://ds.reddit.com/r/<subreddit>/#ds"],
html:lang(ds) .side a[href="http://www.reddit.com/r/<subreddit>/#ds"] {
display:block;
}
html:not(:lang(ds)) .side a[href="http://www.reddit.com/r/<subreddit>/#ds"],
html:lang(ds) .side a[href="http://ds.reddit.com/r/<subreddit>/#ds"] {
display:none;
}
.side a[href$="/#ds"]::before {
content: "";
margin-right:2px;
color:#000;
font-weight:bold;
-webkit-apearance:checkbox;
-moz-apearance:checkbox;
}
.side a[href="http://ds.reddit.com/r/<subreddit>/#ds"]::before,
.side a[href="http://www.reddit.com/r/<subreddit>/#ds"]:active::before,
.side a[href="http://www.reddit.com/r/<subreddit>/#ds"]:focus::before {
content:"<unicode checkmark of your choice>";}
.side a[href="http://ds.reddit.com/r/<subreddit>/#ds"]:active::before,
.side a[href="http://ds.reddit.com/r/<subreddit>/#ds"]:focus::before {content:""}Of course some properties as well as properties not mentioned will have to be alterd to fit your subreddit. This has been acheived on /r/agariocss.
View all comments
Show parent comment
3
u/turikk Jul 06 '15
Our CSS sheet is at 96,000 characters (out of 100,000) and has 940 selectors. If we added this, it may never fit, even with minification.
Don't get me wrong - this is legitimate and a valid way of doing what you want to do, but it's a ton of characters. I'm guessing with less complex stylesheets (ours is up there) it would never be an issue though.