Skip to content

Instantly share code, notes, and snippets.

@kaveenr
Last active May 19, 2020 13:09
Show Gist options
  • Save kaveenr/5db88fd525135e8978a31148b8383d34 to your computer and use it in GitHub Desktop.
Save kaveenr/5db88fd525135e8978a31148b8383d34 to your computer and use it in GitHub Desktop.
WhatsApp Colour Scheme Switcher
// ==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