NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Whattsapp Theme Editor
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Add Whatsapp Web toggle setting for dark mode.
// @author m00n_byt3
// @copyright 2020, m00n_byt3 (https://openuserjs.org/users/m00n_byt3)
// @license MIT
// @match https://web.whatsapp.com/
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// ==/UserScript==
//Comment the line below for preloading Whatsapp Web on Default Mode
document.body.className = 'web dark';
waitForKeyElements ("._2sNbV", set);
function set() {
var div = document.getElementsByClassName("_1CkkN")[1];
var mod = document.getElementsByClassName("_1CkkN");
var clone = div.cloneNode(true);
clone.title = "Theme";
document.getElementsByClassName("_2sNbV")[0].appendChild(clone);
if (document.body.className == 'web') {
document.getElementsByClassName("_3LL06")[4].innerHTML = "Set Dark theme";
mod[4].setAttribute("onclick","document.body.className = 'web dark';");
} else {
document.getElementsByClassName("_3LL06")[4].innerHTML = "Set Default theme";
mod[4].setAttribute("onclick","document.body.className = 'web';");
}
}