Skip to content

Instantly share code, notes, and snippets.

@eldridgea
Last active September 21, 2024 22:48
Show Gist options
  • Save eldridgea/629b19962b6f8eff0a299c8b6e4f3e35 to your computer and use it in GitHub Desktop.
Save eldridgea/629b19962b6f8eff0a299c8b6e4f3e35 to your computer and use it in GitHub Desktop.

This is a Greasemonkey script to archive all messages in the web view for Google Messages.

To use:

  1. Install Firefox if needed
  2. In Firefox, go to the Google Messages web interface and pair with your phone if not already paired
  3. Close all Google Messages tabs in Firefox
  4. Install the Grasemoneky extension
  5. Click the Greasemonkey icon in the toolbar > New User Script
  6. Delete anything in there and paste the below archiveAllGoogleMessages.js contents
  7. Click the save icon or `Ctrl + S
  8. Open the Google Messages web interface in Firefox
  9. After the page loads it should archive all messages on the page, reload the page when done, and repeat indefinetly
  10. When the messages are all archived either uninstall this script or uninstall Grasemoneky completely
// ==UserScript==
// @name Google Messages Archive All
// @version 1
// @grant none
// @include https://messages.google.com/*
// ==/UserScript==
//
// This is a script used with Grasemonkey and the web version of Google Messages to archive
// all messages in the inbox.
async function archiveAllMessages() {
console.log('Sleeping 5 seconds to allow page loading...');
await sleep(5000); // Wait for 5 seconds
archive();
}
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();
} else {
location.reload();
}
}
archiveAllMessages();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment