Last active
March 24, 2020 15:52
-
-
Save darcyclarke/68cd3abf282ad8b68aba08bdbfef7ea1 to your computer and use it in GitHub Desktop.
Facebook Sponsored Ad Filter - Use this w/ your preferred script injector (ex. "CJS" on Chrome or "Code Injector" on FF)
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
// Updated & working as of March 24th, 2020 | |
;(() => { | |
function removeAds() { | |
Array.from(document.querySelectorAll('[id^=feed_sub_title], [data-testid^=story-subtilte], [data-pagelet^=FeedUnit]')) | |
.map(e => { | |
let content = e.innerText | |
let dynamic = Array.from(e.querySelectorAll('span:not([data-content=""])')) | |
.filter(e => e.style.display != 'none') | |
.map(e => { | |
let hidden = window.getComputedStyle(e, ':before').getPropertyValue('content') | |
return (hidden && hidden !== 'none' ? hidden : '') + e.innerText | |
}) | |
.join('') | |
.replace(/['"]+/g, '') | |
if ((content + dynamic).toLowerCase().includes('sponsored')) { | |
e.closest('[data-pagelet^=FeedUnit]').remove() | |
} | |
}) | |
setTimeout(removeAds, 200) // change to whatever interval you want... | |
} | |
removeAds() | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment