YouTube Ultimate Enhancer

Melhora a pesquisa, layout e funcionalidades do YouTube.

  1. // ==UserScript==
  2. // @name YouTube Ultimate Enhancer
  3. // @namespace YouTube Ultimate Enhancer
  4. // @version 1.3
  5. // @description Melhora a pesquisa, layout e funcionalidades do YouTube.
  6. // @author You
  7. // @match *://www.youtube.com/*
  8. // @grant GM_addStyle
  9. // @run-at document-start
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Função para criar botões de controle
  17. const createToggleButton = (id, label, defaultVisible) => {
  18. const button = document.createElement('button');
  19. button.id = id;
  20. button.textContent = label;
  21. button.style.position = 'fixed';
  22. button.style.bottom = '20px';
  23. button.style.right = '20px';
  24. button.style.zIndex = '1000';
  25. button.style.padding = '10px 20px';
  26. button.style.backgroundColor = '#ff0000';
  27. button.style.color = '#fff';
  28. button.style.border = 'none';
  29. button.style.borderRadius = '5px';
  30. button.style.cursor = 'pointer';
  31. button.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1)';
  32. document.body.appendChild(button);
  33.  
  34. const targetElement = document.querySelector(id === 'toggle-sidebar' ? '#secondary' : 'ytd-comments');
  35. if (targetElement) {
  36. targetElement.style.display = defaultVisible ? 'block' : 'none';
  37. }
  38.  
  39. button.addEventListener('click', () => {
  40. if (targetElement) {
  41. const isVisible = targetElement.style.display === 'block';
  42. targetElement.style.display = isVisible ? 'none' : 'block';
  43. button.textContent = isVisible ? `Mostrar ${label}` : `Esconder ${label}`;
  44. }
  45. });
  46. };
  47.  
  48. // Forçar pesquisa limpa e adicionar filtros
  49. const forceCleanSearch = () => {
  50. const searchParams = new URLSearchParams(window.location.search);
  51. if (searchParams.has('search_query')) {
  52. searchParams.delete('sp');
  53. searchParams.set('sp', 'EgIQAQ%3D%3D'); // Resultados exatos
  54. searchParams.set('sp', 'EgIIAQ%3D%3D'); // Vídeos curtos
  55. const newUrl = `${window.location.pathname}?${searchParams.toString()}`;
  56. window.history.replaceState(null, null, newUrl);
  57. }
  58. };
  59.  
  60. // Layout melhorado
  61. const improvedLayout = () => {
  62. GM_addStyle(`
  63. /* Layout principal */
  64. #primary.ytd-page-manager {
  65. max-width: 1400px !important;
  66. margin: 0 auto !important;
  67. padding: 20px !important;
  68. }
  69.  
  70. /* Grade de vídeos melhorada */
  71. ytd-rich-grid-row {
  72. display: grid !important;
  73. grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
  74. gap: 20px !important;
  75. padding: 15px 0 !important;
  76. }
  77.  
  78. /* Pesquisa aprimorada */
  79. ytd-searchbox {
  80. max-width: 800px !important;
  81. margin: 0 auto !important;
  82. }
  83.  
  84. /* Remover elementos desnecessários */
  85. ytd-banner-promo-renderer,
  86. ytd-rich-shelf-renderer,
  87. #masthead-container,
  88. #container.ytd-masthead {
  89. display: none !important;
  90. }
  91.  
  92. /* Miniaturas maiores */
  93. ytd-thumbnail {
  94. width: 100% !important;
  95. height: 180px !important;
  96. border-radius: 12px !important;
  97. transition: transform 0.2s ease !important;
  98. }
  99. ytd-thumbnail:hover {
  100. transform: scale(1.05) !important;
  101. }
  102.  
  103. /* Tipografia melhorada */
  104. #video-title {
  105. font-size: 1.6rem !important;
  106. color: #333 !important;
  107. font-family: 'Arial', sans-serif !important;
  108. }
  109. yt-formatted-string.ytd-video-renderer {
  110. color: #666 !important;
  111. }
  112.  
  113. /* Player de vídeo */
  114. video.html5-main-video {
  115. width: 100% !important;
  116. height: auto !important;
  117. }
  118. .ytp-chrome-top {
  119. display: none !important;
  120. }
  121.  
  122. /* Botões com bordas 3D realçadas */
  123. .ytp-button {
  124. background-color: #ff0000 !important;
  125. border-radius: 50% !important;
  126. border: 2px solid #fff !important;
  127. box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2) !important;
  128. }
  129.  
  130. /* Responsividade */
  131. @media (max-width: 768px) {
  132. ytd-rich-grid-row {
  133. grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
  134. }
  135. #primary.ytd-page-manager {
  136. padding: 10px !important;
  137. }
  138. }
  139.  
  140. /* Remover anúncios */
  141. ytd-promoted-sparkles-web-renderer,
  142. ytd-promoted-video-renderer {
  143. display: none !important;
  144. }
  145. `);
  146. };
  147.  
  148. // Função para inicializar o script
  149. const initializeScript = () => {
  150. forceCleanSearch();
  151. improvedLayout();
  152. createToggleButton('toggle-sidebar', 'Esconder Barra Lateral', false);
  153. createToggleButton('toggle-comments', 'Esconder Comentários', false);
  154. };
  155.  
  156. // Executar inicialmente
  157. initializeScript();
  158.  
  159. // Observar mudanças dinâmicas
  160. const observer = new MutationObserver((mutations) => {
  161. mutations.forEach((mutation) => {
  162. if (mutation.type === 'childList') {
  163. initializeScript();
  164. }
  165. });
  166. });
  167.  
  168. observer.observe(document.body, {
  169. childList: true,
  170. subtree: true
  171. });
  172.  
  173. // Usar window.navigation API para detectar mudanças de rota
  174. if (window.navigation) {
  175. window.navigation.addEventListener('navigate', (event) => {
  176. initializeScript();
  177. });
  178. }
  179. })();

QingJ © 2025

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