Hide Twitter Views link

Remove the twitter views link from people's tweets

You will need to install an extension such as Tampermonkey, Greasemonkey 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 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.

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

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

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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();
})();