Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 62 additions & 16 deletions Facebook-Delete-ActivityLog-SearchHistory.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
function deleteFacebookActivityLog_SearchHistory(index = 0) {
function deleteFacebookActivityLog_SearchHistory(index = 0, currentAttempt = 0) {
// Var to store the different values for innerText
var innerTextValues = [
"Move to trash",
"Delete",
"Remove reaction",
"Unlike",
"Delete Your Activity",
"Move to bin",
]

// Increment attempt count
currentAttempt++;

// If tried more than two times, go to the next item
if (currentAttempt > 2) {
console.log("Tried too many times, going to next item");
return deleteFacebookActivityLog_SearchHistory(index + 1, 0);
}

var items = document.querySelectorAll('[aria-label="Action options"] > i');
var item = items[index]

if (item) {
var logIdentifier = item.parentNode.parentNode.parentNode.innerText.trim();
console.log("ACTIVITY-LOG => ", item.parentNode.parentNode.parentNode.innerText);

item.scrollIntoView();
Expand All @@ -12,31 +32,57 @@ function deleteFacebookActivityLog_SearchHistory(index = 0) {
var canDelete = false
for (let i=0; i < opts.length; i += 1) {
var opt = opts[i];
if (opt.innerText === "Move to trash" || opt.innerText === "Delete") {
var ariaLabel = opt.innerText === "Move to trash" ? "Move to Trash" : "Delete";
canDelete = true;
opt.click();
setTimeout(() => {
var confirm = document.querySelector(`[aria-label="${ariaLabel}"][tabindex="0"]`);
if (confirm) {
confirm.click();
// If the innerText is one of the values in the array, then we can deletefaczb
if (innerTextValues.includes(opt.innerText)) {
let ariaLabel;
// If innerText is "Move to trash", set ariaLabel to "Move to trash" (for history logs)
if (opt.innerText === "Move to trash") {
ariaLabel = opt.innerText;
// If innerText is "Move to bin", then ariaLabel should be "Move to Recycle bin" (FB UI...) (for posts logs)
} else if (opt.innerText === "Move to bin") {
ariaLabel = "Move to Recycle bin";
// Otherwise, set ariaLabel to "Delete" (default for all other logs)
} else {
ariaLabel = "Delete";
}
canDelete = true;
opt.click();
setTimeout(() => {
deleteFacebookActivityLog_SearchHistory(index);
console.log("Activity deleted");
}, 2000);
}, 250);
break;
var confirm = document.querySelector(`[aria-label="${ariaLabel}"][tabindex="0"]`);
if (confirm) {
confirm.click();
}
setTimeout(() => {
// After deletion attempt, check if the same log line is still present at the same index
var newItems = document.querySelectorAll('[aria-label="Action options"] > i');
var newItem = newItems[index];
var stillSame = false;
if (newItem) {
var newIdentifier = newItem.parentNode.parentNode.parentNode.innerText.trim();
stillSame = (newIdentifier === logIdentifier);
}
if (stillSame) {
// Deletion failed, try again
console.log("Deletion failed, retrying...");
deleteFacebookActivityLog_SearchHistory(index, currentAttempt);
} else {
// Deletion succeeded, move to next
console.log("Activity deleted");
deleteFacebookActivityLog_SearchHistory(index, 0);
}
}, 2000);
}, 250);
break;
}
}
if (!canDelete) {
setTimeout(() => {
deleteFacebookActivityLog_SearchHistory(index + 1);
deleteFacebookActivityLog_SearchHistory(index + 1, 0);
console.log("Nothing to do");
}, 250);
}
}, 250);
}
}

deleteFacebookActivityLog_SearchHistory();
deleteFacebookActivityLog_SearchHistory();