Last active
June 14, 2021 03:17
-
-
Save gual/1ee53af2588e84d29405b4ac7f90684c to your computer and use it in GitHub Desktop.
To export whatsapp chat history (text only)
This file contains 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
// This needs to be run on the browser console with the corresponding chat selected | |
// on Whatsapp Web. It also needs to have the whole conversation loaded. | |
// It copies the conversation to the clipboard, change it as needed. | |
conversation = ''; | |
msgElements = document.querySelectorAll('div.copyable-text:not(._2_1wd)'); | |
for (let msgElement of msgElements) { | |
sender = msgElement.dataset.prePlainText; | |
try { | |
message = msgElement.querySelector('._3-8er.selectable-text.copyable-text span').innerText; | |
completeMsg = sender + message; | |
conversation += '\n' + completeMsg; | |
} catch (error) { | |
continue; | |
} | |
}; | |
navigator.clipboard.writeText(conversation).then(function() { | |
console.log('success'); | |
}, function(err) { | |
console.log('fail', err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment