Whatsapp Toggle (Hide/Show) Contacts By N.S

Creates A Toggle Button Switch Which Hides And Shows The WhatsApp Contacts And Messages For Privacy (Also ESC Key can be used)

当前为 2020-11-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name     Whatsapp Toggle (Hide/Show) Contacts By N.S
// @version  1.1
// @grant    none
// @match    *://web.whatsapp.com/*
// @description Creates A Toggle Button Switch Which Hides And Shows The WhatsApp Contacts And Messages For Privacy (Also ESC Key can be used)
// @namespace astroid.com.tr
// ==/UserScript==

var myInterval1 = setInterval(AddCButton ,1000);
var myInterval2 = setInterval(AddMButton ,1000);

function AddCButton() {
    var paneSide = document.getElementById("pane-side");
    var myDiv = document.getElementById("pane-side").parentElement;

    if(myDiv == null){
        console.log("there is no element...");
        return;
    }


    // creating button element
    var button = document.createElement('BUTTON');

    // creating text to be
    //displayed on button
    var text = document.createTextNode("Hide / Show");

    // appending text to button
    button.id = 'myButton';
    button.appendChild(text);
    button.onclick = function() { HideOrShowContacts() };
    button.style.color = 'red';
    button.style.border = '1px solid';
    button.style.height = '100%';
    button.style.fontSize = '18px';
    button.style.cursor = 'row-resize';


    // appending button to div
    myDiv.append(button);

    myDiv.insertBefore(button, paneSide);

    clearInterval(myInterval1);
    HideOrShowContacts();
    console.log("Button Has Been Added. Timer Suspended")
}


function AddMButton() {
    var main = document.getElementById("main");
    var myDiv = document.getElementById("main").parentElement;

    if(myDiv == null){
        console.log("there is no main parent element...");
        return;
    }


    // creating button element
    var button = document.createElement('BUTTON');

    // creating text to be
    //displayed on button
    var text = document.createTextNode("Hide / Show");

    // appending text to button
    button.id = 'myButton2';
    button.appendChild(text);
    button.onclick = function() { HideOrShowMain() };
    button.style.color = 'red';
    button.style.border = '1px solid';
    button.style.height = 'auto';
    button.style.width = '30%';
    button.style.fontSize = '18px';
    button.style.cursor = 'row-resize';
    button.style.position = 'absolute';
    button.style.marginLeft = '35%';
    button.style.zIndex = '9999';
    button.style.top = '5px';


    // appending button to div
    myDiv.append(button);

    myDiv.insertBefore(button, main);

    clearInterval(myInterval2);
    HideOrShowMain();
    HideOrShowMain();
    console.log("Main Button Has Been Added. Timer Suspended")
}

function HideOrShowContacts() {
    var pane = document.getElementById("pane-side");
    if (pane.style.display === "none") {
        pane.style.display = "flex";
        document.getElementById("myButton").innerText = 'Hide Contacts';
    } else {
        pane.style.display = "none";
        document.getElementById("myButton").innerText = 'Show Contacts';
    }

}

function HideOrShowMain() {
    var main = document.getElementById("main");
    if (main.style.display === "none") {
        main.style.display = "flex";
        document.getElementById("myButton2").innerText = 'Hide Messages';
    } else {
        main.style.display = "none";
        document.getElementById("myButton2").innerText = 'Show Messages';
    }

}

document.onkeydown = function(evt) {
    evt = evt || window.event;
    if (evt.keyCode == 27) {

//         var main = document.getElementById("main");
//         var pane = document.getElementById("pane-side");
//         main.style.display = "none";
//         pane.style.display = "none";
        HideOrShowContacts();
        HideOrShowMain();
    }
};


// AddButton();
//HideOrShow();