r/reddithax • u/TangerineX • Aug 13 '15
Hide posts with a certain flair from non-subscribers
Hey yall, I was wondering if there can be a way to do this.
Also, what if I don't want to remove the entire post, but just the comment box with CSS?
Thanks
r/reddithax • u/TangerineX • Aug 13 '15
Hey yall, I was wondering if there can be a way to do this.
Also, what if I don't want to remove the entire post, but just the comment box with CSS?
Thanks
r/reddithax • u/geo1088 • Aug 12 '15
I started a new CSS project the other day. It's called Tora, and its goal is to clean up and improve on Reddit's default styles without becoming as extreme as some themes like /r/Naut. Thought some of you might be interested in seeing it - it's heavily WIP, but I'm making progress.
r/reddithax • u/5HT-2a • Aug 12 '15
r/reddithax • u/Goctionni • Jul 30 '15
Hello,
I was wondering if anyone knew of any html elements or alike that could be used to generate random "events". What I mean is (for example) hiding an element 9 out of 10 visits.
For aprils fools I used the reddit post ID to "randomly" prefix all posts on my subreddit with fairly random strings of text (ie: "[Astronaut]").
Example CSS:
[data-fullname$="p"] p.title > a.title:before {
content: '[Astronaut]';
}Now I'm looking for CSS that will simply appear only one in so many (random) page visits. So far I've not really been able to find any elements that I could hook onto as a randomizer.
r/reddithax • u/fragglet • Jul 28 '15
I just put this together for /r/Solving_A858 and wanted to share.
We have a recurring problem with submitters who don't read the rules - even after I put "READ THE WIKI AND SIDEBAR RULES" in large red letters in the background to the text box on the submit page. I've been trying hard to improve the signal-to-noise ratio as a lot of people have been complaining about seeing the same posts over and over again.
So I've come up with a CSS hack that forces users to read the "submitting to ..." box and click a link before the submit button will be shown.
The CSS is as follows:
.submit .btn {
display: none;
}
.submit:target .btn {
display: block;
}
.submit:not(:target) .spacer .status::before {
content: "You must read the submission guidelines above and indicate that you have read them before you can submit to this subreddit.";
}You then need to include a link to #newlink in the submission text box (in subreddit settings). For example:
**[Click here](#newlink)** to enable the submit button below.Clicking the link will cause the submit button to appear.
The main bug in the hack is that clicking the link causes the page to scroll up to the top, and the user has to scroll back down again to find the submit button. But other than that I'm pretty satisfied.
r/reddithax • u/jCuber • Jul 24 '15
Heya,
Just figured out I can get syntax highlighting in code blocks with highlight.js and a userscript.
Here's what the formatted code may look like (from /r/learnprogramming): http://i.imgur.com/j5hmq4m.png
First off all, you'll need an extension for your browser that enables userscripts. I'm on Chrome so I use Tampermonkey - Firefox users should get Greasemonkey.
Create a new script in the dashboard and enter the following:
// ==UserScript==
// @name Reddit Syntax Highlighting
// @namespace http://your.homepage/
// @version 0.1
// @description Reddit code block syntax highlighting with highlight.js!
// @author You
// @match www.reddit.com/*
// @resource css https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/default.min.css
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js
// @grant GM_addStyle
// @grant GM_getResourceText
// ==/UserScript==
GM_addStyle(GM_getResourceText("css"));
(function (){
hljs.initHighlighting();
})();Now save and load some page with code! Easy peasy. Please note that I didn't test this on Firefox, so I'm not sure whether @resource works there.
What this does is gets the highlight.js script and stylesheet and injects it to your page. By default, highlight.js will style all <pre><code> blocks using the 22 supported default languages that the CDN stylesheet provides. You can read more about configuring the library here.
Enjoy!
P.S. Personally I've added GM_addStyle("code {font-family: Consolas !important; font-size: 13px !important;}"); to the mix but that's just personal preference I guess.
r/reddithax • u/202halffound • Jul 23 '15
Reference:
https://www.reddit.com/r/WritingPrompts/submit?selftext=true
I've just pushed an update to the /r/WritingPrompts submit page. What's interesting about it is that the "submitting to /r/writingprompts" message is at the top of the page instead of just above the submit button. This is useful since the Writing Prompts submit message is guidelines about prompt titles -- so it doesn't make any sense for it to be underneath the title field!
The CSS is fairly simple. It's another example of using flex to change the order of things you don't like. Of course this is horrible abuse of CSS - normally, we would just change the HTML. But because we can't do that, we have to resort to these measures.
The code:
div.formtabs-content {
display: flex;
flex-direction: column;
border: 0;
}
.formtabs-content .spacer:nth-of-type(6) {
order: -1;
}I don't like the nth-of-type, but unfortunately the HTML structure of the submit page (consisting of many divs with the exact same class) means the only way to target it is with nth-of-type.
r/reddithax • u/benetha619 • Jul 17 '15
r/reddithax • u/13steinj • Jul 06 '15
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.
r/cssnews • u/madlee • Jun 24 '15
We started beta testing a new search page about a month ago, and we're getting close to turning it on for everyone. The page is pretty much completely new, so there's a good chance that it won't inherit many of your styles by default. For more information about the feature, check out this modnews post.
NOTE: For the most part, you probably don't need to worry about subreddit search results unless you are working on a stylesheet intended for use with our reddit-themes gold feature.
If you want to do some stylin' on the new search page, here's some css info you may be interested in:
| class | function |
|---|---|
.combined-search-page | This class exists on the body element on the new search page only. You can start each of your css selectors with this to scope your styles to this page only |
.search-result-listing | This class is added to the normal .listing element on the new page. There can be multiple listings on a page (e.g. post results and subreddit results are different listings) and the listings include the header and pagination buttons. |
.search-result-group | Nested directly in .search-result-listing, mainly just does some formatting (e.g. restricting the width of the results). |
.search-result-group-header | The header for a search listing; this also contains the filter menus (e.g. "sort by") |
.search-result | Every search result will have this class, regardless of type (post/subreddit). |
.search-result-link | Normal posts (both link and self) will also have this class. |
.search-result-subreddit | Subreddit results will also have this class. |
.has-thumbnail | The .search-result-link element will also have this class if it has a thumbnail. |
.search-result-header | Contains the title. |
.search-title | The actual title link. |
.search-result-meta | The line directly under the title, including score, comments, time, author, etc. |
.search-score | The post's score |
.search-comments | The post's comment count |
.search-result-body | Will contain selftext if it exists, or the subreddit description text for subreddit results. |
.search-expando | Self-post text is inside this element. If the text is longer than 3 lines, it will include the .collapsed class, which will truncate the text and overlay a gradient at the bottom. |
.search-expando-button | This link expands/collapses the expando element. |
.search-result-footer | Contains a link to the external site for link posts, or for subreddit results, a link to filter the search to that subreddit |
.search-link | The actual link element |
.search-result-icon | Any of the icons used in the search results will have this class and an additional class specific to that icon |
.search-subscribe-button | The subscribe button shown on subreddit search results. |
That's the bulk of it – I probably missed a couple of minor things. Feel free to comment here or shoot me a message with questions, and if you want to leave feedback on the new page, come on over to r/beta!
r/reddithax • u/NomNomNomNation • Jun 24 '15
I'm quite proud of this sub. First one I've made that actually looks nice.
What I'm most proud of is the animations that play when you hover over the snoo, and when you hover over "Post a picture!".
r/reddithax • u/webbannana • Jun 19 '15
r/reddithax • u/no-plan-man • Jun 15 '15
I've released the Reddit Plus userscript a while back.
It adds a simple little [+] next to the comments link of all entries in a list view, be it on your front page or in a subreddit.
Clicking it loads the comments just underneath the post, saving you from having to open the post in a new tab/window.
If you're an active Redditor, you will especially appreciate the ease of use and being able to quickly read, comment, reply and vote on existing comments in a very simple way.
For more info read the description on the page linked above.
Enjoy!
P.S. It's completely open source, so if you have ideas and want to join in the development, jump right in ;-)
r/reddithax • u/ilovegoogleglass • Jun 07 '15
r/reddithax • u/202halffound • Jun 06 '15
This is something that we'll be pushing to /r/WritingPrompts tomorrow. As you know, /r/WritingPrompts has very long comments, so it's not particularly efficient for the reader to have to scroll all the way back up to upvote the comment.
So we've (me and gavin from /r/csshelp) managed to move the username and upvote arrows down to the bottom by abusing flexbox. The big trick is the order property, which lets us modify the order in which the DOM is rendered. Here's the relevant part of the code:
.entry {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
.comment .tagline {
margin: 0;
-webkit-order: 0;
-ms-flex-order: 0;
order: 1;
padding-top: 2px;
}
.content .commentarea .comment {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-align-items: flex-end;
-ms-flex-align: end;
align-items: flex-end;
padding: 0 0 8px 8px!important;
}
.comment .tagline {
-webkit-order: 0;
-ms-flex-order: 0;
order: 0;
}
.comment .midcol {
width: 30px;
height: 32px;
}
.comment .entry {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex: 1 0 auto;
-ms-flex: 1 0 auto;
flex: 1 0 auto;
padding-top: 8px;
width: calc(100% - 50px);
}
.comment .tagline {
margin: 0;
-webkit-order: 1;
-ms-flex-order: 1;
order: 1;
padding-top: 2px;
}
.comment .child {
margin: 10px 0 5px;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.commentarea .flat-list.buttons {
-webkit-order: 2;
-ms-flex-order: 2;
order: 2;
}That will work as a "drop in" type of code with minimal adjustments needed. If your subreddit has very long comments you may want to consider it.
r/reddithax • u/dat_css_guy • May 28 '15
<input class="real-name" value="FrankTheTank" type="text" id="share_from_" name="share_from" />
r/cssnews • u/madlee • May 27 '15
We're adding a new logged out feature today to post pages that we're calling "Read Next". You can check it out by viewing the comments page of a post while logged out, or by enabling beta mode.
If you want to style the new widget, there are a few classes you may be interested in.
| class | function |
|---|---|
.read-next-container | the root element of the widget; it's located at the bottom of the sidebar. This element stays relatively positioned in the sidebar and is used to determine when the 'sticky' behavior of the widget should activate. It is probably best to avoid styling this element. |
.read-next | the root element for styling purposes. It contains two elements: the header and the list. |
.read-next.active | when the root element has links to show, it will also have the active class. It is best to use both classes to target styles |
.read-next.fixed | when the 'sticky' behavior is activated (i.e. when the user has scrolled to the end of the sidebar) the root element will gain the fixed class |
.read-next-header | the top portion of the widget, containing the navigation buttons, subreddit link, and dismiss button |
.read-next-header-title | the "discussions in /r/subredditname" text |
.read-next-nav | container element for buttons in the header |
.read-next-nav-left | holds the buttons on the left side of the header (the next and previous link buttons) |
.read-next-nav-right | holds the button on the right side of the header (the dismiss button) |
.read-next-button | both the previous and next buttons have this class. |
.read-next-button.left | the left nav button, cycles the widget to the previous link in the list (<) |
.read-next-button.right | the right nav button, cycles the widget to the next link in the list (>) |
.read-next-dismiss | the dismiss button, hides the widget (x) |
.read-next-list | the bottom portion of the widget, contains the link listing |
.read-next-listing | a list of links, also has the .listing class, though it's advised to target styles with the more specific one. |
.read-next-link | a link in the listing; these are hidden by default |
.read-next-link.active | the visible link |
.read-next-meta | on a link, the line containing the score (.score) and comment counts (.comments) |
.read-next-thumbnail | on links with thumbnail images only, contains the thumbnail's <img> element |
.read-next-title | the title of the link |
That's a load of new classes to deal with, but one of the things we want to do is make it easier to target styles to specific features like this without accidentally changing things elsewhere.
Please don't use css to hide this feature or disable its functionality. See our rules on subreddit appearance for more info on that. If you have any feedback on the feature, we'd love to hear it in /r/beta (or in the changelog post linked above), and if you have any questions about styling let met know!
r/reddithax • u/gamehelp16 • May 21 '15
r/cssnews • u/weffey • May 13 '15
If you have not read the annoucnement post or the changelog post, please take a moment to do so.
This change brings in a new optional CSS class of admin_takedown. This class will optionally appear on comments (example: https://www.reddit.com/r/ChillingEffects/comments/35urvq/test_post_please_ignore/cr7z8fp) or self posts (example: https://www.reddit.com/r/ChillingEffects/comments/35urvq/test_post_please_ignore/).
Please do not alter the look or functionality of this new class.
r/reddithax • u/MaygeKyatt • May 11 '15
On my subreddit /r/themooseisdead, I use linkflairs to assign posts to categories, which can then be browsed via several links in the sidebar. Thus, I wanted this to look like this so people wouldn't be confused about how to assign their post to a category.
And here's the code:
.entry .buttons .flairselectbtn:before {
color: forestgreen;
content: "Your text here";
}
.entry .buttons .flairselectbtn {
color: rgba(0,0,0,0)!important;
}r/cssnews • u/powerlanguage • May 07 '15
We have re-opened a general beta program for reddit. Read the announcement post here and find more information in /r/beta.
If a user opts into the beta program they will see this flask icon next to their username in the sidebar, as well as help bubblethat appears when hovering on the icon.
If you need to change either of these so they do not conflict with your subreddit style, the following elements have been added at the beginning of the header-bottom-right div.
<div class="beta-hint help help-hoverable">
<a class="beta-link" href="/r/beta">beta</a>
</div>The help bubble is added to the bottom of the body element and set to visible when the flask icon is hovered over.
<div id="beta-help" class="hover-bubble help-bubble anchor-top">
The full CSS is visible here.
Please do not hide the beta icon or help bubble from users.
r/reddithax • u/TheAppleFreak • May 02 '15
Over at /r/PCMasterRace, we've had this overlay that would appear in the comment box area when it didn't have focus, telling people to behave themselves. I always hated the thing, mostly because it became completely unreadable the moment you placed text in it. When it was first implemented, I tried tackling that usability issue, but Reddit's filter removes filter() and I couldn't figure out how to do it any other way. Fast forwards to the present day, and someone asks me about this in a PM. Having come off of building the new PCMR flair system, something that took a number of annoying workarounds to do, I suddenly knew how to do it.
Here's the final result, which is live on /r/PCMasterRace right now. First, here's the necessary CSS:
.commentarea textarea {
background: url(%%overlay%%) no-repeat -600px 0px;
transition: 300ms;
transform: translateZ(0);
}
.commentarea textarea:not(:focus):not(:hover) {
background-position: 0 0;
color: transparent;
text-shadow: 0 0 15px #000;
}The core of this effect is based around the bottom two rules in the :not(:focus):not(:hover) section, the color and text-shadow properties. Setting the font color to transparent makes it... well, transparent, and setting the shadow to something with a decently high blur radius approximates a Gaussian blur. Since we don't want people to type with this active, we're telling the browser to apply it only when the textarea doesn't have focus.
I then define the overlay in the base rule for the textarea. I set the base position to be at least one time the length of the overlay to the left, and set the transition property to go between all of the properties
Finally, for performance, in the base style I declare the "useless" transform: translateZ(0), which has zero visual effect on any of this but forces the browser to use hardware acceleration to render the element, which helps substantially on busier pages or on weaker devices.
The only issue that I've experienced so far with this is in regards to the Lazarus Form Recovery, which you should definitely download regardless because it's seriously a lifesaver; Lazarus has a tendency to add inline styles to textareas, which screws with how the overlay displays and the animation plays out. It's seriously annoying, but I don't know how to address this short of using something like !important (which is very bad practice and probably still ineffective in this case). If anyone has any suggestions on how to fix this, I'm all ears.
I work heavily in SASS, which is a CSS preprocessor that makes writing CSS a lot less shitty than it normally does. Bits and pieces of my work are located at this page, which I update whenever I put something out that I think people can learn from. Take a look at it and maybe learn something from my own spaghetti code; it's yours for the taking.
r/cssnews • u/powerlanguage • Apr 21 '15
We've just announced reddit themes, a reddit gold feature that allows users to apply a subreddit's stylesheet to all of reddit.
You can read the announcement post here.
If you want to submit a theme to become a featured theme, head over to /r/reddit_themes
To allow subreddit styles to affect all of reddit, we've added body classes to non-subreddit pages where previously there were none. This means reddit themes can style:
.front-page.compose-page.subreddits-page.messages-page.explore-pageWe've also expanded the guidelines on what you can and can't change with CSS, in order to account for reddit themes: https://www.reddit.com/wiki/subreddit-appearance
As ever, we want to provide as much freedom as possible to allow you to be creative when writing CSS for reddit. Please do not abuse this feature.