Hide Verified Posts

Hides posts from verified accounts

Per 17-10-2024. Zie de nieuwste versie.

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