From 8d6f77ce37cca70a661308437e9addc00b9428bc Mon Sep 17 00:00:00 2001 From: Gabin Date: Tue, 20 May 2025 14:09:24 +0200 Subject: [PATCH 1/5] Update Facebook-Delete-ActivityLog-SearchHistory.js --- Facebook-Delete-ActivityLog-SearchHistory.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Facebook-Delete-ActivityLog-SearchHistory.js b/Facebook-Delete-ActivityLog-SearchHistory.js index 852bea1..2e10478 100644 --- a/Facebook-Delete-ActivityLog-SearchHistory.js +++ b/Facebook-Delete-ActivityLog-SearchHistory.js @@ -12,7 +12,7 @@ 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") { + if (opt.innerText === "Move to trash" || opt.innerText === "Delete" || opt.innerText === "Remove reaction" || opt.innerText === "Unlike") { var ariaLabel = opt.innerText === "Move to trash" ? "Move to Trash" : "Delete"; canDelete = true; opt.click(); @@ -39,4 +39,4 @@ function deleteFacebookActivityLog_SearchHistory(index = 0) { } } -deleteFacebookActivityLog_SearchHistory(); \ No newline at end of file +deleteFacebookActivityLog_SearchHistory(); From 84bc18d316f798a045a7f944cb7e17deeac04353 Mon Sep 17 00:00:00 2001 From: LittleBangTheory Date: Tue, 20 May 2025 14:22:05 +0200 Subject: [PATCH 2/5] Refactor deleteFacebookActivityLog_SearchHistory function to use an array for innerText values --- Facebook-Delete-ActivityLog-SearchHistory.js | 37 ++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/Facebook-Delete-ActivityLog-SearchHistory.js b/Facebook-Delete-ActivityLog-SearchHistory.js index 2e10478..9027a56 100644 --- a/Facebook-Delete-ActivityLog-SearchHistory.js +++ b/Facebook-Delete-ActivityLog-SearchHistory.js @@ -1,4 +1,12 @@ function deleteFacebookActivityLog_SearchHistory(index = 0) { + // Var to store the different values for innerText + var innerTextValues = [ + "Move to trash", + "Delete", + "Remove reaction", + "Unlike", + ] + var items = document.querySelectorAll('[aria-label="Action options"] > i'); var item = items[index] @@ -12,21 +20,22 @@ 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" || opt.innerText === "Remove reaction" || opt.innerText === "Unlike") { - 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 delete + if (innerTextValues.includes(opt.innerText)) { + var ariaLabel = opt.innerText === "Move to trash" ? "Move to Trash" : "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(() => { + deleteFacebookActivityLog_SearchHistory(index); + console.log("Activity deleted"); + }, 2000); + }, 250); + break; } } if (!canDelete) { From f0498259e7eae71a5f213deb89533685b22a47b9 Mon Sep 17 00:00:00 2001 From: LittleBangTheory Date: Tue, 20 May 2025 15:00:52 +0200 Subject: [PATCH 3/5] Add attempt tracking and skip logic to deleteFacebookActivityLog_SearchHistory function --- Facebook-Delete-ActivityLog-SearchHistory.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Facebook-Delete-ActivityLog-SearchHistory.js b/Facebook-Delete-ActivityLog-SearchHistory.js index 9027a56..844e3fc 100644 --- a/Facebook-Delete-ActivityLog-SearchHistory.js +++ b/Facebook-Delete-ActivityLog-SearchHistory.js @@ -1,3 +1,5 @@ +const attemptCounts = {}; // Track attempts per index + function deleteFacebookActivityLog_SearchHistory(index = 0) { // Var to store the different values for innerText var innerTextValues = [ @@ -7,6 +9,16 @@ function deleteFacebookActivityLog_SearchHistory(index = 0) { "Unlike", ] + // Increment attempt count for this index + attemptCounts[index] = (attemptCounts[index] || 0) + 1; + + // If tried more than twice, skip to next + if (attemptCounts[index] > 2) { + console.log(`Skipping index ${index} after 2 failed attempts.`); + deleteFacebookActivityLog_SearchHistory(index + 1); + return; + } + var items = document.querySelectorAll('[aria-label="Action options"] > i'); var item = items[index] @@ -20,7 +32,7 @@ function deleteFacebookActivityLog_SearchHistory(index = 0) { var canDelete = false for (let i=0; i < opts.length; i += 1) { var opt = opts[i]; - // If the innerText is one of the values in the array, then we can delete + // If the innerText is one of the values in the array, then we can deletefaczb if (innerTextValues.includes(opt.innerText)) { var ariaLabel = opt.innerText === "Move to trash" ? "Move to Trash" : "Delete"; canDelete = true; From 799c161b96193d1ddffb09dfe599ec8a6a011be2 Mon Sep 17 00:00:00 2001 From: LittleBangTheory Date: Tue, 20 May 2025 15:13:03 +0200 Subject: [PATCH 4/5] Refactor deleteFacebookActivityLog_SearchHistory function to track attempts using parameters and improve retry logic --- Facebook-Delete-ActivityLog-SearchHistory.js | 40 +++++++++++++------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Facebook-Delete-ActivityLog-SearchHistory.js b/Facebook-Delete-ActivityLog-SearchHistory.js index 844e3fc..8628203 100644 --- a/Facebook-Delete-ActivityLog-SearchHistory.js +++ b/Facebook-Delete-ActivityLog-SearchHistory.js @@ -1,28 +1,27 @@ -const attemptCounts = {}; // Track attempts per index - -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", ] - // Increment attempt count for this index - attemptCounts[index] = (attemptCounts[index] || 0) + 1; + // Increment attempt count + currentAttempt++; - // If tried more than twice, skip to next - if (attemptCounts[index] > 2) { - console.log(`Skipping index ${index} after 2 failed attempts.`); - deleteFacebookActivityLog_SearchHistory(index + 1); - return; + // 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(); @@ -43,8 +42,23 @@ function deleteFacebookActivityLog_SearchHistory(index = 0) { confirm.click(); } setTimeout(() => { - deleteFacebookActivityLog_SearchHistory(index); - console.log("Activity deleted"); + // 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; @@ -52,7 +66,7 @@ function deleteFacebookActivityLog_SearchHistory(index = 0) { } if (!canDelete) { setTimeout(() => { - deleteFacebookActivityLog_SearchHistory(index + 1); + deleteFacebookActivityLog_SearchHistory(index + 1, 0); console.log("Nothing to do"); }, 250); } From 86c6a10e1ba925dd5f03abd91fc8c9b284657255 Mon Sep 17 00:00:00 2001 From: LittleBangTheory Date: Wed, 21 May 2025 10:03:22 +0200 Subject: [PATCH 5/5] Add "Move to bin" option and refine ariaLabel assignment logic in deleteFacebookActivityLog_SearchHistory function --- Facebook-Delete-ActivityLog-SearchHistory.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Facebook-Delete-ActivityLog-SearchHistory.js b/Facebook-Delete-ActivityLog-SearchHistory.js index 8628203..6b26d2b 100644 --- a/Facebook-Delete-ActivityLog-SearchHistory.js +++ b/Facebook-Delete-ActivityLog-SearchHistory.js @@ -6,6 +6,7 @@ function deleteFacebookActivityLog_SearchHistory(index = 0, currentAttempt = 0) "Remove reaction", "Unlike", "Delete Your Activity", + "Move to bin", ] // Increment attempt count @@ -33,7 +34,17 @@ function deleteFacebookActivityLog_SearchHistory(index = 0, currentAttempt = 0) var opt = opts[i]; // If the innerText is one of the values in the array, then we can deletefaczb if (innerTextValues.includes(opt.innerText)) { - var ariaLabel = opt.innerText === "Move to trash" ? "Move to Trash" : "Delete"; + 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(() => {