Hide Verified Replies

Hides replies from verified accounts

当前为 2024-10-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Hide Verified Replies
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.5
  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. if (currentPage.includes('/home'))
  22. return;
  23.  
  24. const articles = document.querySelectorAll('article');
  25. articles.forEach(article => {
  26. const authorLink = article.querySelector('a[href^="/"][role="link"]');
  27. const verifiedSvg = article.querySelector('svg[data-testid="icon-verified"]');
  28.  
  29. if (verifiedSvg && authorLink) {
  30. let profileUrl = authorLink.getAttribute('href');
  31. let username = authorLink.getAttribute('href').substring(1);
  32.  
  33. if (currentPage.includes(profileUrl)) {
  34. return;
  35. }
  36.  
  37. if (whitelist.includes(username)) {
  38. return;
  39. }
  40.  
  41. const infoDiv = document.createElement('div');
  42. infoDiv.style.color = 'rgb(113, 118, 123)';
  43. infoDiv.style.fontFamily = 'TwitterChirp, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
  44. infoDiv.style.padding = '10px 10px';
  45.  
  46. const link = document.createElement('a');
  47. link.href = profileUrl;
  48. link.textContent = `@${username}`;
  49. link.style.color = 'inherit';
  50. link.style.textDecoration = 'none';
  51.  
  52. infoDiv.textContent = `Hidden verified post from `;
  53. infoDiv.appendChild(link);
  54.  
  55. article.replaceWith(infoDiv);
  56. }
  57. });
  58. }
  59.  
  60. const observer = new MutationObserver((mutations) => {
  61. mutations.forEach((mutation) => {
  62. hideVerifiedAccountPosts();
  63. });
  64. });
  65.  
  66. observer.observe(document.body, {
  67. childList: true,
  68. subtree: true
  69. });
  70. })();

QingJ © 2025

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