Created
June 25, 2025 12:52
-
-
Save nns2009/b35e28f5b49626989290238964526def to your computer and use it in GitHub Desktop.
Facebook: Expand all "View ..." comments
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
| // This script slowly but surely expands all comments of a Facebook post | |
| // (pretty annoying Facebook doesn't have this feature with a single click) | |
| // Manually select "All comments" before launching in the console | |
| // The class selector will likely change | |
| // I might update it with a more robust version someday | |
| // Note that even this class selector is somehow not enough, so extra textContent filtering is used | |
| let sleep = s => new Promise((resolve, _) => setTimeout(resolve, s * 1000)); | |
| let random = (min, max) => min + Math.random() * (max - min); | |
| async function openOne() { | |
| let $viewAll = document.querySelectorAll('.x193iq5w.xeuugli.x13faqbe.x1vvkbs.x1xmvt09.x1lliihq.x1s928wv.xhkezso.x1gmr53x.x1cpjm7i.x1fgarty.x1943h6x.xudqn12.x3x7a5m.x6prxxf.xvq8zen.x1s688f.xi81zsa'); | |
| $viewAll = [...$viewAll].filter(n => n.textContent.toLowerCase().startsWith('view')); | |
| if ($viewAll.length === 0) | |
| return false; | |
| $viewAll[0].scrollIntoViewIfNeeded(); | |
| await sleep(random(1, 2.4)); | |
| $viewAll[0].click(); | |
| return true; | |
| } | |
| while (await openOne()) | |
| await sleep(random(7, 12)); | |
| console.info('----- Done -----'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment