Created
August 31, 2023 02:51
-
-
Save afnizarnur/7f05ea8075c321c1861c1fa80ce3a7e7 to your computer and use it in GitHub Desktop.
Instagram 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 Instagram Auto Device Theme | |
// @version 1.0.0 | |
// @grant none | |
// @author Afnizar Nur Ghifari | |
// @license GPL-3.0-or-later | |
// @match https://www.instagram.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=instagram.com | |
// @grant none | |
// ==/UserScript== | |
function setThemePreference() { | |
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
localStorage.setItem('igt', isDarkMode ? 'dark' : 'light'); | |
} | |
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