X/Twitter 干净的选单和侧边栏(支持多种语言)

干净的 选单、Grok、高级订阅、已认证组织、其他、探索、通知、私信、书签、右侧边栏、静音通知和可自订设定

  1. // ==UserScript==
  2. // @name X/Twitter Clean menu and sidebar (Supports multiple language)
  3. // @name:ja X/Twitter きれいなメニューとサイドバー(多言語対応)
  4. // @name:zh-TW X/Twitter 乾淨的選單和側邊欄(支持多種語言)
  5. // @name:zh-CN X/Twitter 干净的选单和侧边栏(支持多种语言)
  6. // @version 2.9
  7. // @description Hidden Menu,Grok,Premium subscription,Verified Orgs,other,Explore,Notifications,Messages,Communities,Bookmarks,Right Column, Muted Account Notices and Customizable Settings
  8. // @description:ja 清潔なメニュー、Grok、高度なサブスクリプション、認証済み組織、他の、探索、通知、メッセージ、コミュニティ、ブックマーク、右側カラム、ミュート通知、およびカスタム設定
  9. // @description:zh-TW 乾淨的 選單、Grok、高級訂閱、已認證組織、其他、探索、通知、訊息、社群、書籤、右側邊欄、靜音通知和可自訂設定
  10. // @description:zh-CN 干净的 选单、Grok、高级订阅、已认证组织、其他、探索、通知、私信、书签、右侧边栏、静音通知和可自订设定
  11. // @license MIT
  12. // @author movwei
  13. // @match https://x.com/*
  14. // @match https://twitter.com/*
  15. // @grant GM_registerMenuCommand
  16. // @grant GM_setValue
  17. // @grant GM_getValue
  18. // @grant GM_addStyle
  19. // @namespace https://greasyfork.org/users/1041101
  20. // ==/UserScript==
  21.  
  22. (function() {
  23. 'use strict';
  24.  
  25. const defaultSettings = {
  26. hideGrok: true,
  27. hidePremiumSignUp: true,
  28. hideSelectors: true,
  29. hideVerifiedOrgs: true,
  30. hideother: true,
  31. hideExplore: false,
  32. hideNotifications: false,
  33. hideBookmarks: false,
  34. hideMessages: false,
  35. hideCommunities: false,
  36. hideMutedNotices: false,
  37. hideRightColumn: false,
  38. useLargerCSS: false,
  39. cssWidth: 680,
  40. useCustomPadding: false,
  41. paddingWidth: 20,
  42. };
  43.  
  44. const settings = {
  45. hideGrok: GM_getValue('hideGrok', defaultSettings.hideGrok),
  46. hidePremiumSignUp: GM_getValue('hidePremiumSignUp', defaultSettings.hidePremiumSignUp),
  47. hideSelectors: GM_getValue('hideSelectors', defaultSettings.hideSelectors),
  48. hideVerifiedOrgs: GM_getValue('hideVerifiedOrgs', defaultSettings.hideVerifiedOrgs),
  49. hideother: GM_getValue('hideother', defaultSettings.hideother),
  50. hideExplore: GM_getValue('hideExplore', defaultSettings.hideExplore),
  51. hideNotifications: GM_getValue('hideNotifications', defaultSettings.hideNotifications),
  52. hideBookmarks: GM_getValue('hideBookmarks', defaultSettings.hideBookmarks),
  53. hideMessages: GM_getValue('hideMessages', defaultSettings.hideMessages),
  54. hideCommunities: GM_getValue('hideCommunities', defaultSettings.hideCommunities),
  55. hideRightColumn: GM_getValue('hideRightColumn', defaultSettings.hideRightColumn),
  56. hideMutedNotices: GM_getValue('hideMutedNotices', defaultSettings.hideMutedNotices),
  57. useLargerCSS: GM_getValue('useLargerCSS', defaultSettings.useLargerCSS),
  58. cssWidth: GM_getValue('cssWidth', defaultSettings.cssWidth),
  59. useCustomPadding: GM_getValue('useCustomPadding', defaultSettings.useCustomPadding),
  60. paddingWidth: GM_getValue('paddingWidth', defaultSettings.paddingWidth),
  61. };
  62.  
  63. const language = navigator.language || navigator.userLanguage;
  64. const languages = {
  65. 'en': {
  66. 'hideGrok': 'Hide Grok',
  67. 'hidePremiumSignUp': 'Hide Premium Sign-up',
  68. 'hideSelectors': 'Hide Subscribe Message',
  69. 'hideVerifiedOrgs': 'Hide Verified Orgs',
  70. 'hideExplore': 'Hide Explore',
  71. 'hideNotifications': 'Hide Notifications',
  72. 'hideMessages': 'Hide Messages',
  73. 'hideCommunities': 'Hide Communities',
  74. 'hideBookmarks': 'Hide Bookmarks',
  75. 'hideother': 'Hide other',
  76. 'hideMutedNotices': 'Hide Muted Account Notices',
  77. 'hideRightColumn': 'Hide Right Column',
  78. 'useLargerCSS': 'Larger Post Area',
  79. 'cssWidth': 'Custom width',
  80. 'useCustomPadding': 'Right Sidebar Spacing',
  81. 'paddingWidth': 'Padding Width',
  82. 'settings': 'Settings',
  83. 'saveRefresh': 'Save & refresh',
  84. 'close': 'Close'
  85. },
  86. 'zh-TW': {
  87. 'hideGrok': '隱藏 Grok',
  88. 'hidePremiumSignUp': '隱藏 高級訂閱',
  89. 'hideSelectors': '隱藏 訂閱訊息',
  90. 'hideVerifiedOrgs': '隱藏 已認證組織',
  91. 'hideExplore': '隱藏 探索',
  92. 'hideNotifications': '隱藏 通知',
  93. 'hideMessages': '隱藏 訊息',
  94. 'hideCommunities': '隱藏 社群',
  95. 'hideBookmarks': '隱藏 書籤',
  96. 'hideother': '隱藏 其他',
  97. 'hideMutedNotices': '隱藏 靜音帳戶通知',
  98. 'hideRightColumn': '隱藏 右側邊欄',
  99. 'useLargerCSS': '更大貼文區域',
  100. 'cssWidth': '自訂寬度',
  101. 'useCustomPadding': '右側邊欄間距',
  102. 'paddingWidth': '間距寬度',
  103. 'settings': '設定',
  104. 'saveRefresh': '保存並刷新',
  105. 'close': '關閉'
  106. },
  107. 'zh-CN': {
  108. 'hideGrok': '隐藏 Grok',
  109. 'hidePremiumSignUp': '隐藏 高级订阅',
  110. 'hideSelectors': '隐藏 订阅消息',
  111. 'hideVerifiedOrgs': '隐藏 已认证组织',
  112. 'hideExplore': '隐藏 探索',
  113. 'hideNotifications': '隐藏 通知',
  114. 'hideMessages': '隐藏 私信',
  115. 'hideCommunities': '隐藏 社群',
  116. 'hideBookmarks': '隐藏 书签',
  117. 'hideother': '隐藏 其他',
  118. 'hideMutedNotices': '隐藏 静音账户通知',
  119. 'hideRightColumn': '隐藏 右侧边栏',
  120. 'useLargerCSS': '更大帖子区域',
  121. 'cssWidth': '自定义宽度',
  122. 'useCustomPadding': '右侧边栏间距',
  123. 'paddingWidth': '间距宽度',
  124. 'settings': '设置',
  125. 'saveRefresh': '保存并刷新',
  126. 'close': '关闭'
  127. },
  128. 'ja': {
  129. 'hideGrok': 'Grokを非表示',
  130. 'hidePremiumSignUp': 'プレミアムサインアップを非表示',
  131. 'hideSelectors': 'サブスクライブメッセージを非表示',
  132. 'hideVerifiedOrgs': '認証済み組織を非表示',
  133. 'hideExplore': '話題を検索を非表示',
  134. 'hideNotifications': '通知を非表示',
  135. 'hideMessages': 'メッセージを非表示',
  136. 'hideCommunities': 'コミュニティを非表示',
  137. 'hideBookmarks': 'ブックマークを非表示',
  138. 'hideother': '他のを非表示',
  139. 'hideMutedNotices': 'ミュートアカウント通知を非表示',
  140. 'hideRightColumn': '右側カラムを非表示',
  141. 'useLargerCSS': 'より大きな投稿エリア',
  142. 'cssWidth': 'カスタム幅',
  143. 'useCustomPadding': '右側サイドバーの間隔',
  144. 'paddingWidth': 'パディング幅',
  145. 'settings': '設定',
  146. 'saveRefresh': '保存して更新',
  147. 'close': '閉じる'
  148. },
  149. };
  150.  
  151. const currentLanguage = languages[language] || languages['en'];
  152.  
  153. function createSettingsPanel() {
  154. const panel = document.createElement('div');
  155. panel.id = 'settingsPanel';
  156. panel.innerHTML = `
  157. <div id="settingsPanelContent">
  158. <div class="settings-header">
  159. <h2>${currentLanguage['settings']}</h2>
  160. </div>
  161.  
  162. <div class="settings-container">
  163. <div class="settings-section">
  164. <label class="toggle-switch">
  165. <input type="checkbox" id="hideGrokCheckbox" ${settings.hideGrok ? 'checked' : ''}>
  166. <span class="toggle-slider"></span>
  167. <span class="toggle-label">${currentLanguage['hideGrok']}</span>
  168. </label>
  169. <label class="toggle-switch">
  170. <input type="checkbox" id="hidePremiumSignUpCheckbox" ${settings.hidePremiumSignUp ? 'checked' : ''}>
  171. <span class="toggle-slider"></span>
  172. <span class="toggle-label">${currentLanguage['hidePremiumSignUp']}</span>
  173. </label>
  174. <label class="toggle-switch">
  175. <input type="checkbox" id="hideSelectorsCheckbox" ${settings.hideSelectors ? 'checked' : ''}>
  176. <span class="toggle-slider"></span>
  177. <span class="toggle-label">${currentLanguage['hideSelectors']}</span>
  178. </label>
  179. <label class="toggle-switch">
  180. <input type="checkbox" id="hideVerifiedOrgsCheckbox" ${settings.hideVerifiedOrgs ? 'checked' : ''}>
  181. <span class="toggle-slider"></span>
  182. <span class="toggle-label">${currentLanguage['hideVerifiedOrgs']}</span>
  183. </label>
  184. <label class="toggle-switch">
  185. <input type="checkbox" id="hideotherCheckbox" ${settings.hideother ? 'checked' : ''}>
  186. <span class="toggle-slider"></span>
  187. <span class="toggle-label">${currentLanguage['hideother']}</span>
  188. </label>
  189. </div>
  190.  
  191. <div class="settings-section">
  192. <label class="toggle-switch">
  193. <input type="checkbox" id="hideExploreCheckbox" ${settings.hideExplore ? 'checked' : ''}>
  194. <span class="toggle-slider"></span>
  195. <span class="toggle-label">${currentLanguage['hideExplore']}</span>
  196. </label>
  197. <label class="toggle-switch">
  198. <input type="checkbox" id="hideNotificationsCheckbox" ${settings.hideNotifications ? 'checked' : ''}>
  199. <span class="toggle-slider"></span>
  200. <span class="toggle-label">${currentLanguage['hideNotifications']}</span>
  201. </label>
  202. <label class="toggle-switch">
  203. <input type="checkbox" id="hideMessagesCheckbox" ${settings.hideMessages ? 'checked' : ''}>
  204. <span class="toggle-slider"></span>
  205. <span class="toggle-label">${currentLanguage['hideMessages']}</span>
  206. </label>
  207. <label class="toggle-switch">
  208. <input type="checkbox" id="hideCommunitiesCheckbox" ${settings.hideCommunities ? 'checked' : ''}>
  209. <span class="toggle-slider"></span>
  210. <span class="toggle-label">${currentLanguage['hideCommunities']}</span>
  211. </label>
  212. <label class="toggle-switch">
  213. <input type="checkbox" id="hideBookmarksCheckbox" ${settings.hideBookmarks ? 'checked' : ''}>
  214. <span class="toggle-slider"></span>
  215. <span class="toggle-label">${currentLanguage['hideBookmarks']}</span>
  216. </label>
  217. </div>
  218.  
  219. <div class="settings-section">
  220. <label class="toggle-switch">
  221. <input type="checkbox" id="hideMutedNoticesCheckbox" ${settings.hideMutedNotices ? 'checked' : ''}>
  222. <span class="toggle-slider"></span>
  223. <span class="toggle-label">${currentLanguage['hideMutedNotices']}</span>
  224. </label>
  225. <label class="toggle-switch">
  226. <input type="checkbox" id="hideRightColumnCheckbox" ${settings.hideRightColumn ? 'checked' : ''}>
  227. <span class="toggle-slider"></span>
  228. <span class="toggle-label">${currentLanguage['hideRightColumn']}</span>
  229. </label>
  230. </div>
  231. </div>
  232.  
  233. <div class="horizontal-settings-container">
  234. <div class="horizontal-settings-item">
  235. <label class="toggle-switch">
  236. <input type="checkbox" id="useLargerCSSCheckbox" ${settings.useLargerCSS ? 'checked' : ''}>
  237. <span class="toggle-slider"></span>
  238. <span class="toggle-label">${currentLanguage['useLargerCSS']}</span>
  239. </label>
  240. <div class="width-input-container">
  241. <span class="width-label">${currentLanguage['cssWidth']}</span>
  242. <div class="width-input-wrapper">
  243. <input type="number" id="cssWidthInput" class="width-input" value="${settings.cssWidth}" min="400" max="1200">
  244. <span class="width-unit">px</span>
  245. </div>
  246. </div>
  247. </div>
  248. <div class="horizontal-settings-item">
  249. <label class="toggle-switch">
  250. <input type="checkbox" id="useCustomPaddingCheckbox" ${settings.useCustomPadding ? 'checked' : ''}>
  251. <span class="toggle-slider"></span>
  252. <span class="toggle-label">${currentLanguage['useCustomPadding']}</span>
  253. </label>
  254. <div class="width-input-container">
  255. <span class="width-label">${currentLanguage['paddingWidth']}</span>
  256. <div class="width-input-wrapper">
  257. <input type="number" id="paddingWidthInput" class="width-input" value="${settings.paddingWidth}" min="0" max="100">
  258. <span class="width-unit">px</span>
  259. </div>
  260. </div>
  261. </div>
  262. </div>
  263.  
  264. <div class="buttons-container">
  265. <button id="saveSettingsButton" class="panel-button primary-button">${currentLanguage['saveRefresh']}</button>
  266. <button id="closeSettingsButton" class="panel-button secondary-button">${currentLanguage['close']}</button>
  267. </div>
  268. </div>
  269. `;
  270. document.body.appendChild(panel);
  271. document.getElementById('saveSettingsButton').addEventListener('click', saveSettings);
  272. document.getElementById('closeSettingsButton').addEventListener('click', () => {
  273. document.getElementById('settingsPanel').style.display = 'none';
  274. });
  275.  
  276. document.getElementById('hideRightColumnCheckbox').addEventListener('change', function() {
  277. if (this.checked) {
  278. document.getElementById('useLargerCSSCheckbox').checked = true;
  279. } else {
  280. document.getElementById('useLargerCSSCheckbox').checked = false;
  281. }
  282. });
  283. }
  284.  
  285. function saveSettings() {
  286. settings.hideGrok = document.getElementById('hideGrokCheckbox').checked;
  287. settings.hidePremiumSignUp = document.getElementById('hidePremiumSignUpCheckbox').checked;
  288. settings.hideSelectors = document.getElementById('hideSelectorsCheckbox').checked;
  289. settings.hideVerifiedOrgs = document.getElementById('hideVerifiedOrgsCheckbox').checked;
  290. settings.hideExplore = document.getElementById('hideExploreCheckbox').checked;
  291. settings.hideNotifications = document.getElementById('hideNotificationsCheckbox').checked;
  292. settings.hideBookmarks = document.getElementById('hideBookmarksCheckbox').checked;
  293. settings.hideMessages = document.getElementById('hideMessagesCheckbox').checked;
  294. settings.hideCommunities = document.getElementById('hideCommunitiesCheckbox').checked;
  295. settings.hideother = document.getElementById('hideotherCheckbox').checked;
  296. settings.hideRightColumn = document.getElementById('hideRightColumnCheckbox').checked;
  297. settings.hideMutedNotices = document.getElementById('hideMutedNoticesCheckbox').checked;
  298. settings.useLargerCSS = document.getElementById('useLargerCSSCheckbox').checked;
  299. settings.cssWidth = parseInt(document.getElementById('cssWidthInput').value) || 680;
  300. settings.useCustomPadding = document.getElementById('useCustomPaddingCheckbox').checked;
  301. settings.paddingWidth = parseInt(document.getElementById('paddingWidthInput').value) || 20;
  302.  
  303. GM_setValue('hideGrok', settings.hideGrok);
  304. GM_setValue('hidePremiumSignUp', settings.hidePremiumSignUp);
  305. GM_setValue('hideSelectors', settings.hideSelectors);
  306. GM_setValue('hideVerifiedOrgs', settings.hideVerifiedOrgs);
  307. GM_setValue('hideExplore', settings.hideExplore);
  308. GM_setValue('hideNotifications', settings.hideNotifications);
  309. GM_setValue('hideBookmarks', settings.hideBookmarks);
  310. GM_setValue('hideMessages', settings.hideMessages);
  311. GM_setValue('hideCommunities', settings.hideCommunities);
  312. GM_setValue('hideother', settings.hideother);
  313. GM_setValue('hideRightColumn', settings.hideRightColumn);
  314. GM_setValue('hideMutedNotices', settings.hideMutedNotices);
  315. GM_setValue('useLargerCSS', settings.useLargerCSS);
  316. GM_setValue('cssWidth', settings.cssWidth);
  317. GM_setValue('useCustomPadding', settings.useCustomPadding);
  318. GM_setValue('paddingWidth', settings.paddingWidth);
  319. location.reload();
  320. }
  321.  
  322. GM_addStyle(`
  323. #settingsPanel {
  324. width: 90%;
  325. max-width: 800px;
  326. min-width: 300px;
  327. position: fixed;
  328. top: 50%;
  329. left: 50%;
  330. transform: translate(-50%, -50%);
  331. background-color: #ffffff;
  332. border: none;
  333. padding: 0;
  334. z-index: 10000;
  335. display: none;
  336. box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  337. border-radius: 16px;
  338. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  339. overflow: hidden;
  340. }
  341.  
  342. #settingsPanelContent {
  343. display: flex;
  344. flex-direction: column;
  345. width: 100%;
  346. }
  347.  
  348. .settings-header {
  349. display: flex;
  350. justify-content: center;
  351. align-items: center;
  352. padding: 16px 20px;
  353. border-bottom: 1px solid rgba(0,0,0,0.08);
  354. }
  355.  
  356. #settingsPanel h2 {
  357. margin: 0;
  358. font-size: 18px;
  359. font-weight: 700;
  360. color: #0f1419;
  361. text-align: center;
  362. }
  363.  
  364. .settings-container {
  365. display: flex;
  366. justify-content: space-between;
  367. padding: 12px 20px;
  368. flex-wrap: wrap;
  369. border-bottom: 1px solid rgba(0,0,0,0.08);
  370. }
  371.  
  372. .settings-section {
  373. flex: 1;
  374. min-width: 200px;
  375. padding: 0 10px;
  376. }
  377.  
  378. .horizontal-settings-container {
  379. display: flex;
  380. justify-content: space-between;
  381. padding: 12px 20px;
  382. border-bottom: 1px solid rgba(0,0,0,0.08);
  383. }
  384.  
  385. .horizontal-settings-item {
  386. flex: 1;
  387. min-width: 200px;
  388. padding: 0 10px;
  389. }
  390.  
  391. .toggle-switch {
  392. position: relative;
  393. display: flex;
  394. align-items: center;
  395. margin: 12px 0;
  396. padding: 6px 0;
  397. cursor: pointer;
  398. }
  399.  
  400. .toggle-switch:first-child {
  401. border-top: none;
  402. }
  403.  
  404. .toggle-switch input {
  405. opacity: 0;
  406. width: 0;
  407. height: 0;
  408. }
  409.  
  410. .toggle-slider {
  411. position: relative;
  412. display: inline-block;
  413. width: 42px;
  414. height: 24px;
  415. background-color: #cfd9de;
  416. border-radius: 24px;
  417. transition: .3s;
  418. margin-right: 12px;
  419. flex-shrink: 0;
  420. }
  421.  
  422. .toggle-slider:before {
  423. position: absolute;
  424. content: "";
  425. height: 18px;
  426. width: 18px;
  427. left: 3px;
  428. bottom: 3px;
  429. background-color: white;
  430. border-radius: 50%;
  431. transition: .3s;
  432. }
  433.  
  434. input:checked + .toggle-slider {
  435. background-color: #1d9bf0;
  436. }
  437.  
  438. input:checked + .toggle-slider:before {
  439. transform: translateX(18px);
  440. }
  441.  
  442. .toggle-label {
  443. font-size: 16px;
  444. color: #0f1419;
  445. }
  446.  
  447. .buttons-container {
  448. display: flex;
  449. justify-content: center;
  450. padding: 16px 20px;
  451. gap: 10px;
  452. border-top: 1px solid rgba(0,0,0,0.08);
  453. }
  454.  
  455. .panel-button {
  456. flex: 1;
  457. padding: 12px 0;
  458. font-size: 15px;
  459. font-weight: 600;
  460. border: none;
  461. border-radius: 9999px;
  462. cursor: pointer;
  463. transition: background-color 0.2s;
  464. text-align: center;
  465. }
  466.  
  467. .primary-button {
  468. color: white;
  469. background-color: #1d9bf0;
  470. }
  471.  
  472. .primary-button:hover {
  473. background-color: #1a8cd8;
  474. }
  475.  
  476. .secondary-button {
  477. color: #0f1419;
  478. background-color: #e6e7e7;
  479. }
  480.  
  481. .secondary-button:hover {
  482. background-color: #d1d1d1;
  483. }
  484.  
  485. .width-input-container {
  486. display: flex;
  487. align-items: center;
  488. justify-content: center;
  489. margin: 12px 0;
  490. padding: 25px 0;
  491. }
  492.  
  493. .width-label {
  494. font-size: 16px;
  495. color: #0f1419;
  496. flex-grow: 0.1;
  497. }
  498.  
  499. .width-input-wrapper {
  500. position: relative;
  501. display: flex;
  502. align-items: center;
  503. }
  504.  
  505. .width-input {
  506. width: 90px;
  507. padding: 8px 30px 8px 12px;
  508. border: 1px solid #cfd9de;
  509. border-radius: 9999px;
  510. font-size: 14px;
  511. transition: border-color 0.2s;
  512. text-align: center;
  513. }
  514.  
  515. .width-input:focus {
  516. outline: none;
  517. border-color: #1d9bf0;
  518. box-shadow: 0 0 0 1px rgba(29, 155, 240, 0.3);
  519. }
  520.  
  521. .width-unit {
  522. position: absolute;
  523. right: 12px;
  524. font-size: 14px;
  525. color: #536471;
  526. pointer-events: none;
  527. }
  528.  
  529. .width-input::-webkit-inner-spin-button,
  530. .width-input::-webkit-outer-spin-button {
  531. -webkit-appearance: none;
  532. margin: 0;
  533. }
  534.  
  535. .width-input[type=number] {
  536. -moz-appearance: textfield;
  537. }
  538. `);
  539.  
  540. createSettingsPanel();
  541. GM_registerMenuCommand(currentLanguage['settings'], () => {
  542. const panel = document.getElementById('settingsPanel');
  543. panel.style.display = 'block';
  544. });
  545.  
  546. function addGlobalStyle(css) {
  547. var head, style;
  548. head = document.getElementsByTagName('head')[0];
  549. if (!head) { return; }
  550. style = document.createElement('style');
  551. style.type = 'text/css';
  552. style.innerHTML = css;
  553. head.appendChild(style);
  554. }
  555.  
  556. var cssRules = '';
  557.  
  558. if (settings.hideSelectors) {
  559. const observer = new MutationObserver(mutations => {
  560. mutations.forEach(mutation => {
  561. const elements = document.querySelectorAll('.css-175oi2r.r-1habvwh.r-eqz5dr.r-uaa2di.r-1mmae3n.r-3pj75a.r-bnwqim');
  562. elements.forEach(element => {
  563. const parentDiv = element.closest('div');
  564. if (parentDiv) {
  565. parentDiv.remove();
  566. }
  567. });
  568.  
  569. const verifiedUpsell = document.querySelectorAll('.css-175oi2r.r-yfoy6g.r-18bvks7.r-1867qdf.r-1phboty.r-rs99b7.r-1ifxtd0.r-1udh08x[data-testid="verified_profile_upsell"]');
  570. verifiedUpsell.forEach(element => {
  571. const parentDiv = element.closest('div');
  572. if (parentDiv) {
  573. parentDiv.remove();
  574. } else {
  575. element.remove();
  576. }
  577. });
  578. });
  579. });
  580. observer.observe(document.body, { childList: true, subtree: true });
  581.  
  582. GM_addStyle(`
  583. .css-175oi2r.r-1xpp3t0 { display: none !important; }
  584. .css-175oi2r.r-yfoy6g.r-18bvks7.r-1q9bdsx.r-rs99b7 { display: none !important; }
  585. `);
  586. }
  587.  
  588. if (settings.hideGrok) {
  589. const targetPathD = "M2.205 7.423L11.745 21h4.241L6.446 7.423H2.204zm4.237 7.541L2.2 21h4.243l2.12-3.017-2.121-3.02zM16.957 0L9.624 10.435l2.122 3.02L21.2 0h-4.243zm.767 6.456V21H21.2V1.51l-3.476 4.946z";
  590. const targetGrokImageGenPathD = "M12.745 20.54l10.97-8.19c.539-.4 1.307-.244 1.564.38 1.349 3.288.746 7.241-1.938 9.955-2.683 2.714-6.417 3.31-9.83 1.954l-3.728 1.745c5.347 3.697 11.84 2.782 15.898-1.324 3.219-3.255 4.216-7.692 3.284-11.693l.008.009c-1.351-5.878.332-8.227 3.782-13.031L33 0l-4.54 4.59v-.014L12.743 20.544M10.48 22.531c-3.837-3.707-3.175-9.446.1-12.755 2.42-2.449 6.388-3.448 9.852-1.979l3.72-1.737c-.67-.49-1.53-1.017-2.515-1.387-4.455-1.854-9.789-.931-13.41 2.728-3.483 3.523-4.579 8.94-2.697 13.561 1.405 3.454-.899 5.898-3.22 8.364C1.49 30.2.666 31.074 0 32l10.478-9.466";
  591. const observer = new MutationObserver(mutations => {
  592. mutations.forEach(mutation => {
  593. const svgs = document.querySelectorAll('svg[aria-hidden="true"].r-4qtqp9');
  594. svgs.forEach(svg => {
  595. const path = svg.querySelector('path');
  596. if (path && path.getAttribute('d') === targetPathD) {
  597. const container = svg.closest('button') || svg.closest('div');
  598. if (container) {
  599. container.remove();
  600. }
  601. }
  602. });
  603.  
  604. const grokImgGenButtons = document.querySelectorAll('button[data-testid="grokImgGen"]');
  605. grokImgGenButtons.forEach(button => {
  606. button.remove();
  607. });
  608. });
  609. });
  610. observer.observe(document.body, { childList: true, subtree: true });
  611.  
  612. GM_addStyle(`
  613. a[href="/i/grok"] { display: none !important; }
  614. .css-175oi2r.r-1867qdf.r-xnswec.r-13awgt0.r-1ce3o0f.r-1udh08x.r-u8s1d.r-13qz1uu.r-173mn98.r-1e5uvyk.r-ii8lfi.r-40lpo0.r-rs99b7.r-12jitg0 { display: none; }
  615. .css-175oi2r.r-16y2uox.r-1wbh5a2.r-tzz3ar.r-1pi2tsx.r-buy8e9.r-mfh4gg.r-2eszeu.r-10m9thr.r-lltvgl.r-18u37iz.r-9aw3ui { display: none; }
  616. .css-175oi2r.r-1s2bzr4.r-dnmrzs.r-bnwqim { display: none; }
  617. `);
  618. }
  619.  
  620. if (settings.hideCommunities) {
  621. const targetCommunitiesPathD = "M7.501 19.917L7.471 21H.472l.029-1.027c.184-6.618 3.736-8.977 7-8.977.963 0 1.95.212 2.87.672-.444.478-.851 1.03-1.212 1.656-.507-.204-1.054-.329-1.658-.329-2.767 0-4.57 2.223-4.938 6.004H7.56c-.023.302-.05.599-.059.917zm15.998.056L23.528 21H9.472l.029-1.027c.184-6.618 3.736-8.977 7-8.977s6.816 2.358 7 8.977zM21.437 19c-.367-3.781-2.17-6.004-4.938-6.004s-4.57 2.223-4.938 6.004h9.875zm-4.938-9c-.799 0-1.527-.279-2.116-.73-.836-.64-1.384-1.638-1.384-2.77 0-1.93 1.567-3.5 3.5-3.5s3.5 1.57 3.5 3.5c0 1.132-.548 2.13-1.384 2.77-.589.451-1.317.73-2.116.73zm-1.5-3.5c0 .827.673 1.5 1.5 1.5s1.5-.673 1.5-1.5-.673-1.5-1.5-1.5-1.5.673-1.5 1.5zM7.5 3C9.433 3 11 4.57 11 6.5S9.433 10 7.5 10 4 8.43 4 6.5 5.567 3 7.5 3zm0 2C6.673 5 6 5.673 6 6.5S6.673 8 7.5 8 9 7.327 9 6.5 8.327 5 7.5 5z";
  622. const observerCommunities = new MutationObserver(mutations => {
  623. mutations.forEach(() => {
  624. const svgs = document.querySelectorAll('svg[aria-hidden="true"].r-4qtqp9');
  625. svgs.forEach(svg => {
  626. const path = svg.querySelector('path');
  627. if (path && path.getAttribute('d') === targetCommunitiesPathD) {
  628. const container = svg.closest('a') || svg.closest('div');
  629. if (container) {
  630. container.remove();
  631. }
  632. }
  633. });
  634. });
  635. });
  636. observerCommunities.observe(document.body, { childList: true, subtree: true });
  637. }
  638.  
  639. if (settings.hidePremiumSignUp) {
  640. cssRules += 'a[href="/i/premium_sign_up"] { display: none !important; }';
  641. }
  642. if (settings.hideVerifiedOrgs) {
  643. cssRules += 'a[href="/i/verified-orgs-signup"] { display: none !important; }';
  644. }
  645. if (settings.hideother) {
  646. cssRules += 'a[href="/jobs"] { display: none !important; }';
  647. cssRules += '.css-175oi2r.r-l00any.r-109y4c4.r-kuekak { display: none !important; }';
  648. cssRules += 'a.css-175oi2r.r-5oul0u.r-knv0ih.r-faml9v.r-2dysd3.r-13qz1uu.r-o7ynqc.r-6416eg.r-1ny4l3l.r-1loqt21 { display: none !important; }';
  649. cssRules += 'a.css-175oi2r.r-5oul0u.r-1wzrnnt.r-1c4vpko.r-1c7gwzm.r-13qz1uu.r-o7ynqc.r-6416eg.r-1ny4l3l.r-1loqt21 { display: none !important; }';
  650. }
  651. if (settings.hideExplore) {
  652. cssRules += 'a[href="/explore"] { display: none !important; }';
  653. }
  654. if (settings.hideNotifications) {
  655. cssRules += 'a[href="/notifications"] { display: none !important; }';
  656. }
  657. if (settings.hideBookmarks) {
  658. cssRules += 'a[href="/i/bookmarks"] { display: none !important; }';
  659. }
  660. if (settings.hideMessages) {
  661. cssRules += 'a[href="/messages"] { display: none !important; }';
  662. }
  663. if (settings.hideRightColumn) {
  664. cssRules += '.css-175oi2r.r-yfoy6g.r-18bvks7.r-1867qdf.r-1phboty.r-rs99b7.r-1ifxtd0.r-1udh08x { display: none !important; }';
  665. cssRules += '.css-175oi2r.r-18bvks7.r-1867qdf.r-1phboty.r-1ifxtd0.r-1udh08x.r-1niwhzg.r-1yadl64 { display: none !important; }';
  666. }
  667. if (settings.useLargerCSS) {
  668. cssRules += `div[data-testid="sidebarColumn"] { padding-left:20px; }`;
  669. cssRules += `.r-1ye8kvj { max-width: ${settings.cssWidth}px !important; }`;
  670. cssRules += '.r-10f7w94 { margin-tuning-right: 0px !important; }';
  671. }
  672. if (settings.useCustomPadding) {
  673. cssRules += `div[data-testid="sidebarColumn"] { padding-left: ${settings.paddingWidth}px !important; }`;
  674. }
  675.  
  676. if (settings.hideMutedNotices) {
  677. function hideMutedPostNotices() {
  678. const replyCells = document.querySelectorAll('[data-testid="cellInnerDiv"]');
  679. replyCells.forEach((cell) => {
  680. const mutedNotices = cell.querySelectorAll('.css-175oi2r.r-1awozwy.r-g6ijar.r-cliqr8.r-1867qdf.r-1phboty.r-rs99b7.r-18u37iz.r-1wtj0ep.r-1mmae3n.r-n7gxbd');
  681. mutedNotices.forEach((notice) => {
  682. const parentCell = notice.closest('[data-testid="cellInnerDiv"]');
  683. if (parentCell) {
  684. parentCell.remove();
  685. }
  686. });
  687. });
  688. }
  689.  
  690. const observer = new MutationObserver(() => {
  691. hideMutedPostNotices();
  692. });
  693. observer.observe(document.body, { childList: true, subtree: true });
  694. hideMutedPostNotices();
  695. }
  696.  
  697. addGlobalStyle(cssRules);
  698. })();