Skip to content

Instantly share code, notes, and snippets.

@karbassi
Last active October 3, 2024 09:09
Show Gist options
  • Save karbassi/d7499bf9da6407fde1ff45dcde582a12 to your computer and use it in GitHub Desktop.
Save karbassi/d7499bf9da6407fde1ff45dcde582a12 to your computer and use it in GitHub Desktop.
Archive all messages in Google Messages web app

Archive all messages in Google Messages web app

This code was something I quickly put together to archive over 5000 text messages in Google Messages. I have no idea if Google frowns on this or not, but it's basically the same as if a human sat there and archived all the messages by hand.

Tested and working as of Monday, November 4, 2019.

How to run

  1. Sign into https://messages.google.com/web/
  2. Open Chrome Developers console by going to View > Developer > JavaScript Console.
  3. Copy and paste the code below into console. It should automatically run.

Warning

Don't run any code before you know what it does. Review it and make sure it's safe. I accept no fault if something goes wrong. Google may change their code at anytime and this code may not work. I provide no support.

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function archive() {
let menu = document.querySelectorAll('button.menu-button');
console.log(menu.length);
if(menu.length) {
menu[0].click();
document.querySelectorAll('button.mat-mdc-menu-item')[0].click()
await sleep(1000);
archive();
}
}
archive();
@thesterns
Copy link

works great. thanks!

@LeonC510
Copy link

This works great for me!!! Thank you so much; this is exactly what I needed. I had hundreds of conversations in Google messages after migrating from my old phone, and this code helped me put the useless conversations away fast.
Tip: If you could only archive 25 conversations unexpectedly, refresh the webpage and rerun the code. The problem is that the Google Messages web end only loads 25 conversations by default.

@geek111
Copy link

geek111 commented Oct 3, 2024

There is possible add checkbox messeges who i want archive one click? but only this what have checked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment