try to take over the world!
当前为
// ==UserScript==
// @name New Userscript
// @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;
}
})();