I created an extension that lets you ignore tags on dev.to

kaos

Kai Oswald

Posted on July 5, 2019

I created an extension that lets you ignore tags on dev.to

I'm following the #webdev and the #vue tags, but my feed is full of #react, #python and #angular posts. I don't care about these, but many articles are tagged with multiple tags like #react, #webdev.

So what are we gonna do about it?
Wait until dev.to introduces the option to ignore tags?
Follow the tag and set its relevance to -999?
Since we are lazy developers, there's only one remaining option. Write our own extension ¯\(ツ)/¯.

Introducing Dev.no

So how does it work?
The extension can essentially be broken down to this little snippet

const tags = ['react', 'python']; // hardcoded tags list for demo purposes
tags.forEach(tag => {
    var tagElements = Array.from(
      document.querySelectorAll(`.single-article .tags a[href='/t/${tag}']`)
    );

    tagElements.forEach(tagElement => {
      // the whole article is located 2 elements above (parent.parent);
      var articleElement = tagElement.parentElement.parentElement;
      articleElement.style.display = "none";      
    });
  });

To better understand that snippet, let's have a look how an article looks like on the dev.to main page and break it down to the essential elements we need to focus on.

<div class="single-article single-article-small-pic">
  <!-- removed -->
  <div class="tags">
    <a href="/t/javascript"><span class="tag">#javascript</span></a>
    <a href="/t/webdev"><span class="tag">#webdev</span></a>
    <a href="/t/tutorial"><span class="tag">#tutorial</span></a>
    <a href="/t/discuss"><span class="tag">#discuss</span></a>
  </div>  
  <!-- removed -->
</div>

The tag 'react' can then for example be located with the following selector
.single-article .tags a[href='/t/react'].

The full article can then be accessed by calling .parentElement 2 times.

The extension also has an options UI, which is built with vue, where you can manage the ignored tags and view some nice stats. I'm not really satisfied with how it looks right now, so feel free to shoot a PR :)
screenshot of the options ui

This extension may become obsolete as soon as dev.to rolls out the option to ignore tags.

It's open source btw, so make sure to check out the repo and download the extension.

GitHub logo kai-oswald / dev.no

Chrome extension to ignore tags on dev.to

💖 💪 🙅 🚩
kaos
Kai Oswald

Posted on July 5, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related