Last active
October 23, 2020 15:26
-
-
Save clhenrick/d9fcc478f1c1251c39e44f2fc956c9ab to your computer and use it in GitHub Desktop.
Persisting the removal of annoying stuff from web pages
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
// 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