Last active
December 17, 2024 00:08
-
-
Save fanzeyi/6bc0c8e9fa560f6bd38eb36f7f749468 to your computer and use it in GitHub Desktop.
Twitter Auto Dark Mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Twitter auto darkmode | |
// @version 1 | |
// @grant none | |
// @match *://twitter.com/* | |
// ==/UserScript== | |
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => { | |
const isDarkMode = e.matches ? 1 : 0; | |
document.cookie = `night_mode=${isDarkMode};path=/;domain=.twitter.com;secure`; | |
}); |
If you prefer the dark mode to be lights out instead of dim, change this line:
const isDarkMode = e.matches ? 1 : 0;
to this:
const isDarkMode = e.matches ? 2 : 0;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
after rebrand