Skip to content

Instantly share code, notes, and snippets.

@akmandev
Created June 22, 2019 23:37
Show Gist options
  • Save akmandev/1a4dc147faf3ba7acb6dbfd868fdb334 to your computer and use it in GitHub Desktop.
Save akmandev/1a4dc147faf3ba7acb6dbfd868fdb334 to your computer and use it in GitHub Desktop.
/**
* Originally created by: https://github.com/mdunham/delete-fb-messages
* Edited for the latest UI changes by Ozan Akman
*/
(function($){
var
stepOne = function(){
if (null !== $('div[aria-label="Conversation actions"]')) {
$('div[aria-label="Conversation actions"]').click();
setTimeout(stepTwo, 200);
} else {
console.log('There are no messages to delete');
}
},
stepTwo = function(){
var elements = document.evaluate('//span[text()="Delete"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < elements.snapshotLength; i++) {
elements.snapshotItem(i).click();
}
setTimeout(stepThree, 200);
},
stepThree = function(){
var elements = document.evaluate('//button[text()="Delete"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < elements.snapshotLength; i++) {
elements.snapshotItem(i).click();
}
if (null !== $('div[aria-label="Conversation actions"]')) {
setTimeout(stepOne, 600);
} else {
console.log('No more messages to delete');
}
};
stepOne();
})(function(sel){ return document.querySelector(sel); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment