X/Twitter Display Settings Sidebar Button

Adds back the button for display settings in the sidebar, changing simple colours shouldn't need cost money, Elon.

  1. // ==UserScript==
  2. // @name X/Twitter Display Settings Sidebar Button
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description Adds back the button for display settings in the sidebar, changing simple colours shouldn't need cost money, Elon.
  6. // @author Lupo01 (Y0ICHI)
  7. // @license MIT
  8. // @match https://x.com/*
  9. // @match https://twitter.com/*
  10. // @icon https://abs.twimg.com/favicons/twitter.3.ico
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. const SELECTORS = {
  18. SIDEBAR: 'nav[aria-label="Primary"][role="navigation"]',
  19. MORE_BUTTON: 'button[data-testid="AppTabBar_More_Menu"]',
  20. LINK_TEMPLATE: 'a[href*="/i/bookmarks"], a[href*="/Lupo01_/communities"]'
  21. };
  22.  
  23. function init() {
  24. const observer = new MutationObserver(() => {
  25. const sidebar = document.querySelector(SELECTORS.SIDEBAR);
  26. const moreButton = document.querySelector(SELECTORS.MORE_BUTTON);
  27. const templateLink = document.querySelector(SELECTORS.LINK_TEMPLATE);
  28.  
  29. if (sidebar && moreButton && templateLink && !document.getElementById('display-settings-button')) {
  30. observer.disconnect();
  31. addDisplaySettingsButton(sidebar, moreButton, templateLink);
  32. }
  33. });
  34.  
  35. observer.observe(document.body, {childList: true, subtree: true});
  36. setTimeout(() => observer.disconnect(), 10000);
  37. }
  38.  
  39. function addDisplaySettingsButton(sidebar, moreButton, templateLink) {
  40. const displayButton = templateLink.cloneNode(true);
  41. displayButton.id = 'display-settings-button';
  42. displayButton.href = '/settings/display';
  43. displayButton.removeAttribute('data-testid');
  44. displayButton.removeAttribute('aria-selected');
  45.  
  46. // Modifica il testo
  47. const textSpan = displayButton.querySelector('[dir="ltr"] span');
  48. if (textSpan) {
  49. textSpan.textContent = 'Display Settings';
  50. }
  51.  
  52. // Modifica l'icona
  53. const iconContainer = displayButton.querySelector('svg').parentElement;
  54. iconContainer.innerHTML = `
  55. <svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-dnmrzs r-bnwqim r-lrvibr r-m6rgpd r-1nao33i r-lwhw9o r-cnnz9e">
  56. <g>
  57. <path d="M10.54 1.75h2.92l1.57 2.36c.11.17.32.25.53.21l2.53-.59 2.17 2.17-.58 2.54c-.05.2.04.41.21.53l2.36 1.57v2.92l-2.36 1.57c-.17.12-.26.33-.21.53l.58 2.54-2.17 2.17-2.53-.59c-.21-.04-.42.04-.53.21l-1.57 2.36h-2.92l-1.58-2.36c-.11-.17-.32-.25-.52-.21l-2.54.59-2.17-2.17.58-2.54c.05-.2-.03-.41-.21-.53l-2.35-1.57v-2.92L4.1 8.97c.18-.12.26-.33.21-.53L3.73 5.9 5.9 3.73l2.54.59c.2.04.41-.04.52-.21l1.58-2.36zm1.07 2l-.98 1.47C10.05 6.08 9 6.5 7.99 6.27l-1.46-.34-.6.6.33 1.46c.24 1.01-.18 2.07-1.05 2.64l-1.46.98v.78l1.46.98c.87.57 1.29 1.63 1.05 2.64l-.33 1.46.6.6 1.46-.34c1.01-.23 2.06.19 2.64 1.05l.98 1.47h.78l.97-1.47c.58-.86 1.63-1.28 2.65-1.05l1.45.34.61-.6-.34-1.46c-.23-1.01.18-2.07 1.05-2.64l1.47-.98v-.78l-1.47-.98c-.87-.57-1.28-1.63-1.05-2.64l.34-1.46-.61-.6-1.45.34c-1.02.23-2.07-.19-2.65-1.05l-.97-1.47h-.78zM12 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5c.82 0 1.5-.67 1.5-1.5s-.68-1.5-1.5-1.5zM8.5 12c0-1.93 1.56-3.5 3.5-3.5 1.93 0 3.5 1.57 3.5 3.5s-1.57 3.5-3.5 3.5c-1.94 0-3.5-1.57-3.5-3.5z"></path>
  58. </g>
  59. </svg>
  60. `;
  61.  
  62. // Inserisci prima del pulsante "More"
  63. moreButton.parentElement.insertBefore(displayButton, moreButton);
  64.  
  65. // Aggiungi stili per l'hover
  66. displayButton.style.transition = 'background-color 0.2s';
  67. displayButton.addEventListener('mouseover', () => {
  68. displayButton.style.backgroundColor = 'rgba(231, 233, 234, 0.1)';
  69. });
  70. displayButton.addEventListener('mouseout', () => {
  71. displayButton.style.backgroundColor = 'transparent';
  72. });
  73. }
  74.  
  75. // Avvia lo script
  76. init();
  77.  
  78. // Gestione SPA
  79. let currentPath = location.pathname;
  80. setInterval(() => {
  81. if (location.pathname !== currentPath) {
  82. currentPath = location.pathname;
  83. setTimeout(init, 500);
  84. }
  85. }, 100);
  86. })();

QingJ © 2025

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