shuuji3 / Twitter Block Ads & Moments etc.

// ==UserScript==
// @name         Twitter Block Ads & Moments etc.
// @namespace    https://openuserjs.org//users/shuuji3
// @version      0.1.0
// @description  Block bad things.
// @author       TAKAHASHI Shuuji <shuuji3@gmail.com>
// @copyright 2018, shuuji3 (https://openuserjs.org//users/shuuji3)
// @match        https://mobile.twitter.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
  'use strict';

  function removeAds() {
    const tweets = [...document.querySelectorAll('article')];
    tweets.forEach(tweet => {
      const isPromotion = tweet.querySelector('svg + div') !== null;
      if (isPromotion) {
        console.log('remove ads:', tweet.textContent);
        tweet.remove();
      }
    });
  }

  function removeMoments() {
    const style = document.createElement('style');
    style.innerText = 'div[aria-label="Timeline: Explore"] { display: none }';
    document.body.appendChild(style);
  }

  setInterval(removeAds, 100);
  removeMoments();
})();