Last active
August 24, 2024 14:08
-
-
Save rzymek/75e7071beb6dc6e1358e80b7aca57c3b to your computer and use it in GitHub Desktop.
fb feed cleaner
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
(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}`; | |
} | |
findParent = (eP, predicate) => { | |
for (; ;) { | |
eP = eP.parentElement; | |
if (!eP || predicate(eP)) { | |
return eP; | |
} | |
} | |
} | |
xp = (xpath) => { | |
const result = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE); | |
return Array.from({ length: result.snapshotLength }, (_, index) => result.snapshotItem(index)); | |
} | |
{/*sponsored*/ | |
xp(`//span[text()='Sponsored']`) | |
.map(it => it.id) | |
.filter(it=>it) | |
.flatMap(id => Array.from(document.querySelectorAll(`[aria-labelledby="${id}"]`))) | |
.map(x => findParent(x, e5 => e5.getAttribute('aria-describedby'))) | |
.forEach(rm) | |
Array.from(document.querySelectorAll('a[href^="/ads/about"]')) | |
.map(x => findParent(x, e5 => e5.getAttribute('aria-describedby'))).forEach(rm) | |
} | |
{ | |
suggested = xp( | |
['Suggested for you','People You May Know','Reels and short videos','Suggested events', | |
'Proponowana dla Ciebie','Osoby, które możesz znać','Follow','Join'] | |
.map(h=>`//span[text()='${h}']`) | |
.join("|")) | |
.forEach(x2 => { | |
rm(findParent(x2, eq => eq.getAttribute('aria-describedby'))); | |
}) | |
} | |
}, 100); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://caiorss.github.io/bookmarklet-maker/