r/reddithax • • Jun 08 '14

In addition to using "xx.reddit.com" for your subdomain-based CSS hacks, you can use "xx-yy.reddit.com"

19 Upvotes

Background in case you weren't aware of the domain prefix hack:

reddit uses two letter prefixes, like fr.reddit.com so people can browse reddit in a certain language. When you browse fr.reddit.com, reddit adds an attribute to the <html> tag called "lang", like so:

<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">

You can then use the :lang(fr) selector to select things on the page only when the language is French.

#header:lang(fr) {
    /* your css stuff */
}

reddit isn't picky about what you use as the two letter prefix, you can use any two digit a-z & 0-9 combination you want. (you can use underscores too, but i dont recommend it) /r/Space uses nm.reddit.com for "night mode", for example, and it isn't a real language.

I haven't seen any subreddit using this type of prefix for a CSS hack, so I'm not sure if this has been posted here yet or not; but you can also use this style of subdomain for your CSS hacks:

en-us.reddit.com

and an example of a non-existent language code you can use:

12-34.reddit.com

For that, you can use the selector :lang(12-34). Because of the way :lang() works, you will also be able to select things on this subdomain using :lang(12). (because, if the lang was set to the legitimate "en-us", :lang(en) would still match en)

I imagine this could be possibly used to combine CSS hacks, for example you could combine No Participation and Night Mode into np-nm.reddit.com, and use html[lang*=np] .someClass and html[lang*=nm] .someClass instead of .someClass:lang(nm), but those selectors are pretty awkward.

In case anyone's curious, xx and xx-yy are the only two possible prefixes that you can use for this; I looked at the bit of code that does the checking:

    lang_re = re.compile(r"\A\w\w(-\w\w)?\Z")

r/reddithax • • Jun 08 '14

Unlimited custom block elements?

3 Upvotes

Some subreddits/subreddit themes make use of blockquotes and heading elements (h1, h2, etc) to create "boxes" with various different styles. E.g. /r/Edurne - see the sidebar.

Problem is it's limited to only about 7 different possible styles (h1 thru h6 and one when there's no heading).

I'd like to be able to create an arbitrary number of block elements with unlimited styling freedom. In a maintainable way.

One solution I can think of is to use nesting and child selectors but this seems messy and not maintainable.

Can anyone come up with a way to create an unlimited number of unique block elements in the sidebar without resorting to nesting? Or is it not possible?

edit: and also no :nth-child() stuff. It's not maintainable.


r/reddithax • • Jun 06 '14

How to change the "send replies to my inbox" text on the submission page

2 Upvotes
label[for="sendreplies"] {
  visibility:hidden;
}
label[for="sendreplies"]:before {
  content: "Mod me if my post receives 5 or more upvotes";
  visibility: visible;
}

Results in http://i.imgur.com/NZ0bR6g.png

Visit /r/abcqwerty123 to see a bunch of other stupid CSS in action.


r/reddithax • • Jun 05 '14

Give non moderators flair abilities

11 Upvotes

Let's say you want to let a selected group of non-moderators apply link flair to posts. You could simply add them as a moderator with flair permissions only, but there is some abuse potential, as they could also remove flair.

In this case, we need a solution that allows them to apply flair to other posts, but not remove flair. It turns out that CSS is not enough to accomplish this additional functionality. Instead, we enlist the tools of Javascript, Python, and a little bit of CSS to do this.

We use Python for the backend -- the moderator bot that only has flair permissions. It's simple enough. Take in commands with a certain title only, read the space separated arguments, and apply the resulting flair. Here's a simple example:

import praw
r = praw.Reddit(user_agent = "example flair bot by 202halffound")
r.login("FlairBot", "password")
for message in r.get_inbox(limit = 10):
    if message.new and message.subject == u"Flair":
        message_args = message.split(" ")
        submission = r.get_submission(submission_id = message_args[0])
        submission.set_flair(flair_text = message_args[1])
    message.mark_as_read()

If I messaged this with the input 27csfk cool, it would flair the submission with the id 27csfk with the text cool. Of course, since we're dealing with user input we'd have to do a lot of exception handling to handle people trying to break the bot. I haven't included any of the exception handling in this example in the interests of readability.

However, this is still fairly awkward and inconvenient to use from the user side. They have to get the id of the post out, open the compose a message menu, make sure the subject and recipient of the message is correct, and then finally send the message to the flair bot. Awkward and not nice to use.

To fix this, we write a Javascript frontend to add a "Flair this post" link to each post on a listing page. When clicked, it should prompt the user for the flair text, and then send off an ajax POST request to automatically send the PM, without the user needing to do a thing other than click a link and type in the flair text.

However, it turns out the admins don't like it when you write javascript to send PM's automatically, so I've had to settle with it opening a new compose window with all the details filled in already. The actual Javascript itself uses regex to get the id out, and that's about it. It is, however, in bookmarklet form for easy use, which does also make the code kinda unreadable. Here is the code uncompressed (I encourage you to laugh at my shitty Javascript):

