Skip to content

Instantly share code, notes, and snippets.

@clhenrick
Last active October 23, 2020 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clhenrick/d9fcc478f1c1251c39e44f2fc956c9ab to your computer and use it in GitHub Desktop.
Save clhenrick/d9fcc478f1c1251c39e44f2fc956c9ab to your computer and use it in GitHub Desktop.
Persisting the removal of annoying stuff from web pages
// In Chrome devtools, create live expressions for each of these code blocks
// https://developers.google.com/web/tools/chrome-devtools/console/live-expressions
// Now when you visit a page, no more annoying thing that will bother you!
// The annoying thing contains this text
const textToSearchFor = "foo"
// Filtering by searching for the above text here but you could filter other ways too
function filterFn(node) {
return node.textContent.includes(textToSearchFor);
}
// Removing any list items that contain the above text,
// change this for whatever DOM element you want to remove.
Array.prototype.filter.call(
document.querySelectorAll("li"),
filterFn
)
.forEach(node => node.remove())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment