Last active
May 19, 2020 13:09
-
-
Save kaveenr/5db88fd525135e8978a31148b8383d34 to your computer and use it in GitHub Desktop.
WhatsApp Colour Scheme Switcher
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 WhatsApp Color Scheme Switcher | |
// @namespace https://kaveenrodrigo.com/ | |
// @version 0.1 | |
// @description WhatsApp Color Sceheme Switcher. | |
// @author Kaveen Rodrigo | |
// @match https://web.whatsapp.com/ | |
// @grant none | |
// ==/UserScript== | |
function setTheme(color) { | |
document.body.className = color == "dark" ? "web dark" : "web"; | |
} | |
(function() { | |
'use strict'; | |
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { | |
setTheme("dark"); | |
} | |
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => { | |
const newColorScheme = e.matches ? "dark" : "light"; | |
setTheme(newColorScheme); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment