DEV Community

Matt Ellen-Tsivintzeli
Matt Ellen-Tsivintzeli

Posted on

4 2

Quick fix for current spam deluge

If you use Grease Monkey or similar, you can use this user script to filter out the current spam posts in your feed:

// ==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);
Enter fullscreen mode Exit fullscreen mode

Obviously this is a temporary work around while smarter people look at real spam filters, but my feed was unbrowseable :D

You'll need to do a hard refresh for the filter to kick in.

Thanks to MDN for the mutation observer code.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (2)

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli

I've put it into a Gist if people want to offer up improvements.

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli

Updated to cover when "customer care number" has things other than spaces in it.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay