Last active
November 3, 2023 07:08
-
-
Save yzraeu/5a427489ee9eb35efeb26700586ac787 to your computer and use it in GitHub Desktop.
WhatsApp Senders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Caveats | |
| // #1 - This is reading the DOM, not the storage, so only visible messages are accounted - YES, you need to scroll up to get more data | |
| // DONE | |
| // #2 - Still didn't get the message content, really wanted that for the chars / hour ranking | |
| // Impossible, encrypted | |
| // #3 - I stripped out the the date time, but that could be useful to actually compile amount of messages / hour | |
| // the message store doesn't seem to have the datetime, or maybe the princess is in another castle. Would need to check the other tables | |
| // found on message-info, still need to merge in the data | |
| // #4 - There's probably a way to retrieve the names instead of phone numbers | |
| // maybe encrypted as well, need to check | |
| var chatName = "MyGroupName"; // case sensitive | |
| var debug = true; | |
| var request = indexedDB.open("model-storage"); | |
| request.onsuccess = function (event) { | |
| var db = event.target.result; | |
| var transaction = db.transaction(["chat", "message","message-info"], "readonly"); | |
| var chatStore = transaction.objectStore("chat"); // all groups | |
| var messageStore = transaction.objectStore("message"); // all the messages | |
| // var messageInfoStore = transaction.objectStore("message-info"); // message info - timestamp | |
| var chatRequest = chatStore.getAll(); | |
| chatRequest.onsuccess = function (event) { | |
| var result = event.target.result; | |
| var validGroups = result.filter(g => g?.name !== undefined); | |
| if(debug) console.dir(validGroups.map(g => g?.name)) | |
| var chat = validGroups.filter(g => g?.name?.indexOf(chatName) >= 0)[0]; | |
| if(debug) console.dir(chat) | |
| var messageRequest = messageStore.getAll(); | |
| messageRequest.onsuccess = function (messageEvent) { | |
| var messageResult = messageEvent.target.result; | |
| var senders = messageResult.filter(m => m.internalId.indexOf(chat.id) >= 0).map(m => m?.author?.user) | |
| console.dir(senders.length) | |
| var counterTable = {}; | |
| for (var i = 0; i < senders.length; i++) { | |
| var k = senders[i]; | |
| counterTable[k] = counterTable[k] === undefined ? 1 : counterTable[k]+1; | |
| } | |
| console.table(counterTable); | |
| }; | |
| }; | |
| db.close(); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment