Greasy Fork is available in English.

Default YouTube to Dark Theme

Makes YouTube default to its Dark Theme by initialising the relevant cookie

Pemasangan harian
Total pemasangan
1 0 0
Berlaku untuk


If you regularly clear your cookies, or limit their lifespan, then YouTube will keep forgetting that you chose to use the Dark Theme. You might find this annoying and wish for just that one piece of information to be remembered. You might want to use a userscript to achieve this.

How it works

At document-start, the script checks to see whether the PREF cookie for exists. If it exists, then the script does nothing, on the assumption that your preferences are as you left them. If the PREF cookie does not exist, then the script assumes that cookies have been cleared/deleted at some point, and it initialises the PREF cookie with the value f6=400, which seems to correspond to enabling the Dark Theme.

And that's it. There are other scripts that force-enable the Dark Theme, but they all seem to do it by navigating the user interface to press the toggle button that enables/disables the Dark Theme. I think setting the cookie is a more elegant solution.

But I was trying to avoid cookies, and now you're auto-generating one when I visit YouTube!

If you turn on the Dark Theme by pressing the toggle switch in the menu, then YouTube is going to set a cookie. That's how the setting persists across multiple open tabs. It's what you might call an "essential cookie" in GDPR-speak. It's fundamental to providing the functionality. This script just cuts out the middle man that is YouTube's user interface.

(I suspect most of you already know this, though.)

Version history

0.1. First release. 0.2. Correction to logic to determine whether PREF cookie exists.