Modify and Reply To Deleted WhatsApp Texts [A How-To Guide]

Written by zer0k | Published 2020/02/24
Tech Story Tags: whatsapp | javascript | chrome-extensions | hacking | javascript-top-story | coderlife | how-to-read-deleted-messages | whatsapp-web-hacks

TLDR Aakash Khatu created a Chrome extension that allows you to restore deleted messages on WhatsApp web. The extension stores all messages it receives locally. When a message gets deleted, it adds the previously known message contents to a deleted messages array. Then it replaces the “This message was deleted ” text with its previous contents. Once the message gets restored you can even quote it in a reply. Using this on non deleted messages only edits the message for you. Sadly, the code from the extension is obfuscated and difficult to read.via the TL;DR App

A while back I was playing around with a chrome extension that allows you to restore deleted messages on WhatsApp web.
How it does that is:
  • Stores all messages it receives locally.
  • When a message gets deleted, it adds the previously known message contents to a deleted messages array.
  • Then it replaces the “This message was deleted ” text with its previous contents.
Once the message gets restored you can even quote it in a reply.
While sending the reply message to WhatsApp, along with your message, you are also expected to send all the data of the message that you are quoting, this is what I make use of.
Now before sending the reply I can edit the contents of the deleted message to be whatever I want.
Since the message is deleted, WhatsApp doesn’t check if the data that I sent is valid or not and forwards the same data to everyone else.
Using this on non deleted messages only edits the message for you.

How would this be useful

Just imagine the things you can make your friends (or enemies) say!
Honestly,I cannot find a better use for this other than using it as a topic for my first blog post.

Try It Yourself

  • Open WhatsApp Web.
  • Press
    Control+Shift+J
    to open up the console for Google Chrome.
  • Paste the code from the gist into the console (After reading it, and making sure that it won’t make you order 100 toasters from amazon).
    Here is the link to the Gist on GitHub which has all the required helper functions.
  • Then open up a chat and Ctrl - Click on the area beside the deleted message.
  • Fill out the message prompts to write your own reply message, and the Quoted message.
The helper functions are taken directly from the Chrome extension WA Web Plus. They expose the underlying WhatsApp web’s java-script function to allow us to use them in our script. Sadly, the code from the extension is obfuscated and difficult to read.
Read the contents of
function ayo(x)
to understand the workings of getting the message id, editing the message, and sending it.
function ayo(x) {
    if (x.target === x.currentTarget) {
        d = this;
        // gets the id of the selected message and stores it in variable c
        for (i in d) i.startsWith("__reactInternalInstance$") && (c = d[i]["return"]["return"].key);
        var b = $(this);
        if (x.ctrlKey) {
            a = prompt("Enter Your Reply", "Reply text");
            var text = prompt("Enter the Quoted Text", "deleted message text");
            c = void 0 !== c ? c.replace("msg-", "") : "";
            b && (b = window.f.Chat.where({
                __x_active: !0
            }), c = window.f.Msg.get(c), b[0].sendMessage = b[0].sendMessage ? b[0].sendMessage : function () {
                return window.f.sendMessage.apply(this,
                    arguments)
            }, void 0 !== c && ((c.__x_type = "chat", c.__x_body = text, c.__x_text = text), c.__x_isRevoked = !1), b[0].sendMessage(a, {
                quotedMsg: c
            }));
            return !1
        }
    }
}

$(document).on("click", ".message-in", ayo)
You can do a lot more fun stuff with the WhatsApp Web’s java-script functions, like automatic replies to messages, making self destructing messages, adding quick replies, etc.
Hope that you have fun with this, this is my first Article so help me out if I've made any mistakes.

Written by zer0k | Computer engineering student that likes to learn stuff.
Published by HackerNoon on 2020/02/24