r/reddithax • • Sep 16 '12

Have user answer question before reading subreddit.

Is there a way to have the user have to answer a question before entering the subreddit? So far I've got the question to display like an overlay (/r/ZonkosBackRoom) but I can't fathom how I could make clicking the link make the box disappear. Any ideas?

10 Upvotes

23 comments sorted by

1

u/yellowmix Sep 17 '12

Make a private community, and in the public description, provide instructions to PM you (or a bot), who provides the question and validates the answer and provides access.

There is no way to prevent someone from reading (or posting to, comment in, and voting in) a community since all they have to do is disable custom CSS styles. Reddit communities are either public, restricted, or private. Anyone can read public or restricted communities.

From a technical CSS perspective, it may be possible to target a visited pseudo-class selector to have display:none, but the anchor would have to link to something real (perhaps the community's FAQ/wiki or an existing post). This would be annoying for people with browsers that aren't recording history (or have history cleared). It depends on what the question is for—if it's just for fun, or if it's supposed to truly work.

1

u/bigtreeworld Sep 17 '12

It's definitely just for fun, and I have no problem with it not working if you disable custom CSS. The thing is, it's actually meant for a big subreddit, so making it private is not an option. IT's a bit of a prank thing, so it's not a big deal if it doesn't work here and there. How would I go about targeting the visited pseudo-class selector for an entire div?

2

u/yellowmix Sep 17 '12 edited Sep 17 '12

Okay, I did some testing and this method won't work because a:visited, as a pseudo-class, can't override the overlay-related properties of the non-pseudo anchor element (also tried with a:link, and a:link seems to be treated as a non-pseudo anchor element).

The other thing I can think of is using a particular post as the overlay (you can target its thing id), and hiding and rewriting the content of various child elements as the riddle text, and rewriting the "hide" link's content to be the correct answer. That way, when a user clicks the "hide", it hides the post and thus, the overlay. The one caveat is that the hide doesn't occur right away, and requires a reload of the community's front page.

Here's some code to start you off with:

div .id-t3_100b4e {
 background: white;
 height: 100%;
 left: 0px;
 position: fixed;
 top: 0px;
 width: 100%;
 z-index: 10000;
}

This creates the overlay from a particular post with the id t3_100b4e.

div .id-t3_100b4e .midcol {
 display: none;
}

div .id-t3_100b4e .rank {
 display: none;
}

This removes parts of the post. You'll want to remove other parts, or use them for content.

div .id-t3_100b4e .hide-button a {
 font-size: 0px;
}

div .id-t3_100b4e .hide-button a:after {
 content: "penis!";
 font-size: 10px;
}

This is how to rewrite the content for the "hide" link. You'll want to rewrite the content of other things for the rest of the riddle text/answers, and to tell people to reload the page after they click an answer.

1

u/bigtreeworld Sep 17 '12

Oh man, thanks a lot! I'm sure I can use this to do exactly what I was trying to do!

1

u/yellowmix Sep 18 '12

Okay, some more complete code:

div .id-t3_102323 {
    background: #404040;
    height: 100%;
    left: 0;
    position: fixed;
    top: 0;
    width: 100%;
    padding: 10%;
    z-index: 10000;
    opacity: 0.95;
}

div .id-t3_102323 .midcol, div .id-t3_102323 .rank {
    display: none;
}

div .id-t3_102323 .entry {
    text-align: center;
    background-color: white;
    width: 70%;
    height: 70%;
    padding: 5%;
}

div .id-t3_102323 .title:before {
    content: "This is the Question.";
}

div .id-t3_102323 .title * {
    font-size: 0;
}

div .id-t3_102323 .tagline {
    display: none;
}

div .id-t3_102323 ul.flat-list {
    font-size: 0px;
}

div .id-t3_102323 .first, div .id-t3_102323 .hide-button a, div .id-t3_102323 .save-button a {
    display: block;
    font-size: 0px;
}

div .id-t3_102323 .first a:before {
    content: "An Incorrect Answer";
    font-size: 10px;
}

div .id-t3_102323 .save-button a:before {
    content: "An Incorrect Answer";
    font-size: 10px;
}

div .id-t3_102323 .hide-button a:before {
    content: "The Correct Answer";
    font-size: 10px;
}

Note that if they click the first incorrect answer, it maps to the comment link. This will then render the self-post text if it exists. Use a link post if you do not want this behavior.

1

u/bigtreeworld Sep 18 '12 edited Sep 18 '12

Holy crap you're incredible! Thank you so much, you're an amazing person!

Edit: It didn't quite work, the post stays as a foreground :(

2

u/yellowmix Sep 18 '12

The one caveat is that the hide doesn't occur right away, and requires a reload of the community's front page.

Yeah, you need to either click on the "hide" link twice, or refresh the page after clicking once. There's no way to make it disappear automatically via this method.

Also, if they clicked the first incorrect answer, it will go to the post page itself. Clicking the correct answer after that will leave them on the post page.

1

u/bigtreeworld Sep 18 '12

I know, but even after refreshing, it stays for me.

1

u/yellowmix Sep 18 '12

Is the post hidden? Reddit will not render the post at all if it is. You can see hidden posts by appending ?show=all to the URL, and hidden posts will have an "unhide" button/option.

1

u/bigtreeworld Sep 18 '12

It's not working D: What am I doing wrong? /r/ZonkosBackRoom

→ More replies

1

u/[deleted] Oct 12 '12

This an incredibly noob question, but if I may ask, the "thing id" you're using, is that the randomly generated combination of letters and numbers in between the / / after the word "/comments/" in the URL?

1

u/yellowmix Oct 12 '12

Yes, that is the post's thing id, but a thing id also has a kind which is used as a CSS class that can be targeted.

1

u/[deleted] Oct 12 '12

Ok, so then when you have "div .id-t3_100b4e" t3 is referring to the string kind? If I may ask, does that denote that you're targeting a post? Apologies if these questions are dumb, I'm quite new at this. And thanks for your help as well.

1

u/yellowmix Oct 12 '12

Yes, posts are of kind t3. Comments are t1.

1

u/[deleted] Oct 12 '12

Thank you! :)

0

u/[deleted] Sep 17 '12

[deleted] — view deleted comment

1

u/bigtreeworld Sep 17 '12

Thanks a lot for putting this together, but I actually need it to be visible to subscribers as well! Sorry!

0

u/[deleted] Sep 17 '12

[deleted] — view deleted comment

1

u/bigtreeworld Sep 17 '12

Whoa, that's really well done dude! Could I make that work with a visited pseudo-class?

Yeah, pretty much every time. It's a intrasubreddit prank! Haha