Skip to content

Instantly share code, notes, and snippets.

@srsgores
Created April 19, 2018 04:10
Show Gist options
  • Save srsgores/6bdc904aba143770cdd396277ecabb9a to your computer and use it in GitHub Desktop.
Save srsgores/6bdc904aba143770cdd396277ecabb9a to your computer and use it in GitHub Desktop.
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