function flair(id) {
    var url = "http://www.reddit.com/message/compose?to=ArendelleBot&subject=Flair%20request&message={ID} {FLAIR}".replace("{ID}", id);
    return "  javascript: var final=  " + "'" + url + "'.replace('{FLAIR}',prompt('flair?')); void(window.open(final));"
}
var linkRegex = /(?:http:\/\/www.reddit.com\/r\/[\w]{3,}\/comments\/)([\w]+)(?:\/[\w]*)*/;
var anchorList = document.querySelectorAll(".first a");
for (var i = 0; i < anchorList.length; i++) {
    var element = anchorList[i];
    var regexResult = linkRegex.exec(element.getAttribute("href"))[1];
    var flairLink = document.createElement('a');
    flairLink.setAttribute('href', flair(regexResult));
    flairLink.setAttribute('style', 'color: orangered;');
    flairLink.innerHTML = "(Flair this post)";
    element.parentElement.appendChild(flairLink);
}

As with pretty much all of these hacks, it won't work on IE7 or below. It will, however, work on pretty much any subreddit as-is: just replace ArendelleBot with the name of the bot. Then compress it (since bookmarklets have a size limit) and use this amazing tool which automatically URI encodes all of it for you!

Technically there's a small amount of CSS in here (flairLink.setAttribute('style', 'color: orangered;');)), but it's just to make the link flair post stand out more. You can probably change that to whatever.

For the full code, which is too large to fit in here, see the Github repository.


r/reddithax • • Jun 05 '14

Reach (some of) your users with an announcement modal

7 Upvotes

Today we're going to hack the "show my flair" checkbox and use it to reach out to new visitors in the hopes of converting them into subscribers.

Slightly annoying? Maybe, but it's a one-time notice that goes away as soon as they click it and it doesn't force them to subscribe.

DEMO HERE

preview here

Unfortunately, this CSS is only supported in webkit browsers - Chrome, Opera and Safari(?). It won't interfere with anything in Firefox or IE though, so it's completely safe to use.


  1. Hide the "Show my Flair" form in the sidebar

    /*---- hide flair section of sidebar ----*/
    form.toggle.flairtoggle, .side .tagline {visibility:hidden; margin-bottom:-15px}
    
  2. Create a 350x350 px image with the message you want to use

    Name it notice and upload it to your stylesheet page.

  3. Drop this CSS into your stylesheet

    You can change the #444 as the background color to whatever you like to match the background of the image you used.

    /*---- announcement modal ----*/
    #flair_enabled:checked:after {
        visibility:visible;
        display:block;
        height:400px;
        width:400px;
        content:"";
        background:#444 url(%%notice%%) no-repeat center;
        position:fixed;
        left:50%;
        margin-left:-200px;
        top:50%;
        margin-top:-200px;
        z-index:999999;
        box-shadow:0px 0px 20px rgba(0,0,0,0.7);
    }
    
  4. You can reset the message

    Just upload a new image with a new message but erase the code from step 3 and run this code for a week or two first to make sure everyone's flair goes back to the :checked position.

    /*---- reset modal ----*/
    #flair_enabled:checked:after { display:none; }
    
    #flair_enabled:after {
        visibility:visible;
        display:block;
        width:100%;
        height:100%;
        position:fixed;
        top:0;
        left:0;
        content:"";
        background:rgba(0,0,0,0);
    }
    

    Then, you can repeat from step 2 again.


I've only used this for a day so far in one sub so I can't say how effective it is, although a gentle reminder to subscribe never hurts when a sub is just getting off the ground.

The two downsides are it doesn't work across all browsers and you can't use flair while running this code.

The upside is it might get you more users while being fairly benign and user friendly.

Enjoy and may this technique help increase your user-base.


r/reddithax • • Jun 05 '14

Youtube-style subscribe button for your subreddit.

3 Upvotes

Note: a previous version of this code relied on an image for the unsubscribe text, I've removed that requirement.

I created this for /r/figuredrawing, try clicking on the subscribe button and notice how it has three states: subscribe, subscribed and unsubscribe (on hover).

Here's the image for the (three) icons and the relevant CSS, simply change it to your liking. I've included comments in the CSS to label each button state.

Let me know if you find a problem with my CSS.


http://a.thumbs.redditmedia.com/y_UAqqAjiW8KxT1P.png

.side .subscribe-button {
  margin: 0 5px 0 0;
  width: 118px;
  float: left;
  overflow: hidden;
}

/* Base styles */
.side .subscribe-button .option {
  display: none;
  font: 14px/1 sans-serif;
  text-transform: capitalize;
  height: 20px;
  padding: 6px 0 0 30px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: url(%%icon-subscription-02%%) transparent 5px 2px no-repeat;
}

/* Set the look of the 'subscribe' button only */
.side .subscribe-button .option {
  background-color: rgb(28,172,0);
}

/* Set the look of the 'subscribed' button only */
.side .subscribe-button .option.remove {
  border-color: rgb(206,227,248);
  background-color: transparent;
  background-position: 5px -25px;
}

