KnugiHK / WhatsApp-Chat-Exporter

A customizable Android and iOS/iPadOS WhatsApp database parser that will give you the history of your WhatsApp conversations in HTML and JSON. Android Backup Crypt12, Crypt14, Crypt15, and new schema supported.
https://wts.knugi.dev/
MIT License
586 stars 85 forks source link

See only media (photos, videos, gif, audio etc.) in the html and no text conversations #33

Closed gsriram88 closed 1 year ago

gsriram88 commented 1 year ago

Hi there,

Is there a way to quickly process the resultant html so that all the normal conversation text is removed, and only the media (such as photos, videos, gif, audio etc.) alone is present? I basically want something like the "Media, links, and docs" feature of the original WhatsApp app where one can quickly scroll up and down the media alone.

I no longer have the decrypted DB handy, so I am looking for a way to post process your result html and strip away the text and keep only the media. Is there a quick way/hack to do this?

WhatsApp failed to restore my DB and this tool has been great at retrieving my memories in a coherent way! Thanks a lot for your work!

KnugiHK commented 1 year ago

As there is no attribute to tell if there are any media, I quickly created a JavaScript code to remove any rows that do not have the following tags: img, audio, video.

const elems = [...document.getElementsByClassName("table")[0].children]
elems.forEach((elem) => {
    if (elem.getElementsByClassName("w3-center").length <= 0) {
        search = elem.querySelector(".w3-col.m10.l10");
        if (search.querySelectorAll("img,audio,video").length <= 0){
            elem.remove();
        };
    }
});

After executing the above code in the console, you may save the page into a single file with an extension or convert the above code to some program to remove the unwanted rows for you.

Note that the code will not remove all text-only messages to preserve the conversation date.

gsriram88 commented 1 year ago

Exactly what I was looking for! Works beautifully! Thanks so much!