Add button and hotkey to hide contact names and avatars on web.whatsapp.com
< 脚本Whatsapp Web Privacy Mode的反馈
I updated it 3 days ago to fit the new classnames so it works perfectly again for me now.
Your version also won't work anymore because of the new classnames. You never gave feedback what you actually wanted.
For code to show up nicely here, select "Markdown" on top and put your code between three backticks like
>```
>your
>code here
>```
without the >
So actually you wanted all the same but without showing the button? For this just outcomment line 29 like this:
//addButton('Hide / F7', toggleShowHide);
Ok, so basically, I what I want is
No button
Makes the name of the person you are messaging invisible (profile picture and last seen is visible)
hides the side panel.
I never actually gave feedback about what I wanted cos it felt like I was demanding you to do it for me, so I just tried to figure it out myself.
This time, I can't figure it out, so, could you do that for me?
Thanks.
cos it felt like I was demanding you to do it for me
No worries, I won't do it if I don't want or have no time ;-)
Try if this fulfills your needs:
// ==UserScript==
// @name Whatsapp Web Privacy Mode light
// @namespace graphen
// @version 1.8
// @description Add button and hotkey to hide contact names and avatars on web.whatsapp.com
// @author Graphen
// @match https://web.whatsapp.com/
// @grant none
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
'use strict';
var hidden = false;
window.addEventListener('load', () => {
document.addEventListener("keydown", function(e) {
var keyCode = e.keyCode;
if(keyCode==118) {
toggleShowHide();
}
}, false);
});
function toggleShowHide() {
var sidepanel = document.getElementById('pane-side');
var contactname = document.getElementsByClassName('_1WBXd')[0];
if (hidden) {
console.log("WA Privacy: Toggled show.");
try { // show
sidepanel.setAttribute('style', 'display:block');
contactname.setAttribute('style', 'visibility:visible !important;');
} catch(err) {
console.log("toggleShow: " + err);
}
} else {
console.log("WA Privacy: Toggled hide.");
try { // hide
sidepanel.setAttribute('style', 'display:none');
contactname.setAttribute('style', 'visibility:hidden !important;');
} catch(err) {
console.log("toggleHide: " + err);
}
}
hidden = !hidden;
}
})();
That was amazing. The only thing I changed was in line 26, from
var contactname = document.getElementsByClassName('_1WBXd')[0];
to
var contactname = document.getElementsByClassName('_2EbF-')[0];
so that I can see the online status. You have my greatest thanks :grin:
cos it felt like I was demanding you to do it for me
No worries, I won't do it if I don't want or have no time ;-)
Alright, I'm new to online forums n stuff, so I'm not sure about etiquette. Anyway, thanks again. :grin:
You're welcome.
But changing that class results in contact names still shown in group chats.
Doesn't seem to work anymore.
Also, I made a slightly modified version of your code for the intended effect I previously requested. It actually worked for a while :)
// ==UserScript== // @name WhatsApp Web Privacy Mode lite // @namespace graphen // @version 1 // @description Hide/show chat title by pressing F7. // @author Graphen, Andrew // @match https://web.whatsapp.com/ // @grant none // ==/UserScript== /*jshint esversion: 6 */ (function() { 'use strict'; var hidden = false; window.addEventListener('load', () => { document.addEventListener("keydown", function(e) { var keyCode = e.keyCode; if(keyCode==118) { toggleShowHide(); } }, false); }); function toggleShowHide() { var panel = document.getElementsByClassName('chatlist-panel-body')[0]/.getElementsByClassName('_2wP_Y').getElementsByClassName('chat-title')[0]/; if (hidden) { panel.setAttribute('style', 'display:block'); document.getElementsByClassName('pane-chat-header')[0].getElementsByClassName('chat-title')[0].getElementsByTagName('span')[0].setAttribute('style', 'display:block;'); } else { panel.setAttribute('style', 'display:none'); document.getElementsByClassName('pane-chat-header')[0].getElementsByClassName('chat-title')[0].getElementsByTagName('span')[0].setAttribute('style', 'display:none;'); } hidden = !hidden; } })();