In Javascript from a PAGE and not from the devtools themselves is there currently a way to determine if Chrome's devtools are using dark mode instead of the "normal mode"?
I did find a bug report with a ment about this but it looks like that only relates to Chrome extensions.
In Javascript from a PAGE and not from the devtools themselves is there currently a way to determine if Chrome's devtools are using dark mode instead of the "normal mode"?
I did find a bug report with a ment about this but it looks like that only relates to Chrome extensions.
Share Improve this question edited Jan 31, 2017 at 15:40 Alexis Tyler asked Jan 31, 2017 at 15:14 Alexis TylerAlexis Tyler 9686 gold badges32 silver badges51 bronze badges 6-
Yes. If you open the element inspector on the dev tools, the class
-theme-with-dark-background
is attached to the document body. Look for that. From there you can write some javascript to get the answer you want. – Seiyria Commented Jan 31, 2017 at 15:33 - Is that class accessible from a site or just the devtools themselves though? – Alexis Tyler Commented Jan 31, 2017 at 15:35
- The devtools themselves are an inspectable browser window. As for how you'd access this info from, say, another context like a chrome extension or the parent chrome window, I don't know if that'd be possible. – Seiyria Commented Jan 31, 2017 at 15:37
- So that doesn't answer this at all. I already mentioned extensions can access this via a built in object. – Alexis Tyler Commented Jan 31, 2017 at 15:38
- 1 Well, it does provide an answer if you have the devtools up for the devtools themselves. You didn't specify what context you were trying to get this information in. – Seiyria Commented Jan 31, 2017 at 15:39
1 Answer
Reset to default 7No, it's not available from a page.
It is only available for extensions in javascript via:
chrome.devtools.panels.themeName
The name of the color theme set in user's DevTools settings. Possible values:
default
(the default) anddark
.Since Chrome 59.
Source: https://developer.chrome./extensions/devtools_panels
So it's technically possible to write an chrome-extension that reads the value and then exposes that to the page via a class or javascript variable.
But requiring your visitors to install an extension for detecting dark mode just isn't practical.