Archiving Facebook Messages and Facebook Marketplace Messages

Too many Facebook Messages

I had a ton of Facebook Marketplace messages that I was annoyed with and wanted archived. So I found many resources online on using the Chrome console to run javascript to archive the messages.

Javascript Gist and More

I found a gist with the needed code, but it didn’t work. Upon reading the comments, there was updated code buried and another Github repository.

Archive all of the messages in your Facebook Messages Inbox · GitHub
Archive all of the messages in your Facebook Messages Inbox – archive-all-facebook-messages.js
gist.github.com

My modified code

I took the original code and modified it with ChatGTP. I had it limit the number of times the script would run, essentially, how many messages it would archive. I also added a delay, to make sure I didn’t get blocked by Facebook.

let executionCount = 0;

function run() {
  if (executionCount >= 100) {
    return;
  }
  
  let all = document.querySelectorAll('div[aria-label="Menu"]');
  if (all.length == 0) return;
  
  let a = all[1];
  a.click();
  
  let menuitems = document.querySelectorAll('div[role=menuitem]');
  let archiveChatRegex = /Archive chat/;
  
  for (let i = 0; i < menuitems.length; i++) {
    if (archiveChatRegex.test(menuitems[i].innerText)) {
      menuitems[i].click();
    }
  }
  
  executionCount++;
  setTimeout(run, 200); // Delay of 1 second (1000 milliseconds)
}

run();

MikroTik Scripts

Setup SSH Key Login on Mikrotik

Created File and Place SSH Key Contents

Shell

Set SSH Key for Users

Shell

Setup Email Sending on Mikrotik via Postmark

Shell

Send a Test Email from Mikrotik

Shell

Backup Mikrotik Config and Email – Example 1

Shell

Backup Mikrotik Config and Email – Example 2

Shell