Skip to content

Instantly share code, notes, and snippets.

@afnizarnur
Last active August 25, 2023 14:59
Show Gist options
  • Save afnizarnur/996259dccdeb95fac5d4119dac582581 to your computer and use it in GitHub Desktop.
Save afnizarnur/996259dccdeb95fac5d4119dac582581 to your computer and use it in GitHub Desktop.
Threads Auto Device Theme User Scripts
// ==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