Discussions » Creation Requests

Force Dark Theme on Google Search

§
Posted: 2024-04-01

Anyone has any idea how to force Google Search to use the dark theme by default? I mostly use Google Search on incognito, and even though I have Windows on dark mode, Google will use the light theme until I interact with the page and refresh it, which means I'm flashbanged every time I want to search something. I have no idea what happens when you manually change the theme, I've looked through local storage, cookies and search parameters, but nothing stands out.

§
Posted: 2024-04-01

I took a look at the problem

Anyone has any idea how to force Google Search to use the dark theme by default?

It is complicated. Maybe you need to try some scripts/extensions that are trying to achieve dark themes everywhere and restrict them to Google Search only. It is not going to be like the built in dark theme, but still

I have no idea what happens when you manually change the theme, I've looked through local storage, cookies and search parameters, but nothing stands out

It seems that Google only gives you a page with one style and you can't just change the style right away without reloading the page. When changing the theme in the settings, there is a GET request occurs responsible for that:

https://www.google.com/setprefs?sig=SOME_ID&authuser=0&cs=2&noredirect=1

sig is some kind of unique id inherent in your browser (I didn't find it in the storage either, perhaps it is somehow generated from other data in the storage), and cs is responsible for what theme should be assigned. But for an empty browser I don't think this sig is exists, because it is probably generated when the page is visited. I think that to switch the theme you must in any case visit the page with the white theme

§
Posted: 2024-04-01

I took a look at the problem

Anyone has any idea how to force Google Search to use the dark theme by default?

It is complicated. Maybe you need to try some scripts/extensions that are trying to achieve dark themes everywhere and restrict them to Google Search only. It is not going to be like the built in dark theme, but still

I have no idea what happens when you manually change the theme, I've looked through local storage, cookies and search parameters, but nothing stands out

It seems that Google only gives you a page with one style and you can't just change the style right away without reloading the page. When changing the theme in the settings, there is a GET request occurs responsible for that:

https://www.google.com/setprefs?sig=SOME_ID&authuser=0&cs=2&noredirect=1

sig is some kind of unique id inherent in your browser (I didn't find it in the storage either, perhaps it is somehow generated from other data in the storage), and cs is responsible for what theme should be assigned. But for an empty browser I don't think this sig is exists, because it is probably generated when the page is visited. I think that to switch the theme you must in any case visit the page with the white theme

That sucks. Thanks for looking into it. I already use Dark Reader, but I avoid using it on websites I frequently use, don't like how it looks. For now I've settled for just copying all the 9000 lines of CSS the Google Search results page have and injecting them using Stylus. But it's probably gonna break often because I have a feeling Google changes those selectors constantly.

Post reply

Sign in to post a reply.