r/reddithax • • Jul 30 '15

Reddit CSS and randomization

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.

2 Upvotes

5 comments sorted by

View all comments

Show parent comment

2

u/Goctionni Jul 30 '15 edited Jul 30 '15

Yeah I'd found that I needed to get to the <a> element after also. Aside from overlaying something over the entire thing, is there any known way to avoid the onclick behavior for the :after element?

[edit] I've found that RES adds some random id to it's "Use subreddit style" checkbox. Hypothetically it should be possible to hook onto that and fallback to the logout element when the body tag doesn't have the "res" class, right?

That seems at least a minor improvement :s.

[edit2] Found:

pointer-events: none;

Works perfectly in chrome, but apparently not so much in some other browsers. Will need to do some testing.

1

u/gavin19 Jul 30 '15

Yeah, it'll work in most modern browsers but having a blocking element will work 100% of the time.

1

u/Goctionni Jul 30 '15

I kind of intend to have it moving around the page; so not a good option in this case.

Mind you; this will only be a temporary thing for an event :)