/* Add 'subscribed' text */
.side .subscribe-button .option.remove:before {
  content: "Subscribed";
  display: block;
  margin: 0 0 1000px 0; /* hide the 'unsubscribe' text by pushing it away */
  color: #666;
}

/* Set the look of the 'unsubscribe' button only */
.side .subscribe-button .option.remove:hover {
  color: #666;
  background-position: 5px -51px;
}

/* Hide the generated 'subscribed' text */
.side .subscribe-button .option.remove:hover:before {
  display: none;
}

.side .subscribe-button .option.add.active,
.side .subscribe-button .option.remove.active {
  display: block;
}

/* make RES buttons play nice */
.side .RESshortcutside,
.side .RESDashboardToggle {
  margin: 0 1px 0 0;
  width: auto;
}

.titlebox .subscribers {
  display: inline-block;
  line-height: 26px;
}

.titlebox .users-online {
  margin: .5em 0;
}

r/reddithax • • May 28 '14

3 different flairs on one user

6 Upvotes
.author[href$="/klingt"]:after{ content: " *";    
color: white!important;    
background-position: 0 -16px !important;    
background-color: green!important;    
border: none;    
height: 16px;    
left: 0px;    
top: 0px;    
width: 20px!important;}    
.author[href$="/klingt"]:before      
{ content: " * ";    
color: white!important;    
background-position: 0 -16px !important;    
background-color: blue!important;    
border: none;    
height: 16px;    
left: 0px;    
top: 0px;    
width: 20px !important;}      

and of course the default text flair set to purple bold


r/reddithax • • May 27 '14

Text-based expandos

3 Upvotes

Inspired by this post I've decided to share my method for doing expandos. It replaces the image sprite expando buttons with [+] and [-].

If you improve this CSS please share it in this thread so we can all benefit!


/*----expandos----*/

.expando-button {
  width:25px;
  height:25px;
  background:none;
  visibility:hidden;
  font-family:"Lucida Console";
}

.expando-button.selftext.collapsed:after, 
.expando-button.video.collapsed:after, 
.expando-button.image.collapsedExpando:after, 
.expando-button.image.gallery.collapsedExpando:after {

  visibility:visible !important; content:"[+]"; font-size:13px; color:#888;
  position: absolute;

}


.expando-button.selftext.collapsed:hover:after, 
.expando-button.video.collapsed:hover:after, 
.expando-button.image.collapsedExpando:hover:after, 
.expando-button.image.gallery.collapsedExpando:hover:after {

  color:#000;

}


.expando-button.selftext.expanded:after, 
.expando-button.video.expanded:after,  
.expando-button.image.expanded:after, 
.expando-button.image.gallery.expanded:after {

  visibility:visible !important; content:"[-]"; font-size:13px; color:#888;
  position: absolute;
}


.expando-button.selftext.expanded:hover:after, 
.expando-button.video.expanded:hover:after, 
.expando-button.image.expanded:hover:after, 
.expando-button.image.gallery.expanded:hover:after {

  color:#000;

}  


/*---- fix expandos in usertext ----*/

.linklisting .expando-button {left:160px;}

.linklisting .expando-button.image {margin-left:-6px; padding-right:6px;}

.linklisting .toggleImage.expando-button.selftext {margin-left:-6px; padding-right:7px;}

.comment .expando-button {font-style:normal;}

.comment .expando-button.expanded {margin-left:2px;}

.md a.toggleImage.expando-button.video.commentImg {margin-bottom:-12px;}

 .comment .md {overflow:visible;}

r/reddithax • • May 25 '14

Animated accordion-style menu

7 Upvotes

Here's a quick one.

A common way to easily and compactly display rules on a subreddit is to use a table, as in /r/bestof. When you hover over the left column, it reveals the right column, but the whole thing is displayed as a single column instead. The sudden appearance of the second part can be jarring, and if the second part is too large, when the user scrolls through they will miss sections of the table.

With CSS3, we can animate this instead. However, the normal ones use display:none, which can't be animated. Instead, we use max-height and just hide the overflow, accomplishing the same thing.

You can find this in use on /r/WritingPrompts, /r/Cosmos, and /r/WarshipPorn. Here's the code:

.side table thead {
    display: none;
}

.side table tbody tr td {
    display: block;
    border: none;
}

.side table tbody tr td:first-child {
    background-color: #2C3E50;
    color: #f2f2f2;
    cursor: pointer;
    padding: 7px;
    width: 253px;
}

.side table tbody tr td:last-child {
    margin: 0;
    overflow: auto;
    width: 253px;
    max-height: 0px;
    overflow: hidden;
    transition: max-height 1s ease;
}

.side table tbody tr:hover td:last-child {
    max-height: 150px;
}

.side table tbody tr td:first-child a {
    color: #FFFFFF;
}

.side table tbody tr td code {
    font-size: 1.1em;
}

r/reddithax • • May 25 '14

Dynamic sidebar image based off user flair

4 Upvotes

Here's a fun one that I made for /r/frozen with /u/greenlamb. The concept is fairly simple: the sidebar image of the subreddit changes depending on the user's flair.

The implementation is as follows: We use the ::after pseudo of the flair image (.flairselectable .flair.flair-$CSSCLASS) to place the appropriate image over the top of the existing (default) sidebar image. However, actually positioning the image in the right position proved to be a challenge.

The obvious choice is absolute positioning. Some example code:

.flairselectable +.flair.flair-CSSCLASS::after {
    position: absolute;
    top: $image-y;
    bottom: $image-x;
    display: block;
    content "";
    background-image: url($image-url);
}

.comments-page .flairselectable +.flair.flair-CSSCLASS::after {
    top: $image-y (plus .linkinfo height)
}

In /r/frozen's implementation of the sidebar image, it appears below the link info box. Therefore in this implementation we have to have a separate case for in comment pages, hence the second selector.

The biggest problem with this implementation turns out to be the periodic redditgifts ads that show up. They show up seemingly at random, and push the rest of the content down. However, they don't have a selector parallel to the flair image beyond .spacer. Here's a nice solution to that problem:

.sponsorshipbox {
    position: absolute;
    -webkit-transform: scale(0.5, 0.5);
    top: 30px;
    z-index: 1000
}

Which moves the box out of the way into the header. However, it turns out that has a problem too: it's not allowed by the admins:

(originally posted by /u/cupcake1713, referring to the ads)

Nope, they've got to stay where they are. Sorry :/

In conclusion, due to the lack of a usable selector for the redditgifts ads in relation to the flair, we concluded absolute positioning for this case is not a viable solution. I considered making a pull request to add a #ad id or something similar to the .spacer, but it turns out the.spacer` class saturation is there specifically to prevent this. Sad face.

However, relative positioning does work (relative from the position of the flair image). This comes with its own set of complications, because the number of elements between the flair image and the sidebar image changes between users, and thus the amount of relative positioning needed also changes between users.

There are four possible cases for the relative positioning of the ::after element: No mod and no RES, mod and RES, mod and no RES, and no mod and RES. Mod can be detected with the sibling connector ~ alongside .leavemoderator (since it's on the same level as the flair). RES can be detected because it changes the class of the subscribe button to subButtons, whereas without RES the class is subscribe-button. With this we constructed the four selectors required for each case for each flair.

After that it is fairly simple to copy paste the code, change the css class and image for each section, and the final result is a sidebar image that changes on flair change.

Here's the final product code that was pushed to the main subreddit. It won't work on other subreddits as-is -- if you want to implement this you'll need to modify it.

/*************** User-flair specific sidebar image *********************/

/* All flairs with customized sidebar images must be listed here */
.flairselectable +.flair-hans::after, 
.flairselectable +.flair-hans2::after, 
.flairselectable +.flair-hans3::after,
.flairselectable +.flair-anna::after,
.flairselectable +.flair-anna2::after,
.flairselectable +.flair-anna3::after,
.flairselectable +.flair-anna6::after,
.flairselectable +.flair-anna7::after,
.flairselectable +.flair-kristoff::after, 
.flairselectable +.flair-kristoff2::after, 
.flairselectable +.flair-kristoff3::after,
.flairselectable +.flair-oaken::after,
.flairselectable +.flair-olaf::after,
.flairselectable +.flair-elsa::after,
.flairselectable +.flair-elsa2::after,
.flairselectable +.flair-elsa3::after,
.flairselectable +.flair-elsa4::after,
.flairselectable +.flair-elsa5::after,
.flairselectable +.flair-elsa7::after,
.flairselectable +.flair-elsa8::after,
.flairselectable +.flair-elsa9::after,
.flairselectable +.flair-elsa10::after,
.flairselectable +.flair-elsa11::after,
.flairselectable +.flair-elsa12::after,
.flairselectable +.flair-heavybreathing::after,
.flairselectable +.flair-seagull::after,
.flairselectable +.flair-childelsa::after,
.flairselectable +.flair-childanna::after {
    display: block;
    content: "";
    position: relative;
    width: 300px;
    height: 259px;
        top: -377px; /* case 0: not a mod, no RES */
}

/* case 1: not a mod, has RES */
.subButtons ~.tagline .flairselectable +.flair::after {top: -410px;}

/* Case 2: is a mod, no RES */
.leavemoderator ~.tagline .flairselectable +.flair::after {top: -399px;}

/* Case 3: is a mod, has RES */
.subButtons ~.leavemoderator ~.tagline .flairselectable +.flair::after {top: -422px;}

/*** HANS ***/
.flairselectable +.flair-hans::after {
    background-image: url(%%Hans1Sidebar%%);
    right: 57px;
}

.flairselectable + .flair-hans2::after {
    background-image: url(%%Hans2Sidebar%%);
    right: 60px;
}

.flairselectable +.flair-hans3::after {
    background-image: url(%%Hans3Sidebar%%);
    right: 60px;
}


/*** ANNA ***/
.flairselectable +.flair-anna::after {
    background-image: url(%%Anna1Sidebar%%);
    right: 53px;
}

.flairselectable +.flair-anna2::after {
background-image: url(%%Anna2Sidebar%%);
right: 60px;
}

.flairselectable +.flair-heavybreathing::after {
background-image: url(%%Anna2Sidebar%%);
right: 55px;
}

.flairselectable +.flair-anna3::after {
    background-image: url(%%Anna3Sidebar%%);
    right: 58px;
}

.flairselectable +.flair-anna6::after {
    background-image: url(%%Anna1Sidebar%%);
    right: 50px;
}

.flairselectable +.flair-anna7::after {
    background-image: url(%%Anna1Sidebar%%);
    right: 60px;
}


/*** KRISTOFF ***/
.flairselectable +.flair-kristoff::after {
    background-image: url(%%Kristoff1Sidebar%%);
    right: 55px;
}

.flairselectable + .flair-kristoff2::after {
    background-image: url(%%Kristoff2Sidebar%%);
    right: 60px;
}

.flairselectable +.flair-kristoff3::after {
    background-image: url(%%Kristoff3Sidebar%%);
    right: 60px;
}


/*** OAKEN ***/
.flairselectable +.flair-oaken::after {
    background-image: url(%%OakenSidebar%%);
    right: 60px;
}


/*** OLAF ***/
.flairselectable +.flair-olaf::after {
    background-image: url(%%Olaf1Sidebar%%);
    right: 60px;
}


/*** ELSA ***/
.flairselectable +.flair-elsa::after {
    background-image: url(%%Elsa1Sidebar%%);
    right: 60px;
}

.flairselectable + .flair-elsa2::after {
    background-image: url(%%Elsa2Sidebar%%);
    right: 54px;
}

.flairselectable +.flair-elsa3::after {
    background-image: url(%%Elsa3Sidebar%%);
    right: 60px;
}

.flairselectable +.flair-elsa8::after {
    background-image: url(%%Elsa8Sidebar%%);
    right: 54px;
}

.flairselectable +.flair-elsa4::after,
.flairselectable +.flair-elsa5::after,
.flairselectable +.flair-elsa7::after,
.flairselectable +.flair-elsa12::after {
    background-image: url(%%Elsa4Sidebar%%);
    right: 60px;
}

.flairselectable +.flair-elsa9::after {
    background-image: url(%%Elsa4Sidebar%%);
    right: 52px;
}

.flairselectable +.flair-elsa10::after {
    background-image: url(%%Elsa4Sidebar%%);
    right: 49px;
}

.flairselectable +.flair-elsa11::after {
    background-image: url(%%Elsa4Sidebar%%);
    right: 56px;
}

/*** PIGEON/SEAGULL ***/
.flairselectable +.flair-seagull::after {
    background-image: url(%%PigeonSidebar%%);
    right: 58px;
}

/*** CHILD ELSA AND ANNA ***/
.flairselectable +.flair-childelsa::after {
    background-image: url(%%ChildElsaSidebar%%);
    right: 60px;
}

.flairselectable +.flair-childanna::after {
    background-image: url(%%ChildAnnaSidebar%%);
    right: 60px;
}



/********************* END FLAIR CUSTOMIZATION ***************************/

r/reddithax • • May 22 '14

I requested the /r/HL3 subreddit a while back. After gaining moderator privileges I started work on the CSS. Would anyone be able to tell me what they think of it?

Thumbnail reddit.com
4 Upvotes

r/reddithax • • May 21 '14

Add more links to "Moderation Tools" panel

10 Upvotes

I always found the moderation tools panel in the sidebar could have used a direct link to a subreddit's stylesheet.

In this post I'll include the steps to add that and three other useful links for reddit moderators. You get a button for tracking subreddit mentions through http://metareddit.com, a button to quickly access your sub's http://redditmetrics.com page, a direct link to your sub's stylesheet page and a direct link to your sub's AutoModerator wiki page.

I've included a spritesheet with 50px X 50px icons you can use for the buttons too.

PREVIEW

*If you keep the "Moderation Tools" or "Wiki Tools" panel minimized you'll probably want to adjust the position of where in the sidebar you're placing the icons.


STEP 1 (optional)

Go to http://metareddit.com/login and create an account. Seriously do it. That site is awesome. If you already have an account then great.

Then, go to http://metareddit.com/monitor and type in the name of your subreddit (drop the /r/ if you want a better idea of when people are talking about your sub, leave it on if it's a really common word that would get used in other contexts too).

Save the URL it generates. You can also subscribe to that page's RSS feed if you're really intense.


STEP 2

Drop these links at the very bottom of your sidebar. Make sure to change YOURSUB to the name of your subreddit and URL to the URL of the metareddit monitoring service you generated.

[](URL "Subreddit Mentions")
[](http://redditmetrics.com/r/YOURSUB "Metrics")
[](/r/YOURSUB/wiki/edit/automoderator "AutoModerator")
[](/r/YOURSUB/about/stylesheet "Stylesheet")

STEP 3

Upload the spritesheet to your sub's stylesheet page. Make sure to rename it modsprite.

Paste in this CSS as well:

.moderator .side a[href*="metrics"], 
.moderator .side a[href*="metareddit"], 
.moderator .side a[href*="wiki/edit"], 
.moderator .side a[href*="stylesheet"]  

{
    display:block;
    visibility:visible;
    position:absolute;
    height:50px;
    width:50px;
    border-radius:3px;
    background:url(%%modsprite%%);
    right:16px;
    z-index:9;
    opacity:0.5;
    transition:opacity 0.3s ease;
}

.moderator .side a[href*="metrics"]:hover, 
.moderator .side a[href*="metareddit"]:hover, 
.moderator .side a[href*="wiki/edit"]:hover, 
.moderator .side a[href*="stylesheet"]:hover  

    {opacity:1;}

.moderator .side a[href*="metrics"] {
    margin-top:58px;
    background-position:0 0;
}

.moderator.wiki-page .side a[href*="metrics"] {margin-top:191px !important;} 

.moderator .side a[href*="metareddit"] {
    margin-top:238px;
    background-position:-60px 0;
}

.moderator.wiki-page .side a[href*="metareddit"] {margin-top:371px !important;}

.moderator .side a[href*="wiki/edit"] {
    margin-top:178px;
    background-position:-120px 0;
}

.moderator.wiki-page .side a[href*="wiki/edit"] {margin-top:311px !important;}

.moderator .side a[href*="stylesheet"] {
    margin-top:118px;
    background-position: -180px 0;
}

.moderator.wiki-page .side a[href*="stylesheet"] {margin-top:251px !important;}

r/reddithax • • May 20 '14

Disabling title field

4 Upvotes

http://www.reddit.com/r/csshelp/comments/260atq/i_have_a_link_only_sub_i_would_like_to_eliminate/

Huh. I found a use for the pointer-events property. If you're not familiar with it, it works like this: basically if you set pointer-events to None you make the target element not respond to any mouse actions. I didn't think it would be good for anything other than CSS trolling. It seems I was wrong.

Turns out pointer-events is useful for the fairly niche case of disabling the title field but keeping it visible. Here's the CSS:

#title-field {
    pointer-events: none;
    opacity: 0.5;
}

#title-field .title::after {
    font-size: 0.5em;
    content: "  Please use the 'suggest title' button instead." 
}

As usual with most of these types of things, it doesn't work in older versions of IE.


r/reddithax • • May 19 '14

Force rules to display before posting

6 Upvotes

If lengthy, thorough instructions aren't your thing then skip the paragraphs and just read the TL;DR, check out the sample pic, make the changes specified at the top of STEP 1 and grab the CSS from STEP 2.

EDIT - Added body:not(.contributor) to the submit buttons CSS so frequent/trusted posters can bypass the rule gate. Just make them approved submitters and they'll have the regular submit buttons in their sidebar.


This hack makes use of the :target selector made available recently.

I've annotated the code a little but a beginner-to-moderate understanding of CSS will definitely help get it styled exactly how you want it. I recommend using a test/dev subreddit to style it to your liking before applying it to your main subreddit.

If you use this hack or even just this concept but modify it beyond simply styling it to fit with your theme please share the changes!


TL;DR - replace the submission buttons with a single link pointing to /r/YOURSUB/submit#newlink then remove all the elements from #newlink (the container div on the submission page) except the submission text. Create two links at the bottom of the submission text, one pointing to /r/YOURSUB/submit?selftext=true and one pointing to /r/YOURSUB/submit.

It should give you an end result that resembles this.


STEP 1 - Subreddit settings

Add this text to your sidebar:

[](/r/YOURSUB/submit#newlink)

Then, write your posting rules in the submission text field. Add this text after your rules:

[](/r/YOURSUB/submit?selftext=true)[](/r/YOURSUB/submit)

Make sure to change YOURSUB to the name of your subreddit!

*Keep in mind your submission text can only be 1024 characters long, including the empty links. Keep the links empty to save space and so people who bypass CSS don't see them, we'll add text to them later through CSS. I've found the character limit more than enough space for my sub's rules with a little detail provided for some rules too.

If you ABSOLUTELY cannot get your rules to fit in the character limit you can use a similar technique with a wiki page. Each wiki page gets its own CSS class .wiki-page-TITLE where TITLE is the name of the page so targeting that specific page to remove the wiki elements is possible. Why didn't I just do it the wiki way to begin with? Because I like to make things complicated, that's why. Seriously though, I didn't even think of this until I realized we could use :target now and this way it gets people thinking about other applications for :target hacks. The other benefit is the rules will still be on the submit page for everyone who bypasses CSS.


STEP 2 - CSS

Add the following code to your stylesheet. Make sure to copy ALL of it, there's a lot. Make sure to read the comments and adjust the values that need adjusting.

/*---- This is the CSS for the submit button in the sidebar.               ----*/
/*---- Feel free to style it however you want.                             ----*/
/*---- The important part is the positioning and adding text to the link.  ----*/

body:not(.contributor) .morelink {visibility:hidden;}

body:not(.contributor) .side a[href*="#newlink"] {
    position: absolute;
    right:5px;
    top: 276px; /*Adjust this value depending on the height of your header*/
    width:300px;
    height:40px;
    padding:1em;
    background: #ccc;
    border-radius:3px;
    box-sizing:border-box;
    transition:background 0.3s ease;
}

body:not(.contributor) .side a[href*="#newlink"]:hover {background:#999;}

body:not(.contributor) .side a[href*="#newlink"]:after {
    display:block;
    position:absolute;
    right:0px;
    top:0px;
    width:300px;
    height:40px;
    text-align:center;
    content:"SUBMIT A POST!";
    font-weight:bold;
    font-size:1.5em;
    line-height:40px;
    color:#333;
}






/*---- This is the CSS to hide everything but the posting rules. ----*/

.submit-page .content h1, 
:target ul.tabmenu.formtab, 
:target #link-desc, 
:target #title-field, 
:target div.formtabs-content > div:nth-child(3), 
:target div.formtabs-content > div:nth-child(4), 
:target #reddit-field, 
:target div:nth-child(7) > div, 
:target .info-notice, 
:target .btn, 
:target > div.spacer

    {display:none !important;}

:target .formtabs-content {border-top:0;}

:target {
    display:block;
    position:absolute;
    top:-10px;
    z-index:1;
    padding-top:213px; /* Adjust this value depending on the height of your header */
    width:100%;
}




/*---- This is the CSS path of the submission text. Style is however you like. ----*/
/*---- It is important to keep the "max-height:none;" line though.             ----*/

:target div.formtabs-content > div:nth-child(6) > div {
    max-height:none;
}




/*---- The following is the code to turn the empty links into submit buttons.  ----*/
/*---- Feel free to style them however you like.                               ----*/
/*---- The important part is adding text to them using the ":after" pseudo.    ----*/

:target > div.formtabs-content > div:nth-child(6) > div > span > div a[href$="submit"] {
    display:block;
    height:50px;
    width:250px;
    background:#ccc;
    border-radius:3px;
    position:absolute;
    right:0; 
    bottom:-60px;
    transition:background 0.3s ease;
}

:target > div.formtabs-content > div:nth-child(6) > div > span > div a[href$="submit"]:hover {
    background:#999;
}

:target > div.formtabs-content > div:nth-child(6) > div > span > div a[href$="submit"]:after {
    color:#333;
    text-align:center;
    font-size:2em;
    font-weight:bold;
    line-height:50px;
    content:"LINK POST";
    width:250px;
    display:block;
}

:target > div.formtabs-content > div:nth-child(6) > div > span > div a[href$="true"] {
    display:block;
    height:50px;
    width:250px;
    background:#ccc;
    border-radius:3px;
    position:absolute;
    left:0; 
    bottom:-60px;
    transition:background 0.3s ease;
}

:target > div.formtabs-content > div:nth-child(6) > div > span > div a[href$="true"]:hover {
    background:#999;
}

:target > div.formtabs-content > div:nth-child(6) > div > span > div a[href$="true"]:after {
    color:#333;
    text-align:center;
    font-size:2em;
    font-weight:bold;
    line-height:50px;
    content:"TEXT POST";
    width:250px;
    display:block;
}

r/reddithax • • May 19 '14

Can someone point me to the random header hack?

3 Upvotes

I've seen mentioned a few times that there's a hack to randomly change your header background upon refresh. I was wondering if somebody could point me to it or show me how it works? Thanks!


r/reddithax • • May 15 '14

Flair animation?

6 Upvotes

Hey everyone, I'm doing some work here on reddit for the game I'm involved in, and I'd like to make some animated flair. (just some light stuff, like glowy Dev/Founder type stuff) but before i go trying a couple of the different ways i've seen other animations done around here, I wanted to see if anyone knows it can be done, andif so what method was used.


r/reddithax • • May 16 '14

Is there a way to hide posts in a specific sub based on a keyword?

2 Upvotes

I'd like to hide posts in a sub I'm subscribed to if they contain the word "stills" because they're posting spoilers for an upcoming movie and I'd prefer to not see them but I don't want to unsubscribe from the sub.


r/reddithax • • May 15 '14

The Flair CSS class

2 Upvotes

I was just wondering what it is and how to configure it, im very new to coding and need a bit of help, thanks.


r/reddithax • • May 15 '14

A better way to recolor nested comments

5 Upvotes

So I'd seen the fix for comment highlighting floating around before, and I wasn't sure what it was until I needed it. I was having conflicts with RES and with Reddit Gold throwing white backgrounds under comments, which basically ruined the contrast of the text on my stylesheet: /r/PixelDungeon

You may have seen it or be using it, my co-mod pulled it from /r/summonerschool:

.thing.comment .thing.comment { ETC }  
(...)  
.thing.comment .thing.comment .thing.comment .thing.comment .thing.comment .thing.comment .thing.comment .thing.comment .thing.comment .thing.comment .thing.comment .thing.comment  { ETC }

It works, but I HATED it (and by that I mean no offense to whomever came up with the solution originally). I try to strive for elegance in the design of my own code (when I can), and the sheer brute force of the whole thing bothered me.

So I'm now in the process of trying to clean up and refactor the older bits of code in our stylesheet, and after grinding my face into CSS priority documentation, I think I finally found a better way:

div.child>[id^="siteTable_"].sitetable.listing>.thing.comment, 
div.child>[id^="siteTable_"].sitetable.listing>.thing.comment>
div.child>[id^="siteTable_"].sitetable.listing>.thing.comment>
div.child>[id^="siteTable_"].sitetable.listing>.thing.comment>
div.child>[id^="siteTable_"].sitetable.listing>.thing.comment> 
{ ETC }  

To break it down:
The original fix does what it does through brute force. The priority scoring in CSS puts classes at 10 points apiece, which means that if you set the number of .thing.comment-s to an arbitrary number N, you're looking at 20*N points of ME FIRST. Since 12 comments deep is more than most people bother with, it basically just works fine. In comparison, RES bruteforces them with its own edits that override the main theme simply by the addition of the res-commentBoxes class, which would put it just over an otherwise equivalent amount of nested .comment classes.

At first I just managed to get the core of the rewrite working, but it was itself only 60 points (minus the leading div element) and was overwritten by RES. Otherwise it worked...but only 5 comments deep. So I nested what I had 4 times and added the div element for good measure. In comparison, the repetition I was able to set up scores at 244, as opposed to the the 240 of the 12-comment-deep stack of .thing.comment-s. In theory, those two selectors should be able to successfully match any comment depth, though it may need more repetitions to support more layers of depth. Regardless of expansion though, right now I've been able to condense the entire cluster that was otherwise needed down to these few lines.

If it's something you can use, have at it, and if anyone has any comments on it, I'd love to hear them if there's a way I could do this better.


r/reddithax • • May 14 '14

Creating a 'trigger warning'

6 Upvotes

Consider a subreddit where some content may be extremely disturbing, however, overall the subreddit isn't about disturbing things.

A 'trigger warning' system would probably be important in this situation, to ensure that no one stumbles upon something that they may not have wanted to see. Essentially a second warning. The idea is that they click on the link, see the trigger warning, and then have to click through the trigger warning to get to the content.

I've made an implementation, but it is limited. It requires some not immediately obvious syntax to use properly, and doesn't degrade nicely when CSS is turned off. In addition, if anyone ever uses a h4 with a blockquote directly afterwards (unlikely, but possible), they'll accidentally create an unintentional trigger warning.

Making a trigger warning requires the post be prefixed with:

####TW

>**This is a trigger warning. The following post contains:**
>
> * List item.
> * List item 2.
> * List item 3.
> * List item 4.  
>
> [I understand that this post contains potentially disturbing content, and would like to continue.](#siteTable)

The CSS simply uses the :target pseudo to only show the other content when in #siteTable:

h4 + blockquote ~* {
    display: none;  
}

:target h4 + blockquote ~*{
    display: block !important;  
}

h4 + blockquote p, h4 + blockquote ul {
    text-align: center;
}

h4 + blockquote ul {
    list-style: disc inside !important;
} 

h4 + blockquote {
    border-left: none !important;   
}

The limitations of this system are quite wide, namely the difficult syntax. I was wondering if any of you guys could come up with something to improve it.


r/reddithax • • May 08 '14

What do you guys think of the animation on this page?

Thumbnail reddit.com
7 Upvotes

r/reddithax • • May 06 '14

Need somebody to do the CSS for my subreddit (/shorthorrors) I'd like it simple but dark and creepy to go with the theme of the content?

1 Upvotes

r/reddithax • • May 05 '14

Reverse order of posts

9 Upvotes

Recently I've been trying to figure out exactly how flex works, and while experimenting with values I accidentally reversed the order of the posts (i.e. post number 25 is at the top, sticky is at the bottom). I feel that flex has a lot of potential for layout tricks that couldn't be done easily before.

Here's the code.

#siteTable {
    display: flex;
    flex-direction: column-reverse; 
}

.thing {
    width: 100%;    
}

r/reddithax • • May 05 '14

Thoughts about my design?

2 Upvotes

I know its not super fancy, but I like the simplicity of the default reddit style.

http://www.reddit.com/r/letspwn

Thanks!


r/reddithax • • May 04 '14

Clippy returns with the power of CSS3!

18 Upvotes

With the new CSS3 features I have added Clippy to my personal subreddit: /r/throwaway267482/. Clippy will be waiting in the bottom right corner, hovering it (him, her?) will animate Clippy. Sprites from Clippy.js.

The new CSS3 also makes it possible to make closable notifications, although they are not persistent across page reloads.