Last active
August 25, 2023 14:59
-
-
Save afnizarnur/996259dccdeb95fac5d4119dac582581 to your computer and use it in GitHub Desktop.
Threads Auto Device Theme User Scripts
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 Threads Auto Device Theme | |
// @version 1.0.0 | |
// @grant none | |
// @author Afnizar Nur Ghifari | |
// @license GPL-3.0-or-later | |
// @match https://www.threads.net/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=threads.net | |
// @grant none | |
// ==/UserScript== | |
function setThemePreference() { | |
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
localStorage.setItem('barcelona_theme', isDarkMode ? 'ENABLED' : 'DISABLED'); | |
} | |
window.addEventListener('load', function() { | |
setThemePreference(); | |
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', setThemePreference); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment