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.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

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.

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs