Created
February 15, 2026 08:10
-
-
Save bhuiyanmobasshir94/1b4ac4b659b93d4f5fe856f245a19147 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
| // Delete 30 Facebook posts - Updated with proper confirmation | |
| (async function deleteFBPosts() { | |
| const POSTS_TO_DELETE = 30; | |
| const CLICK_DELAY = 1500; | |
| const MENU_DELAY = 2000; | |
| const SCROLL_DELAY = 2000; | |
| let deletedCount = 0; | |
| let failedAttempts = 0; | |
| console.log(`๐ Starting deletion of ${POSTS_TO_DELETE} posts...`); | |
| function sleep(ms) { | |
| return new Promise(resolve => setTimeout(resolve, ms)); | |
| } | |
| async function scrollToLoadMore() { | |
| window.scrollTo(0, document.body.scrollHeight); | |
| await sleep(SCROLL_DELAY); | |
| window.scrollTo(0, 0); | |
| await sleep(SCROLL_DELAY); | |
| } | |
| async function deletePost() { | |
| try { | |
| // Find the action menu button using the exact aria-label | |
| const actionButton = document.querySelector('[aria-label="Actions for this post"]'); | |
| if (!actionButton) { | |
| console.log('โ No action button found'); | |
| return false; | |
| } | |
| console.log('โ Found action button, clicking...'); | |
| actionButton.click(); | |
| await sleep(MENU_DELAY); | |
| // Find the menu items - look for delete/trash option | |
| const menuItems = Array.from(document.querySelectorAll('[role="menuitem"]')); | |
| console.log(`Found ${menuItems.length} menu items`); | |
| // Look for delete option (try different text variations) | |
| const deleteItem = menuItems.find(item => { | |
| const text = item.textContent.toLowerCase(); | |
| return text.includes('move to trash') || | |
| text.includes('delete') || | |
| text.includes('trash') || | |
| text.includes('เฆฎเงเฆเง เฆซเงเฆฒเงเฆจ'); // Bengali | |
| }); | |
| if (!deleteItem) { | |
| console.log('โ Delete option not found. Available options:'); | |
| menuItems.forEach((item, i) => { | |
| console.log(` ${i}: ${item.textContent.substring(0, 50)}`); | |
| }); | |
| // Close menu | |
| document.body.click(); | |
| await sleep(500); | |
| return false; | |
| } | |
| console.log('โ Found delete option, clicking...'); | |
| deleteItem.click(); | |
| await sleep(MENU_DELAY); | |
| // Find and click confirmation button - Updated to look for "Move" button | |
| console.log('Looking for confirmation button...'); | |
| // First try to find by aria-label | |
| let confirmButton = document.querySelector('[aria-label="Move"][role="button"]'); | |
| // If not found, try finding by text content | |
| if (!confirmButton) { | |
| const allButtons = Array.from(document.querySelectorAll('[role="button"]')); | |
| confirmButton = allButtons.find(btn => { | |
| const text = btn.textContent.trim(); | |
| const ariaLabel = btn.getAttribute('aria-label'); | |
| const isVisible = btn.offsetParent !== null; | |
| // Look for "Move" button (not "Cancel") | |
| const isMove = (text === 'Move' || ariaLabel === 'Move') && | |
| !text.includes('Cancel') && | |
| !ariaLabel?.includes('Cancel'); | |
| return isVisible && isMove; | |
| }); | |
| } | |
| if (!confirmButton) { | |
| console.log('โ Move/Confirm button not found'); | |
| console.log('Available buttons:'); | |
| document.querySelectorAll('[role="button"]').forEach((btn, i) => { | |
| if (btn.offsetParent !== null) { | |
| console.log(` ${i}: aria-label="${btn.getAttribute('aria-label')}", text="${btn.textContent.substring(0, 30)}"`); | |
| } | |
| }); | |
| return false; | |
| } | |
| console.log('โ Confirming deletion (clicking Move button)...'); | |
| confirmButton.click(); | |
| await sleep(CLICK_DELAY); | |
| return true; | |
| } catch (error) { | |
| console.error('โ Error:', error.message); | |
| return false; | |
| } | |
| } | |
| // Main loop | |
| while (deletedCount < POSTS_TO_DELETE) { | |
| console.log(`\nโโโ Attempt ${deletedCount + 1}/${POSTS_TO_DELETE} โโโ`); | |
| const success = await deletePost(); | |
| if (success) { | |
| deletedCount++; | |
| failedAttempts = 0; | |
| console.log(`โ Progress: ${deletedCount}/${POSTS_TO_DELETE} deleted`); | |
| } else { | |
| failedAttempts++; | |
| console.log(`โ ๏ธ Failed attempt #${failedAttempts}`); | |
| if (failedAttempts >= 3) { | |
| console.log('๐ Multiple failures, scrolling to load more posts...'); | |
| await scrollToLoadMore(); | |
| failedAttempts = 0; | |
| } | |
| } | |
| // Scroll every 5 successful deletions | |
| if (deletedCount > 0 && deletedCount % 5 === 0) { | |
| console.log('๐ Loading more posts...'); | |
| await scrollToLoadMore(); | |
| } | |
| await sleep(CLICK_DELAY); | |
| } | |
| console.log(`\n๐ COMPLETED! Successfully deleted ${deletedCount} posts!`); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment