Last active
September 23, 2020 06:32
-
-
Save acropup/5a859183229443d463b7ce11240a6931 to your computer and use it in GitHub Desktop.
Google Messages for Web (https://messages.google.com/web) script to save an entire conversation history in simple text form. MMS messages such as images are not saved.
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
// Chat conversation backup for https://messages.google.com/web | |
// To use, start by choosing a conversation, and scroll to the top until all previous chats have been loaded. | |
// Then copy and paste this script into the Chrome Developer Console (Ctrl+Shift+J), hit Enter, and copy the | |
// value of 'result' and paste it wherever you would like to save the chat history. | |
var result = Array.from(document.querySelectorAll("mws-relative-timestamp, mws-text-message-part")).map((item) => { | |
switch (item.nodeName) { | |
case "MWS-TEXT-MESSAGE-PART": | |
// Extract the sender's name from aria-label, which starts as '[Person] said:' | |
var aria = item.getAttribute("aria-label"); | |
var idx = aria.indexOf("said: ") + 6; | |
return aria.substr(0, idx) + item.innerText; | |
break; | |
case "MWS-RELATIVE-TIMESTAMP": | |
return item.innerText; | |
break; | |
} | |
}); | |
result.join("\n\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment