Skip to content

Instantly share code, notes, and snippets.

@fanzeyi
Last active November 21, 2020 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fanzeyi/6bc0c8e9fa560f6bd38eb36f7f749468 to your computer and use it in GitHub Desktop.
Save fanzeyi/6bc0c8e9fa560f6bd38eb36f7f749468 to your computer and use it in GitHub Desktop.
Twitter Auto Dark Mode
// ==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`;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment