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

Extension disabling Youtube dark mode #2138

Closed
MarckVinny opened this issue Mar 31, 2024 · 9 comments
Closed

Extension disabling Youtube dark mode #2138

MarckVinny opened this issue Mar 31, 2024 · 9 comments
Assignees
Labels
Bug Bug or required update after YouTube changes Feature request Wish or idea good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥

Comments

@MarckVinny
Copy link

When the extension is activated in Chrome, it disables YouTube's dark mode.

Captura de tela 2024-03-31 144303

@MarckVinny MarckVinny added Bug Bug or required update after YouTube changes Feature request Wish or idea good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥ labels Mar 31, 2024
@c4sper877
Copy link

Can confirm. This has started happening to me earlier today too.

@JosephFak
Copy link

I would like to work on this issue if possible!

@raszpl
Copy link
Contributor

raszpl commented Apr 1, 2024

https://github.com/code-charity/youtube/pull/2133/files#diff-ad1de0cf5cc7ea5db3b94e51d5f33a6f51d8f6c5592fec0a865cab9840bf21d7

this wouldnt cause it. All the people who at some point in the past experimented changing improvedtube themes now have storage.theme set to 'default'. improvedtube "default" overrides YT settings :(
edit: even no theme overrides it

I read original code wrong (I blame bad indentation :) ) https://github.com/code-charity/youtube/blob/7d4429374188c1cac12797cf7e695aba25ccf817/js%26css/web-accessible/www.youtube.com/themes.js

missed the purpose of if (typeof cookieValue !== 'undefined'){

'default' is really bad name for this option, again should be called 'disabled' to clearly signal extension does nothing
I finally understand what you meant in #2134 (comment)

@raszpl
Copy link
Contributor

raszpl commented Apr 1, 2024

@MarckVinny @c4sper877 @JosephFak for a quick fix go to extension options / themes and select "Youtube dark"

@ImprovedTube
Copy link
Member

ImprovedTube commented Apr 1, 2024

hi! @raszpl i dont get issues in versions before #2075, besides this one confusing thing: default(none/disabled/off) only removed themes but didn't change the attribute or cookie back to light (80000) or system (0), because we dont consider if the previous was only set to youtube's dark theme with us for a few seconds or minutes or day or set like that with youtube or for long already.

  • thats why youtube's dark theme was moved to the bottom and considered to be removed. Or there can be 3 options with lower height above our themes just mirroring youtube's 3 settings.

While the original darkmode shortcut seem to work and sticks after reloads. (From changing the attribute only?) I added your cookie code for now: it will not remove ambient light/cinematics anymore when going to the light theme.

@raszpl
Copy link
Contributor

raszpl commented Apr 1, 2024

hi! @raszpl i dont get issues in versions before #2075

pre 2075 https://github.com/raszpl/YouTube-Extension/blob/99e6853e179bbbb50d7405780dee8942daf0586c/content-scripts/website-context/youtube-features/themes.js switching black/dark>default>black/dark>any theme corrupted cookie (cookievalue a global variable) and couldnt switch from custom/dark/black to default without reloading whole page

besides this one confusing thing: default(none/disabled/off) only removed themes but didn't change the attribute or cookie back to light (80000) or system (0)

all theme settings did force overwrite of cookie if you switched couple times in a row:
switch to black/dark - cookieValue not set, dark attribute is added
switch to default - dark attribute stays
switch to black/dark - dark attribute present = cookieValue set to 400, and then cookieValue = pref.replace(/(f6=)[^\&]+/, cookieValue); to contents of whole previous cookie
switch to any light theme - cookieValue is already a copy of whole cookie so it passes if (typeof cookieValue !== 'undefined'){, then cookie is being overwritten and corrupted

thats why youtube's dark theme was moved to the bottom and considered to be removed.

even without dark switching black>default>black>any will corrupt cookie as above

While the original darkmode shortcut seem to work and sticks after reloads. (From changing the attribute only?) I added your cookie code for now: it will not remove ambient light/cinematics anymore when going to the light theme.

https://github.com/code-charity/youtube/blob/7c9292be5dd69882b31659677fda490bb761259b/js%26css/web-accessible/www.youtube.com/themes.js
cause is 'default' executing same changes as all light themes
fix #2139
change that "fixes" new build is 0c1bac2 because now themes arent being loaded at all :). Needs some more patching to be able to just ignore [dark] and switch with pure CSS. #2143

(And that's why YouTube's black mode would only keep YouTube's dark if it was enabled previously, not force the cookie change always like now.) if (document.documentElement.hasAttribute('dark') !== null && document.documentElement.hasAttribute('dark') ){ cookieValue = '400'; }

if that was the intention then why touch cookie in the first place? What is the point of this code? If it worked correctly (it doesnt) it would want to force F6 to 400 only if it was already set to 400!?!?!

Now that I understand this better my solution is to remove any cookie manipulation in the first place. We dont need to touch F6 to switch themes. This 68995be & #2143 removes the need for setting cookie, overrides last few elements Youtube forgot in their own dark mode CSS.
Best to just delete cookie manipulation altogether.

@ImprovedTube
Copy link
Member

because now themes arent being loaded at all :).

just haven't seen our CSS themes fail at page load

Needs some more patching to be able to just ignore [dark] and switch with pure CSS.

💡🤔

68995be

🎉

Don't know how synonym (or not) attribute & cookie work now or in history. So generally might choose to use both methods at need or just to back each other up, when correctly considering 80000 and no f6., since we already consider traps like list-view) The original author might faced other issues still. Even though back then youtube had also already started their dark theme too. (You might also noticed our "night mode", with schedule. I don't know why these features didnt stay in the same section (besides that operating systems have night mode). To me the theme previews look like maybe there also was an idea to keep working on it and have a dynamic theme changing all around the clock)
😅
More importantly @raszpl, I hope the themes can't frustrate! (Will be so happy to think hard, if the chance shall happen that i will notice you looking for new tasks.)

@ImprovedTube
Copy link
Member

and i remembered only changing the attribute also doesn't stick when logged out of youtube?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug or required update after YouTube changes Feature request Wish or idea good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥
Projects
None yet
Development

No branches or pull requests

5 participants