whatsapp-desktop-dark icon indicating copy to clipboard operation
whatsapp-desktop-dark copied to clipboard

[not an issue] [enhancement] Userscript implementation?

Open ndrew222 opened this issue 4 years ago • 2 comments

Very cool. I'm just wondering, is it possible to add a userscript to the whatsapp desktop app? I usually use this userscript to hide my contacts and the currently open chat with a hotkey, but I haven't really used the desktop app cos I haven't been able to get the userscript. The userscript is like this. Again, I'm not even sure if it can be implemented into the app, but it would be pretty epic if it's possible.

// ==UserScript==
// @name         Whatsapp Web Privacy Mode lite
// @namespace    graphen
// @version      1.8
// @description  Add button and hotkey to hide contact names on web.whatsapp.com
// @author       Graphen
// @match        https://web.whatsapp.com/
// @icon         https://i.imgur.com/LeZuNg7.png
// @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==115) {
                 toggleShowHide();
             }
         }, false);
        });
        function toggleShowHide() {
          var sidepanel = document.getElementById('pane-side');
          var contactname = document.getElementsByClassName('_1lpto')[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;
        }
    })();

ndrew222 avatar Sep 23 '19 15:09 ndrew222

Hi @ndrew222, I've been fiddling with a few modification scripts for WA desktop myself. But injecting scripts is way too complicated and time consuming so far. I do like to see this come to life but it might take some time till i can come up with something stable. I'll keep this in consideration. Thanks for the suggestion.

m4heshd avatar Sep 23 '19 20:09 m4heshd

UPDATE: I think we're on the right path now because i was able to inject a Dark/Light mode switch button to the UI. This might become possible. 🤞🏼

m4heshd avatar Feb 01 '20 11:02 m4heshd