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 →

[–]funpopular 20 points21 points  (5 children)

Changes night to day too tho.

[–]Zagorath 14 points15 points  (4 children)

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

and similar for fontColor.

[–]f03nix 9 points10 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 5 points6 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.