Last active
September 27, 2025 12:13
-
-
Save letelete/fefaaf796c4684f3182e5d9eb15277f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (() => { | |
| const TIME_TO_FEED_MODAL = 1000; | |
| const TIME_TO_CONFIRM_MODAL = 500; | |
| const TIME_TO_REMOVE_NEXT = TIME_TO_FEED_MODAL + TIME_TO_CONFIRM_MODAL + 500; | |
| let queue = []; | |
| let deleteCount = 0; | |
| function run() { | |
| setTimeout(() => { | |
| if (queue.length <= 1 && deleteCount > 0) { | |
| window.scrollTo(0, document.body.scrollHeight); | |
| } | |
| queue = []; | |
| document | |
| .querySelectorAll('[aria-label="Actions for this post"]') | |
| .forEach((e) => queue.push(e)); | |
| console.log("run:queue", queue.length); | |
| removePost(queue.shift()); | |
| console.log("Deleted posts:", deleteCount); | |
| requestAnimationFrame(run); | |
| }, TIME_TO_REMOVE_NEXT); | |
| } | |
| function removePost(menu) { | |
| let timeout = 50; | |
| try { | |
| menu.click(); | |
| setTimeout(clickRemoveInModal, TIME_TO_FEED_MODAL); | |
| timeout = TIME_TO_REMOVE_NEXT; | |
| } catch (error) { | |
| console.log("Error removing post", error, e); | |
| } | |
| } | |
| function clickRemoveInModal() { | |
| const modal = document.querySelector('[aria-label="Feed story"]'); | |
| const item = [...modal.querySelectorAll('[role="menuitem"]')].filter((e) => | |
| ["Remove post", "Delete", "Delete post"].includes(e.textContent) | |
| )[0]; | |
| console.log(" clickRemoveInModal:item", item); | |
| item.click(); | |
| setTimeout(findConfirmModalAndConfirm, TIME_TO_CONFIRM_MODAL); | |
| } | |
| function findConfirmModalAndConfirm() { | |
| const confirm = [ | |
| document.querySelector('[aria-label="Confirm"]'), | |
| document.querySelector('[aria-label="Delete"]'), | |
| ].filter(Boolean)[0]; | |
| console.log(" findConfirmModalAndConfirm:confirm", confirm); | |
| confirm.click(); | |
| deleteCount++; | |
| } | |
| run(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment