Skip to content

Instantly share code, notes, and snippets.

@nns2009
Created June 25, 2025 12:52
Show Gist options
  • Select an option

  • Save nns2009/b35e28f5b49626989290238964526def to your computer and use it in GitHub Desktop.

Select an option

Save nns2009/b35e28f5b49626989290238964526def to your computer and use it in GitHub Desktop.
Facebook: Expand all "View ..." comments
// 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