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.7
  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://gf.qytechs.cn/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. };
  41.  
  42. const settings = {
  43. hideGrok: GM_getValue('hideGrok', defaultSettings.hideGrok),
  44. hidePremiumSignUp: GM_getValue('hidePremiumSignUp', defaultSettings.hidePremiumSignUp),
  45. hideSelectors: GM_getValue('hideSelectors', defaultSettings.hideSelectors),
  46. hideVerifiedOrgs: GM_getValue('hideVerifiedOrgs', defaultSettings.hideVerifiedOrgs),
  47. hideother: GM_getValue('hideother', defaultSettings.hideother),
  48. hideExplore: GM_getValue('hideExplore', defaultSettings.hideExplore),
  49. hideNotifications: GM_getValue('hideNotifications', defaultSettings.hideNotifications),
  50. hideBookmarks: GM_getValue('hideBookmarks', defaultSettings.hideBookmarks),
  51. hideMessages: GM_getValue('hideMessages', defaultSettings.hideMessages),
  52. hideCommunities: GM_getValue('hideCommunities', defaultSettings.hideCommunities),
  53. hideRightColumn: GM_getValue('hideRightColumn', defaultSettings.hideRightColumn),
  54. hideMutedNotices: GM_getValue('hideMutedNotices', defaultSettings.hideMutedNotices),
  55. useLargerCSS: GM_getValue('useLargerCSS', defaultSettings.useLargerCSS),
  56. cssWidth: GM_getValue('cssWidth', defaultSettings.cssWidth),
  57. };
  58.  
  59. const language = navigator.language || navigator.userLanguage;
  60. const languages = {
  61. 'en': {
  62. 'hideGrok': 'Hide Grok',
  63. 'hidePremiumSignUp': 'Hide Premium Sign-up',
  64. 'hideSelectors': 'Hide Subscribe Message',
  65. 'hideVerifiedOrgs': 'Hide Verified Orgs',
  66. 'hideExplore': 'Hide Explore',
  67. 'hideNotifications': 'Hide Notifications',
  68. 'hideMessages': 'Hide Messages',
  69. 'hideCommunities': 'Hide Communities',
  70. 'hideBookmarks': 'Hide Bookmarks',
  71. 'hideother': 'Hide other',
  72. 'hideMutedNotices': 'Hide Muted Account Notices',
  73. 'hideRightColumn': 'Hide Right Column',
  74. 'useLargerCSS': 'Larger Post Area',
  75. 'cssWidth': 'Custom width',
  76. 'settings': 'Settings',
  77. 'saveRefresh': 'Save & refresh',
  78. 'close': 'Close'
  79. },
  80. 'zh-TW': {
  81. 'hideGrok': '隱藏 Grok',
  82. 'hidePremiumSignUp': '隱藏 高級訂閱',
  83. 'hideSelectors': '隱藏 訂閱訊息',
  84. 'hideVerifiedOrgs': '隱藏 已認證組織',
  85. 'hideExplore': '隱藏 探索',
  86. 'hideNotifications': '隱藏 通知',
  87. 'hideMessages': '隱藏 訊息',
  88. 'hideCommunities': '隱藏 社群',
  89. 'hideBookmarks': '隱藏 書籤',
  90. 'hideother': '隱藏 其他',
  91. 'hideMutedNotices': '隱藏 靜音帳戶通知',
  92. 'hideRightColumn': '隱藏 右側邊欄',
  93. 'useLargerCSS': '更大貼文區域',
  94. 'cssWidth': '自訂寬度',
  95. 'settings': '設定',
  96. 'saveRefresh': '保存並刷新',
  97. 'close': '關閉'
  98. },
  99. 'zh-CN': {
  100. 'hideGrok': '隐藏 Grok',
  101. 'hidePremiumSignUp': '隐藏 高级订阅',
  102. 'hideSelectors': '隐藏 订阅消息',
  103. 'hideVerifiedOrgs': '隐藏 已认证组织',
  104. 'hideExplore': '隐藏 探索',
  105. 'hideNotifications': '隐藏 通知',
  106. 'hideMessages': '隐藏 私信',
  107. 'hideCommunities': '隐藏 社群',
  108. 'hideBookmarks': '隐藏 书签',
  109. 'hideother': '隐藏 其他',
  110. 'hideMutedNotices': '隐藏 静音账户通知',
  111. 'hideRightColumn': '隐藏 右侧边栏',
  112. 'useLargerCSS': '更大帖子区域',
  113. 'cssWidth': '自定义宽度',
  114. 'settings': '设置',
  115. 'saveRefresh': '保存并刷新',
  116. 'close': '关闭'
  117. },
  118. 'ja': {
  119. 'hideGrok': 'Grokを非表示',
  120. 'hidePremiumSignUp': 'プレミアムサインアップを非表示',
  121. 'hideSelectors': 'サブスクライブメッセージを非表示',
  122. 'hideVerifiedOrgs': '認証済み組織を非表示',
  123. 'hideExplore': '話題を検索を非表示',
  124. 'hideNotifications': '通知を非表示',
  125. 'hideMessages': 'メッセージを非表示',
  126. 'hideCommunities': 'コミュニティを非表示',
  127. 'hideBookmarks': 'ブックマークを非表示',
  128. 'hideother': '他のを非表示',
  129. 'hideMutedNotices': 'ミュートアカウント通知を非表示',
  130. 'hideRightColumn': '右側カラムを非表示',
  131. 'useLargerCSS': 'より大きな投稿エリア',
  132. 'cssWidth': 'カスタム幅',
  133. 'settings': '設定',
  134. 'saveRefresh': '保存して更新',
  135. 'close': '閉じる'
  136. },
  137. };
  138.  
  139. const currentLanguage = languages[language] || languages['en'];
  140.  
  141. function createSettingsPanel() {
  142. const panel = document.createElement('div');
  143. panel.id = 'settingsPanel';
  144. panel.innerHTML = `
  145. <div id="settingsPanelContent">
  146. <div class="settings-header">
  147. <h2>${currentLanguage['settings']}</h2>
  148. </div>
  149.  
  150. <div class="settings-container">
  151. <div class="settings-section">
  152. <label class="toggle-switch">
  153. <input type="checkbox" id="hideGrokCheckbox" ${settings.hideGrok ? 'checked' : ''}>
  154. <span class="toggle-slider"></span>
  155. <span class="toggle-label">${currentLanguage['hideGrok']}</span>
  156. </label>
  157. <label class="toggle-switch">
  158. <input type="checkbox" id="hidePremiumSignUpCheckbox" ${settings.hidePremiumSignUp ? 'checked' : ''}>
  159. <span class="toggle-slider"></span>
  160. <span class="toggle-label">${currentLanguage['hidePremiumSignUp']}</span>
  161. </label>
  162. <label class="toggle-switch">
  163. <input type="checkbox" id="hideSelectorsCheckbox" ${settings.hideSelectors ? 'checked' : ''}>
  164. <span class="toggle-slider"></span>
  165. <span class="toggle-label">${currentLanguage['hideSelectors']}</span>
  166. </label>
  167. <label class="toggle-switch">
  168. <input type="checkbox" id="hideVerifiedOrgsCheckbox" ${settings.hideVerifiedOrgs ? 'checked' : ''}>
  169. <span class="toggle-slider"></span>
  170. <span class="toggle-label">${currentLanguage['hideVerifiedOrgs']}</span>
  171. </label>
  172. <label class="toggle-switch">
  173. <input type="checkbox" id="hideotherCheckbox" ${settings.hideother ? 'checked' : ''}>
  174. <span class="toggle-slider"></span>
  175. <span class="toggle-label">${currentLanguage['hideother']}</span>
  176. </label>
  177. </div>
  178.  
  179. <div class="settings-section">
  180. <label class="toggle-switch">
  181. <input type="checkbox" id="hideExploreCheckbox" ${settings.hideExplore ? 'checked' : ''}>
  182. <span class="toggle-slider"></span>
  183. <span class="toggle-label">${currentLanguage['hideExplore']}</span>
  184. </label>
  185. <label class="toggle-switch">
  186. <input type="checkbox" id="hideNotificationsCheckbox" ${settings.hideNotifications ? 'checked' : ''}>
  187. <span class="toggle-slider"></span>
  188. <span class="toggle-label">${currentLanguage['hideNotifications']}</span>
  189. </label>
  190. <label class="toggle-switch">
  191. <input type="checkbox" id="hideMessagesCheckbox" ${settings.hideMessages ? 'checked' : ''}>
  192. <span class="toggle-slider"></span>
  193. <span class="toggle-label">${currentLanguage['hideMessages']}</span>
  194. </label>
  195. <label class="toggle-switch">
  196. <input type="checkbox" id="hideCommunitiesCheckbox" ${settings.hideCommunities ? 'checked' : ''}>
  197. <span class="toggle-slider"></span>
  198. <span class="toggle-label">${currentLanguage['hideCommunities']}</span>
  199. </label>
  200. <label class="toggle-switch">
  201. <input type="checkbox" id="hideBookmarksCheckbox" ${settings.hideBookmarks ? 'checked' : ''}>
  202. <span class="toggle-slider"></span>
  203. <span class="toggle-label">${currentLanguage['hideBookmarks']}</span>
  204. </label>
  205. </div>
  206.  
  207. <div class="settings-section">
  208. <label class="toggle-switch">
  209. <input type="checkbox" id="hideMutedNoticesCheckbox" ${settings.hideMutedNotices ? 'checked' : ''}>
  210. <span class="toggle-slider"></span>
  211. <span class="toggle-label">${currentLanguage['hideMutedNotices']}</span>
  212. </label>
  213. <label class="toggle-switch">
  214. <input type="checkbox" id="hideRightColumnCheckbox" ${settings.hideRightColumn ? 'checked' : ''}>
  215. <span class="toggle-slider"></span>
  216. <span class="toggle-label">${currentLanguage['hideRightColumn']}</span>
  217. </label>
  218. <label class="toggle-switch">
  219. <input type="checkbox" id="useLargerCSSCheckbox" ${settings.useLargerCSS ? 'checked' : ''}>
  220. <span class="toggle-slider"></span>
  221. <span class="toggle-label">${currentLanguage['useLargerCSS']}</span>
  222. </label>
  223. <div class="width-input-container">
  224. <span class="width-label">${currentLanguage['cssWidth']}</span>
  225. <div class="width-input-wrapper">
  226. <input type="number" id="cssWidthInput" class="width-input" value="${settings.cssWidth}" min="400" max="1200">
  227. <span class="width-unit">px</span>
  228. </div>
  229. </div>
  230. </div>
  231. </div>
  232.  
  233. <div class="buttons-container">
  234. <button id="saveSettingsButton" class="panel-button primary-button">${currentLanguage['saveRefresh']}</button>
  235. <button id="closeSettingsButton" class="panel-button secondary-button">${currentLanguage['close']}</button>
  236. </div>
  237. </div>
  238. `;
  239. document.body.appendChild(panel);
  240. document.getElementById('saveSettingsButton').addEventListener('click', saveSettings);
  241. document.getElementById('closeSettingsButton').addEventListener('click', () => {
  242. document.getElementById('settingsPanel').style.display = 'none';
  243. });
  244.  
  245. document.getElementById('hideRightColumnCheckbox').addEventListener('change', function() {
  246. if (this.checked) {
  247. document.getElementById('useLargerCSSCheckbox').checked = true;
  248. } else {
  249. document.getElementById('useLargerCSSCheckbox').checked = false;
  250. }
  251. });
  252. }
  253.  
  254. function saveSettings() {
  255. settings.hideGrok = document.getElementById('hideGrokCheckbox').checked;
  256. settings.hidePremiumSignUp = document.getElementById('hidePremiumSignUpCheckbox').checked;
  257. settings.hideSelectors = document.getElementById('hideSelectorsCheckbox').checked;
  258. settings.hideVerifiedOrgs = document.getElementById('hideVerifiedOrgsCheckbox').checked;
  259. settings.hideExplore = document.getElementById('hideExploreCheckbox').checked;
  260. settings.hideNotifications = document.getElementById('hideNotificationsCheckbox').checked;
  261. settings.hideBookmarks = document.getElementById('hideBookmarksCheckbox').checked;
  262. settings.hideMessages = document.getElementById('hideMessagesCheckbox').checked;
  263. settings.hideCommunities = document.getElementById('hideCommunitiesCheckbox').checked;
  264. settings.hideother = document.getElementById('hideotherCheckbox').checked;
  265. settings.hideRightColumn = document.getElementById('hideRightColumnCheckbox').checked;
  266. settings.hideMutedNotices = document.getElementById('hideMutedNoticesCheckbox').checked;
  267. settings.useLargerCSS = document.getElementById('useLargerCSSCheckbox').checked;
  268. settings.cssWidth = parseInt(document.getElementById('cssWidthInput').value) || 680;
  269.  
  270. GM_setValue('hideGrok', settings.hideGrok);
  271. GM_setValue('hidePremiumSignUp', settings.hidePremiumSignUp);
  272. GM_setValue('hideSelectors', settings.hideSelectors);
  273. GM_setValue('hideVerifiedOrgs', settings.hideVerifiedOrgs);
  274. GM_setValue('hideExplore', settings.hideExplore);
  275. GM_setValue('hideNotifications', settings.hideNotifications);
  276. GM_setValue('hideBookmarks', settings.hideBookmarks);
  277. GM_setValue('hideMessages', settings.hideMessages);
  278. GM_setValue('hideCommunities', settings.hideCommunities);
  279. GM_setValue('hideother', settings.hideother);
  280. GM_setValue('hideRightColumn', settings.hideRightColumn);
  281. GM_setValue('hideMutedNotices', settings.hideMutedNotices);
  282. GM_setValue('useLargerCSS', settings.useLargerCSS);
  283. GM_setValue('cssWidth', settings.cssWidth);
  284. location.reload();
  285. }
  286.  
  287. GM_addStyle(`
  288. #settingsPanel {
  289. width: 90%;
  290. max-width: 800px;
  291. min-width: 300px;
  292. position: fixed;
  293. top: 50%;
  294. left: 50%;
  295. transform: translate(-50%, -50%);
  296. background-color: #ffffff;
  297. border: none;
  298. padding: 0;
  299. z-index: 10000;
  300. display: none;
  301. box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  302. border-radius: 16px;
  303. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  304. overflow: hidden;
  305. }
  306.  
  307. #settingsPanelContent {
  308. display: flex;
  309. flex-direction: column;
  310. width: 100%;
  311. }
  312.  
  313. .settings-header {
  314. display: flex;
  315. justify-content: center;
  316. align-items: center;
  317. padding: 16px 20px;
  318. border-bottom: 1px solid rgba(0,0,0,0.08);
  319. }
  320.  
  321. #settingsPanel h2 {
  322. margin: 0;
  323. font-size: 18px;
  324. font-weight: 700;
  325. color: #0f1419;
  326. text-align: center;
  327. }
  328.  
  329. .settings-container {
  330. display: flex;
  331. justify-content: space-between;
  332. padding: 12px 20px;
  333. flex-wrap: wrap;
  334. border-bottom: 1px solid rgba(0,0,0,0.08);
  335. }
  336.  
  337. .settings-section {
  338. flex: 1;
  339. min-width: 200px;
  340. padding: 0 10px;
  341. }
  342.  
  343. .toggle-switch {
  344. position: relative;
  345. display: flex;
  346. align-items: center;
  347. margin: 12px 0;
  348. padding: 6px 0;
  349. cursor: pointer;
  350. }
  351.  
  352. .toggle-switch:first-child {
  353. border-top: none;
  354. }
  355.  
  356. .toggle-switch input {
  357. opacity: 0;
  358. width: 0;
  359. height: 0;
  360. }
  361.  
  362. .toggle-slider {
  363. position: relative;
  364. display: inline-block;
  365. width: 42px;
  366. height: 24px;
  367. background-color: #cfd9de;
  368. border-radius: 24px;
  369. transition: .3s;
  370. margin-right: 12px;
  371. flex-shrink: 0;
  372. }
  373.  
  374. .toggle-slider:before {
  375. position: absolute;
  376. content: "";
  377. height: 18px;
  378. width: 18px;
  379. left: 3px;
  380. bottom: 3px;
  381. background-color: white;
  382. border-radius: 50%;
  383. transition: .3s;
  384. }
  385.  
  386. input:checked + .toggle-slider {
  387. background-color: #1d9bf0;
  388. }
  389.  
  390. input:checked + .toggle-slider:before {
  391. transform: translateX(18px);
  392. }
  393.  
  394. .toggle-label {
  395. font-size: 15px;
  396. color: #0f1419;
  397. }
  398.  
  399. .buttons-container {
  400. display: flex;
  401. justify-content: center;
  402. padding: 16px 20px;
  403. gap: 10px;
  404. border-top: 1px solid rgba(0,0,0,0.08);
  405. }
  406.  
  407. .panel-button {
  408. flex: 1;
  409. padding: 12px 0;
  410. font-size: 15px;
  411. font-weight: 600;
  412. border: none;
  413. border-radius: 9999px;
  414. cursor: pointer;
  415. transition: background-color 0.2s;
  416. text-align: center;
  417. }
  418.  
  419. .primary-button {
  420. color: white;
  421. background-color: #1d9bf0;
  422. }
  423.  
  424. .primary-button:hover {
  425. background-color: #1a8cd8;
  426. }
  427.  
  428. .secondary-button {
  429. color: #0f1419;
  430. background-color: #e6e7e7;
  431. }
  432.  
  433. .secondary-button:hover {
  434. background-color: #d1d1d1;
  435. }
  436.  
  437. .width-input-container {
  438. display: flex;
  439. align-items: center;
  440. justify-content: center;
  441. margin: 12px 0;
  442. padding: 25px 0;
  443. }
  444.  
  445. .width-label {
  446. font-size: 15px;
  447. color: #0f1419;
  448. flex-grow: 0.1;
  449. }
  450.  
  451. .width-input-wrapper {
  452. position: relative;
  453. display: flex;
  454. align-items: center;
  455. }
  456.  
  457. .width-input {
  458. width: 90px;
  459. padding: 8px 30px 8px 12px;
  460. border: 1px solid #cfd9de;
  461. border-radius: 9999px;
  462. font-size: 14px;
  463. transition: border-color 0.2s;
  464. text-align: center;
  465. }
  466.  
  467. .width-input:focus {
  468. outline: none;
  469. border-color: #1d9bf0;
  470. box-shadow: 0 0 0 1px rgba(29, 155, 240, 0.3);
  471. }
  472.  
  473. .width-unit {
  474. position: absolute;
  475. right: 12px;
  476. font-size: 14px;
  477. color: #536471;
  478. pointer-events: none;
  479. }
  480.  
  481. .width-input::-webkit-inner-spin-button,
  482. .width-input::-webkit-outer-spin-button {
  483. -webkit-appearance: none;
  484. margin: 0;
  485. }
  486.  
  487. .width-input[type=number] {
  488. -moz-appearance: textfield;
  489. }
  490. `);
  491.  
  492. createSettingsPanel();
  493. GM_registerMenuCommand(currentLanguage['settings'], () => {
  494. const panel = document.getElementById('settingsPanel');
  495. panel.style.display = 'block';
  496. });
  497.  
  498. function addGlobalStyle(css) {
  499. var head, style;
  500. head = document.getElementsByTagName('head')[0];
  501. if (!head) { return; }
  502. style = document.createElement('style');
  503. style.type = 'text/css';
  504. style.innerHTML = css;
  505. head.appendChild(style);
  506. }
  507.  
  508. var cssRules = '';
  509.  
  510. if (settings.hideSelectors) {
  511. const observer = new MutationObserver(mutations => {
  512. mutations.forEach(mutation => {
  513. const elements = document.querySelectorAll('.css-175oi2r.r-1habvwh.r-eqz5dr.r-uaa2di.r-1mmae3n.r-3pj75a.r-bnwqim');
  514. elements.forEach(element => {
  515. const parentDiv = element.closest('div');
  516. if (parentDiv) {
  517. parentDiv.remove();
  518. }
  519. });
  520.  
  521. 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"]');
  522. verifiedUpsell.forEach(element => {
  523. const parentDiv = element.closest('div');
  524. if (parentDiv) {
  525. parentDiv.remove();
  526. } else {
  527. element.remove();
  528. }
  529. });
  530. });
  531. });
  532. observer.observe(document.body, { childList: true, subtree: true });
  533.  
  534. GM_addStyle(`
  535. .css-175oi2r.r-1xpp3t0 { display: none !important; }
  536. `);
  537. }
  538.  
  539. if (settings.hideGrok) {
  540. 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";
  541. 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";
  542. const observer = new MutationObserver(mutations => {
  543. mutations.forEach(mutation => {
  544. const svgs = document.querySelectorAll('svg[aria-hidden="true"].r-4qtqp9');
  545. svgs.forEach(svg => {
  546. const path = svg.querySelector('path');
  547. if (path && path.getAttribute('d') === targetPathD) {
  548. const container = svg.closest('button') || svg.closest('div');
  549. if (container) {
  550. container.remove();
  551. }
  552. }
  553. });
  554.  
  555. const grokImgGenButtons = document.querySelectorAll('button[data-testid="grokImgGen"]');
  556. grokImgGenButtons.forEach(button => {
  557. button.remove();
  558. });
  559. });
  560. });
  561. observer.observe(document.body, { childList: true, subtree: true });
  562.  
  563. GM_addStyle(`
  564. a[href="/i/grok"] { display: none !important; }
  565. .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; }
  566. .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; }
  567. .css-175oi2r.r-1s2bzr4.r-dnmrzs.r-bnwqim { display: none; }
  568. `);
  569. }
  570.  
  571. if (settings.hideCommunities) {
  572. 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";
  573. const observerCommunities = new MutationObserver(mutations => {
  574. mutations.forEach(() => {
  575. const svgs = document.querySelectorAll('svg[aria-hidden="true"].r-4qtqp9');
  576. svgs.forEach(svg => {
  577. const path = svg.querySelector('path');
  578. if (path && path.getAttribute('d') === targetCommunitiesPathD) {
  579. const container = svg.closest('a') || svg.closest('div');
  580. if (container) {
  581. container.remove();
  582. }
  583. }
  584. });
  585. });
  586. });
  587. observerCommunities.observe(document.body, { childList: true, subtree: true });
  588. }
  589.  
  590. if (settings.hidePremiumSignUp) {
  591. cssRules += 'a[href="/i/premium_sign_up"] { display: none !important; }';
  592. }
  593. if (settings.hideVerifiedOrgs) {
  594. cssRules += 'a[href="/i/verified-orgs-signup"] { display: none !important; }';
  595. }
  596. if (settings.hideother) {
  597. cssRules += 'a[href="/jobs"] { display: none !important; }';
  598. cssRules += '.css-175oi2r.r-l00any.r-109y4c4.r-kuekak { display: none !important; }';
  599. 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; }';
  600. 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; }';
  601. }
  602. if (settings.hideExplore) {
  603. cssRules += 'a[href="/explore"] { display: none !important; }';
  604. }
  605. if (settings.hideNotifications) {
  606. cssRules += 'a[href="/notifications"] { display: none !important; }';
  607. }
  608. if (settings.hideBookmarks) {
  609. cssRules += 'a[href="/i/bookmarks"] { display: none !important; }';
  610. }
  611. if (settings.hideMessages) {
  612. cssRules += 'a[href="/messages"] { display: none !important; }';
  613. }
  614. if (settings.hideRightColumn) {
  615. cssRules += '.css-175oi2r.r-yfoy6g.r-18bvks7.r-1867qdf.r-1phboty.r-rs99b7.r-1ifxtd0.r-1udh08x { display: none !important; }';
  616. cssRules += '.css-175oi2r.r-18bvks7.r-1867qdf.r-1phboty.r-1ifxtd0.r-1udh08x.r-1niwhzg.r-1yadl64 { display: none !important; }';
  617. }
  618. if (settings.useLargerCSS) {
  619. cssRules += `.r-1ye8kvj { max-width: ${settings.cssWidth}px !important; }`;
  620. cssRules += '.r-10f7w94 { margin-right: 0px !important; }';
  621. }
  622.  
  623. if (settings.hideMutedNotices) {
  624. function hideMutedPostNotices() {
  625. const replyCells = document.querySelectorAll('[data-testid="cellInnerDiv"]');
  626. replyCells.forEach((cell) => {
  627. 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');
  628. mutedNotices.forEach((notice) => {
  629. const parentCell = notice.closest('[data-testid="cellInnerDiv"]');
  630. if (parentCell) {
  631. parentCell.remove();
  632. }
  633. });
  634. });
  635. }
  636.  
  637. const observer = new MutationObserver(() => {
  638. hideMutedPostNotices();
  639. });
  640. observer.observe(document.body, { childList: true, subtree: true });
  641. hideMutedPostNotices();
  642. }
  643.  
  644. addGlobalStyle(cssRules);
  645. })();

QingJ © 2025

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