Skip to content

Instantly share code, notes, and snippets.

@rzymek
Last active January 2, 2024 09:14
Show Gist options
  • Save rzymek/75e7071beb6dc6e1358e80b7aca57c3b to your computer and use it in GitHub Desktop.
Save rzymek/75e7071beb6dc6e1358e80b7aca57c3b to your computer and use it in GitHub Desktop.
fb feed cleaner
(function(){
removed=0;
document.title="0";
document.querySelectorAll("[role='complementary']").forEach(it=>it.remove())
setInterval(() => {
rm=(e2d)=>{
if(!e2d)return;
e2d.remove();
removed++;
document.title=`${removed}`;
}
{/*sponsored*/
sponsoredRefs = Array.from(document.querySelectorAll("text[id]"))
.filter(it => it.textContent === 'Sponsored')
.map(it => `#${it.id}`);
findParent = (eP, predicate) => {
for (; ;) {
eP = eP.parentElement;
if (!eP || predicate(eP)) {
return eP;
}
}
}
useIds = Array.from(document.querySelectorAll("use"))
.filter(it => sponsoredRefs.includes(it.getAttribute("xlink:href")))
.map(e1 => findParent(e1, e2 => e2.id))
.map(e3 => `#${e3.id}`)
.concat(sponsoredRefs)
Array.from(document.querySelectorAll("use"))
.filter(it => useIds.includes(it.getAttribute("xlink:href")))
.forEach(x => {
rm(findParent(x, e4 => e4.getAttribute('aria-describedby')));
})
Array.from(document.querySelectorAll('a[href^="/ads/about"]'))
.map(x => findParent(x, e5 => e5.getAttribute('aria-describedby'))).forEach(rm)
}
{
headers=['Suggested for you','People You May Know','Reels and short videos','Suggested events',
'Proponowana dla Ciebie','Osoby, które możesz znać','Follow','Join']
suggested = document.evaluate(headers.map(h=>`//span[text()='${h}']`).join("|"), document, null, XPathResult.ANY_TYPE, null)
s = [];
while (x1 = suggested.iterateNext()) s.push(x1);
s.forEach(x2 => {
rm(findParent(x2, eq => eq.getAttribute('aria-describedby')));
})
}
}, 100);
})();
@rzymek
Copy link
Author

rzymek commented Oct 23, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment