Skip to content

Instantly share code, notes, and snippets.

@andysdesigns
Forked from bitmvr/fbMessageDeletr.js
Created August 26, 2021 19:49
Show Gist options
  • Select an option

  • Save andysdesigns/1a2002e3265e663004bff404bc546707 to your computer and use it in GitHub Desktop.

Select an option

Save andysdesigns/1a2002e3265e663004bff404bc546707 to your computer and use it in GitHub Desktop.
Facebook Message Deleter
javascript: (function () {
const log = function (msg) {
const d = new Date();
const n = d.toISOString();
console.log(`${n} - ${msg}`);
};
const clickMenu = function() {
document
.querySelector('[aria-label="Conversation actions"]')
.click();
log('Opening the dropdown menu');
};
const clickDeleteFromMenu = function () {
document
.getElementsByClassName('uiContextualLayer')[0]
.getElementsByTagName('ul')[0]
.getElementsByClassName('__MenuItem')[3]
.click();
log('Clicking Delete');
};
const clickDeleteButton = function () {
document
.querySelector('[aria-label="Dialog content"]')
.getElementsByTagName('button')[1]
.click();
log('Confirming Delete');
};
const deleteFacebookMessages = function() {
setTimeout(clickMenu, 500);
setTimeout(clickDeleteFromMenu, 800);
setTimeout(clickDeleteButton, 1000);
};
const messageExist = function () {
return document.querySelector('[aria-label="Conversation List"] li [role="gridcell"]');
};
const run = function () {
if ( messageExist !== null || messageExist !== undefined ){
deleteFacebookMessages();
}
};
run();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment