Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[request] define link colors #34

Closed
atomGit opened this issue Dec 9, 2023 · 9 comments
Closed

[request] define link colors #34

atomGit opened this issue Dec 9, 2023 · 9 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@atomGit
Copy link

atomGit commented Dec 9, 2023

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
Copy link
Owner

ThomazPom commented Dec 10, 2023

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
Copy link
Author

atomGit commented Dec 10, 2023

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
Copy link
Owner

ThomazPom commented Dec 10, 2023

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.

  • Lightness values from 0 to B are preserved as-is.
  • Lightness values from B to 0.5 are scaled from B to A.
    • It might be a good option to shortcut this rule for lightness from B to A ( Do not edit site colors which are already under maximum lightness A, thus keeping exactly these intended colors as is)
  • Lightness values from 0.5 to 1 are reversed and then scaled from A to B.
    • This implies lightness values of 1 (white) are then equals to B (not reversed to black !), ensuring good contrast with colors at point ².

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
Copy link
Owner

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

@ThomazPom
Copy link
Owner

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

@atomGit
Copy link
Author

atomGit commented Dec 10, 2023

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
Copy link
Owner

ThomazPom commented Dec 10, 2023

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
Copy link
Author

atomGit commented Dec 10, 2023

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 Vintagemotors added the enhancement New feature or request label Dec 30, 2023
@Vintagemotors
Copy link
Collaborator

Closing as duplicate.

@Vintagemotors Vintagemotors added the duplicate This issue or pull request already exists label Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants