Created
June 20, 2025 00:27
-
-
Save wilcollins/de8d1c8d12ad527bd2c096edc2b13358 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
| /** | |
| Go to: https://m.facebook.com/pages/launchpoint/liked_pages | |
| Zoom out a few times to load more items at once. | |
| Paste the following script into console (F12 -> console): | |
| **/ | |
| (async function unlikePages() { | |
| const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | |
| const processedElements = new Set(); // Track processed elements by their HTML representation | |
| while (true) { | |
| // Get all "More options" buttons | |
| const moreOptionsButtons = Array.from(document.querySelectorAll('[aria-label="More options"]')); | |
| if (moreOptionsButtons.length === 0) { | |
| console.log("No more items to process. Exiting..."); | |
| break; | |
| } | |
| for (const button of moreOptionsButtons) { | |
| try { | |
| // Use the button's outerHTML to deduplicate | |
| const buttonHTML = button.parentElement.parentElement.innerHTML.trim(); | |
| if (processedElements.has(buttonHTML)) { | |
| console.log("Skipping already processed button:", buttonHTML); | |
| continue; | |
| } | |
| // Click the "More options" button | |
| button.click(); | |
| processedElements.add(buttonHTML); // Mark as processed using its HTML | |
| await delay(1000); // Wait for the menu to open | |
| // Find the "Unlike" menu item | |
| const unlikeButton = document.querySelector('[aria-label*="Menu with options to manage this activity"]'); | |
| if (unlikeButton) { | |
| unlikeButton.querySelector('[role="menuitem"]').click(); | |
| console.log("Unliked an item."); | |
| break; // Exit the loop after processing one item so we can reevaluate the page | |
| } else { | |
| console.log("No 'Unlike' option found for this item."); | |
| } | |
| } catch (error) { | |
| console.error("Error processing an item:", error); | |
| } | |
| } | |
| // Wait a moment and reevaluate the page for new items | |
| await delay(1500); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment