Filters out the posts from the dev.to feed that are obviously spam
This file contains 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
| // ==UserScript== | |
| // @name dev.to spam filter | |
| // @version 1 | |
| // @include http* | |
| // @match *://dev.to/* | |
| // @grant none | |
| // @run-at document-end | |
| // ==/UserScript== | |
| const dev_posts = document.body; | |
| const config = { attributes: false, childList: true, subtree: true }; | |
| const callback = function(mutationsList, observer) | |
| { | |
| for(const mutation of mutationsList) | |
| { | |
| if (mutation.type === 'childList') | |
| { | |
| let posts = document.querySelectorAll('article'); | |
| posts.forEach(post => | |
| { | |
| const title = post.querySelector('.crayons-story__title a'); | |
| if(title.innerHTML.replace(/\n/g, '').match(/customer.*care.*number/i)) | |
| { | |
| post.parentElement.removeChild(post); | |
| console.log('removed post') | |
| } | |
| }); | |
| } | |
| } | |
| }; | |
| // Create an observer instance linked to the callback function | |
| const observer = new MutationObserver(callback); | |
| // Start observing the target node for configured mutations | |
| observer.observe(dev_posts, config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment