Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove facebook sponsored ads
"use strict";
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
const observer = new MutationObserver(function(mutations, observer) {
const sponsoredRegex = /[S][sponred]*/;
mutations.filter((mutation) => mutation.target.textContent.split(sponsoredRegex).filter((match) => match === "").length >= 4).map((ad) => ad.target.remove());
});
observer.observe(document.getElementById("stream_pagelet"), {
childList:true,
subtree: true,
attributes: true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.