ThomazPom / Moz-Ext-UltimaDark

Web Extension that uses agressive technique to get dark mode everywhere
93 stars 6 forks source link

[request] define link colors #34

Closed atomGit closed 8 months ago

atomGit commented 10 months ago

i gave it a quick spin and the most noticeable issue is link colors - consider adding the ability for users to define active, visited and default link colors like Dark Background and Light Text

other than that, and perhaps adding a quicker method to whitelist domains, subdomains and URL segments, it seems to work really well

ThomazPom commented 10 months ago

Hey @atomGit

Thank you for your review. it's highly appreciated. One of my primary goals with UltimaDark is to ensure accuracy in replicating the original site colors. UltimaDark is still highly exeperimental because use realy uncommon methotds to achieve this diffcult goal keeping a high performance Rest assured that I work on incorporating more customization options into UltimaDark and the ability for UltimaDark users to define active, visited, and default link colors is now in my target list.

If you have more suggestions or thoughts, please don't hesitate to open issues – I'm all ears!

Happy browsing with UltimaDark!

atomGit commented 10 months ago

if you care to explain, i am curious as to the method you're using to alter the colors - i looked through the code a bit, but i'm not really a programmer so i'm not understanding it - maybe you'd want to add this info in the readme

ThomazPom commented 10 months ago

Sure, thank you for asking

UltimaDark stands out from other extensions in its category by altering colors even before the Firefox renderer processes them. The UltimaDark code intercepts the page content at an early stage, right after it is fetched from the remote website. This preemptive editing prevents the renderer from displaying the default bright colors of the website before applying the dark theme, eliminating the jarring white flash during page loading.

During this initial edit, nothing has been parsed by the Firefox renderer yet—all values are still character strings. The challenge lies in identifying colors within these character strings and determining whether they will be used as background or foreground. This distinction is not an exact science, adding complexity to the process.

Once a color is detected, it undergoes the appropriate transformation, either darkening or brightening. After the transformation is complete, the original value is replaced in the character string, ready to be read by the renderer.

Let's focus specifically on the darkening transformation, as there are still refinements to be made in the brightening function.

² The darkening transformation begins by determining the lightness of the color. If it falls below a certain brightness threshold (B), it remains untouched, respecting the website's intended design.

For lightness values above B, the edit ensures it never exceeds a maximum lightness (A). The lightness scale ranges from 0 to 1, where 0 is black and 1 is fully white—unsuitable for a background.

You can review the transformation function here: Desmos Transformation Function.

UltimaDark also has the capability to edit pixels in images, although this feature is currently experimental and not fully functional. An example of the broken functionality can be seen on the Apple support page: Broken Example. On the other hand, the feature works better on the Sushi Spirit website: Not-So-Bad Example.

ThomazPom commented 10 months ago

The adjustment of website colors, rather than implementing a dark theme, aims to preserve the authenticity of the website's intended design.

ThomazPom commented 10 months ago

Here is the transformation of backgrounds colors by UltimaDark with current function and current settings BEFORE image AFTER image

atomGit commented 10 months ago

wow - this sounds very interesting - some Qs...

  1. if/when Moz decides to scrap manifest v2, will this affect you?
  2. assuming a more mature state, do you have any comment on performance vs. the current methods used by other extensions?
  3. regarding images, and given how the ext. works (before render), if an image is copied for use elsewhere (image editor), the copied image wouldn't be the original, would it? my thought here would be to avoid processing images, perhaps at user discretion, except for background images which could be removed
ThomazPom commented 10 months ago

Upon reviewing my initial response, I identified some inaccuracies and have made the necessary corrections.

  1. In this case, I'd just adapt to manifest V3, thank you for the reminder
  2. Other extensions which only a set of style rules might not have performance issues, as it's one of the most important feature of browsers. UltimaDark has to check and edit every applicable character string, and sometimes has to retain some chunks of data for few milliseconds to ensure to output a valid result. Performance is not an issue yet, and if it becomes one, I'll take necessary steps to address them. It is highly probable that UltimaDark is currently too slow for many users.
  3. Indeed, this observation holds true, and i may have to determine the best approach for addressing this scenario.
atomGit commented 10 months ago

thank you for your comments - much appreciated

i'll leave it to you to close this issue as you see fit since it was originally about link colors

have a good one!

Vintagemotors commented 8 months ago

Closing as duplicate.