Hide Twitter Views link

Remove the twitter views link from people's tweets

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Hide Twitter Views link
// @namespace    https://twitter.com/14letterhandle
// @version      0.6
// @description  Remove the twitter views link from people's tweets
// @author       14letterhandle
// @match        https://twitter.com/*
// @icon         https://static.thenounproject.com/png/1159224-200.png
// @license      MIT
// ==/UserScript==

(function () {
  "use strict";

  const removeViews = () => {
    // Remove link version of view count
    Array.from(document.querySelectorAll("article a"))
      .filter(({ href }) => href.endsWith("/analytics"))
      .filter(({ innerHTML }) => !innerHTML.includes("View Tweet analytics"))
      .forEach(({ parentElement }) => parentElement.remove());

    // Remove span version of view count
    Array.from(document.querySelectorAll("span"))
      .filter(({ textContent }) => /^.* views?$/i.test(textContent))
      .forEach((el) => el.remove());

    // Trim any excess text decoration left from deleting view count
    Array.from(document.querySelectorAll("span:last-child"))
      .filter(({ textContent }) => textContent === "·")
      .forEach((el) => el.remove());
  };

  new MutationObserver((mutations) => {
    mutations.forEach(({ addedNodes }) => !!addedNodes.length && removeViews());
  }).observe(document.body, { childList: true, subtree: true });

  removeViews();
})();