Twitter/X UI Improvements

Improves Twitter/X layout by adjusting widths and removing grok and stuff

  1. // ==UserScript==
  2. // @name Twitter/X UI Improvements
  3. // @namespace https://twitter.com/
  4. // @version 1.1
  5. // @description Improves Twitter/X layout by adjusting widths and removing grok and stuff
  6. // @author Minoa
  7. // @match https://twitter.com/*
  8. // @match https://x.com/*
  9. // @grant GM_addStyle
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Add custom CSS styles
  17. const customStyles = `
  18. .r-1ye8kvj { max-width: 680px !important; }
  19. .r-o96wvk { width: 230px !important; }
  20. .r-ttdzmv { padding-top: 8px !important; }
  21. .r-1hycxz { width: 280px !important; }
  22. .r-1jte41z { min-width: 250px !important; }
  23. `;
  24. GM_addStyle(customStyles);
  25.  
  26. // Function to remove unwanted elements
  27. function removeElements() {
  28. const selectors = [
  29. '[data-testid="GrokDrawer"]',
  30. 'a[href="/i/grok"]',
  31. 'a[href="/i/verified-orgs-signup"]',
  32. 'a[href="/i/premium_sign_up"]',
  33. 'aside[aria-label="Subscribe to Premium"]',
  34. '[data-testid="grokImgGen"]',
  35. '.r-18u37iz.r-1h0z5md button[aria-label="Grok actions"]'
  36. ];
  37.  
  38. selectors.forEach(selector => {
  39. const elements = document.querySelectorAll(selector);
  40. elements.forEach(element => element.remove());
  41. });
  42. }
  43.  
  44. // Create and run mutation observer to handle dynamically loaded content
  45. const observer = new MutationObserver(() => {
  46. removeElements();
  47. });
  48.  
  49. // Start observing
  50. observer.observe(document.body, {
  51. childList: true,
  52. subtree: true
  53. });
  54.  
  55. // Initial cleanup
  56. removeElements();
  57. })();