Hide Verified Replies ✓

Hides replies from verified accounts

  1. // ==UserScript==
  2. // @name Hide Verified Replies ✓
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6
  5. // @description Hides replies from verified accounts
  6. // @author bmpq
  7. // @match https://x.com/*
  8. // @match https://twitter.com/*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const whitelist = ["Cat_Auras", "xkcd"];
  17.  
  18. function hideVerifiedAccountPosts() {
  19. const currentPage = window.location.pathname;
  20.  
  21. // doing this instead of userscript match because twitter is an SPA
  22. if (!currentPage.includes('/status/'))
  23. return;
  24.  
  25. const articles = document.querySelectorAll('article');
  26. articles.forEach(article => {
  27. const authorLink = article.querySelector('a[href^="/"][role="link"]');
  28. const verifiedSvg = article.querySelector('svg[data-testid="icon-verified"]');
  29.  
  30. if (verifiedSvg && authorLink) {
  31. let profileUrl = authorLink.getAttribute('href');
  32. let username = authorLink.getAttribute('href').substring(1);
  33.  
  34. // dont hide the original post
  35. if (currentPage.includes(profileUrl)) {
  36. return;
  37. }
  38.  
  39. if (whitelist.includes(username)) {
  40. return;
  41. }
  42.  
  43. const infoDiv = document.createElement('div');
  44. infoDiv.style.color = 'rgb(113, 118, 123)';
  45. infoDiv.style.fontFamily = 'TwitterChirp, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
  46. infoDiv.style.padding = '10px 10px';
  47.  
  48. const link = document.createElement('a');
  49. link.href = profileUrl;
  50. link.textContent = `@${username}`;
  51. link.style.color = 'inherit';
  52. link.style.textDecoration = 'none';
  53.  
  54. infoDiv.textContent = `Hidden verified post from `;
  55. infoDiv.appendChild(link);
  56.  
  57. article.replaceWith(infoDiv);
  58. }
  59. });
  60. }
  61.  
  62. const observer = new MutationObserver((mutations) => {
  63. mutations.forEach((mutation) => {
  64. hideVerifiedAccountPosts();
  65. });
  66. });
  67.  
  68. observer.observe(document.body, {
  69. childList: true,
  70. subtree: true
  71. });
  72. })();

QingJ © 2025

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