Skip to content

Instantly share code, notes, and snippets.

@Mellen
Last active December 4, 2020 03:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mellen/6e0c9398fe42d803c76bd2ec6ffc080b to your computer and use it in GitHub Desktop.
Save Mellen/6e0c9398fe42d803c76bd2ec6ffc080b to your computer and use it in GitHub Desktop.
Filters out the posts from the dev.to feed that are obviously spam
// ==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