Whatsapp Web Hide Show contacts

try to take over the world!

As of 25.03.2017. See апошняя версія.

// ==UserScript==
// @name         Whatsapp Web Hide Show contacts
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://web.whatsapp.com/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var hidden = false;
    window.addEventListener('load', () => {
     addButton('Show/Hide', toggleShowHide);
    });

    function addButton(text, onclick, cssObj) {
        cssObj = cssObj || {position: 'absolute', bottom: '7%', left:'90%', 'z-index': 3};
        let button = document.createElement('button'), btnStyle = button.style;
        document.body.appendChild(button);
        button.innerHTML = text;
        button.onclick = onclick;
        Object.keys(cssObj).forEach(key => btnStyle[key] = cssObj[key]);
        return button;
    }

    function toggleShowHide() {
        if (hidden) {
            document.getElementsByClassName('chatlist-panel')[0].setAttribute('style', 'display:block');
        } else {
            document.getElementsByClassName('chatlist-panel')[0].setAttribute('style', 'display:none');
        }
        hidden = !hidden;
    }
})();