Hide Twitter Views link

Remove the twitter views link from people's tweets

  1. // ==UserScript==
  2. // @name Hide Twitter Views link
  3. // @namespace https://twitter.com/14letterhandle
  4. // @version 0.6
  5. // @description Remove the twitter views link from people's tweets
  6. // @author 14letterhandle
  7. // @match https://twitter.com/*
  8. // @icon https://static.thenounproject.com/png/1159224-200.png
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. "use strict";
  14.  
  15. const removeViews = () => {
  16. // Remove link version of view count
  17. Array.from(document.querySelectorAll("article a"))
  18. .filter(({ href }) => href.endsWith("/analytics"))
  19. .filter(({ innerHTML }) => !innerHTML.includes("View Tweet analytics"))
  20. .forEach(({ parentElement }) => parentElement.remove());
  21.  
  22. // Remove span version of view count
  23. Array.from(document.querySelectorAll("span"))
  24. .filter(({ textContent }) => /^.* views?$/i.test(textContent))
  25. .forEach((el) => el.remove());
  26.  
  27. // Trim any excess text decoration left from deleting view count
  28. Array.from(document.querySelectorAll("span:last-child"))
  29. .filter(({ textContent }) => textContent === "·")
  30. .forEach((el) => el.remove());
  31. };
  32.  
  33. new MutationObserver((mutations) => {
  34. mutations.forEach(({ addedNodes }) => !!addedNodes.length && removeViews());
  35. }).observe(document.body, { childList: true, subtree: true });
  36.  
  37. removeViews();
  38. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址