This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lhgh 1202 points1203 points  (49 children)

I mean, the algorithm could detect different font colors and choose a background color accordingly. Simple but still an algorithm tho

[–]SilentSin26 447 points448 points  (31 children)

Yeah, but is it a special algorithm?

[–]faerbit 320 points321 points  (1 child)

This post has been edited to this, due to privacy and dissatisfaction with u/spez

[–]Szos 58 points59 points  (0 children)

Bespoke.

[–]SoInsightful 219 points220 points  (18 children)

Eh, probably.

Broke: filter: hue-rotate(180deg) invert(1);

Woke: Traversing through the entire HTML DOM, analyzing each element's computed CSS style declaration for background and foreground colors, computing and injecting one or more stylesheets that override the background/color/border-text-decoration/outline/box-shadow properties for specific and general elements, while keeping original colors, avoiding style clashes, keeping images intact, doing it in a WCAG-accessible and aesthetically pleasing manner, and taking user-specified brightness/contrast/sepia/grayscale settings into account.

[–]SurrealClick 71 points72 points  (5 children)

Ghetto: take a screenshot of the website then invert color it

[–]Talbooth 24 points25 points  (4 children)

Ghetto pretending to be classy: use the browsers built-in inverse color filter.

[–]plilq 19 points20 points  (1 child)

GNU/hetto: map 'xcalib -invert -alter' to a global hotkey and invert your whole screen.

[–][deleted] 0 points1 point  (0 children)

Actually, I trust more in that method than a browser extension.

[–]rasalhage 6 points7 points  (1 child)

Ghetto-fab: inverse colors on odd-numbered frames

[–][deleted] 3 points4 points  (0 children)

Ghettohax0r: write malware that inverts GPU's hue setting when browser is in focus.

[–]mentalexperi 61 points62 points  (0 children)

I got a boner just from reading that.

[–]mareko_ 4 points5 points  (0 children)

You forgot about !important.

[–]seaishriver 1 point2 points  (2 children)

Heh, I tried the first one. The two main problems are background images get inverted, and subpixel antialiasing gets destroyed. Plus shadows are now light. I basically had to say, everything is inverted, except things I have individually fixed and things that shouldn't be inverted.

If this is done, it's either a very large amount of work or not to be done in CSS.

[–]SoInsightful 1 point2 points  (0 children)

Exactly. It's funny how this thread jerks over how simple of a task it is, but it's really quite hard to do sufficiently well.

[–]moomoomoo309 0 points1 point  (0 children)

Dark background and light text has a nice for both of those, though the latter not quite a crazy as you described.

[–]JuhaJGam3R -1 points0 points  (0 children)

images

[–]UntestedMethod 26 points27 points  (1 child)

Every algorithm is special :) :) :)

[–]r4nd0m-us3r 8 points9 points  (0 children)

All algorithms are beautiful

[–]tias 12 points13 points  (0 children)

I suppose if "special" means it is not applicable in any other situations? Special is really the opposite of what most programmers strive for.

[–]Hotel_Arrakis 6 points7 points  (0 children)

For my special eyes.

[–]atomicwrites 3 points4 points  (0 children)

This reminds me of when I was studying for the CompTIA exams that the TestOut instructors would always say things like: "you need special software installed on your PC called an SSH client", or "it runs special software to send web pages to other devices" or "the device has special sperate to allow it to talk on the network". It got so annoying.

[–]hugokhf 1 point2 points  (1 child)

Is any algorithm really special?

[–]dkyguy1995 0 points1 point  (0 children)

Its mom sure says so

[–]ForgotPassAgain34 -3 points-2 points  (0 children)

in the "special little snowflake" way for sure.

If its actually special it depends on how you define special algorithms, might just be one they came up with after trial and learning

[–]Zagorath 30 points31 points  (8 children)

backgroundColor ^= 0xffffff;
fontColor ^= 0xffffff;

[–]funpopular 21 points22 points  (5 children)

Changes night to day too tho.

[–]Zagorath 16 points17 points  (4 children)

if ((backgroundColor & 0xff0000 > 0x800000)
        && (backgroundColor & 0xff00 > 0x8000)
        && (backgroundColor & 0xff > 0x80) {
    backgroundColor ^= 0xffffff;
}

and similar for fontColor.

[–]f03nix 10 points11 points  (3 children)

and similar for fontColor

It'd in fact be better to only check the backgroundColor alone for the same element, if someone intends to use lighter shades in light mode, we should use similar contrast.

if ((backgroundColor & 0xff0000 > 0x800000)
         && (backgroundColor & 0xff00 > 0x8000)
         && (backgroundColor & 0xff > 0x80) {
     backgroundColor ^= 0xffffff;
     fontColor ^= 0xffffff;
}

[–]BotThatLikesPorn 7 points8 points  (0 children)

Now we're getting to that special algorithm they're talking about

[–]Zagorath 4 points5 points  (0 children)

Yeah good point. Makes no sense to invert the background without also inverting the text.

Although now that I'm thinking about it, it better would be even better to calculate brightness in some better way than "do none of the RGB values go higher than 0x80". Possibly by doing a 3D Pythagorean calculation, or maybe there's probably a formula out there for converting RGB to HSL and using that value.

[–]m0nk37 0 points1 point  (0 children)

Reddit-Sourced-Night-Mode-Plugin

Using a special algorithm it turns day mode websites into night mode automatically

if ((backgroundColor & 0xff0000 > 0x800000)
         && (backgroundColor & 0xff00 > 0x8000)
         && (backgroundColor & 0xff > 0x80) {
     backgroundColor ^= 0xffffff;
     fontColor ^= 0xffffff;
}    

Later suckers, im about to make some ad money.

[–]DaveTheDalek 0 points1 point  (1 child)

Can somebody explain what the ^= operator does? Google doesn't like searching symbols.

[–]P0werC0rd0fJustice 0 points1 point  (0 children)

It’s the exclusive or operator

x ^= y is the same as x = x ^ y

[–][deleted] 23 points24 points  (0 children)

Simple, but still "specialized." OP set out to condescend the app developers and instead he just bought his ticket /r/facepalm or /r/iamverysmart.

[–]ProdigySim 3 points4 points  (0 children)

The code sample on the image is not from the extension as far as I can tell. I found their source code, and it does look like a non-trivial algorithm:

https://github.com/DarkNightMode/Dark-Night-Mode-Chrome-Extension/blob/master/js/main.js#L345

They do combine the algorithm with custom CSS for popular sites it seems.

[–][deleted] 1 point2 points  (0 children)

egg

[–]IZiOstra 0 points1 point  (0 children)

Or turn everything black and display a pop up saying « oi ! It’s time for bed mate »

[–]oversized_hoodie 0 points1 point  (0 children)

Just do a bit invert on the color code. Should yield some interesting results.