YouTube ئاۋاز يېزىلىشنى قايتا توغرىلاش

يۇتۇب ۋىدىئولارىدىكى ئاپتوماتىك تەرجىمە قىلىنغان، ياراتىلغان ئاۋازلارنى ئايرىپ قويىدۇ. ئەسلى ئاۋازغا قايتۇرۇلىدۇ.

  1. // ==UserScript==
  2. // @name YouTube Audiotrack Reset
  3. // @name:zh-TW YouTube 音軌重置
  4. // @name:zh-HK YouTube 音軌重置
  5. // @name:zh-CN YouTube 音轨重置
  6. // @name:ja YouTube オーディオトラックリセット
  7. // @name:kr YouTube 오디오트랙 리셋
  8. // @name:ar YouTube إعادة تعيين المسار الصوتي
  9. // @name:bg YouTube Нулиране на аудио пистата
  10. // @name:cs YouTube Reset audio stopy
  11. // @name:da YouTube Nulstil lydspor
  12. // @name:de YouTube Audiotrack zurücksetzen
  13. // @name:tel YouTube ఆడియో ట్రాక్ రీసెట్
  14. // @name:es YouTube Restablecer pista de audio
  15. // @name:en YouTube Audiotrack Reset
  16. // @name:fr YouTube Réinitialiser la piste audio
  17. // @name:fr-CA YouTube Réinitialiser la piste audio
  18. // @name:he YouTube לאפס את מסלול האודיו
  19. // @name:hu YouTube Audio nyomvonal visszaállítása
  20. // @name:id YouTube Reset trek audio
  21. // @name:it YouTube Reimposta traccia audio
  22. // @name:ko YouTube 오디오 트랙 재설정
  23. // @name:nb YouTube Tilbakestill lydspor
  24. // @name:nl YouTube Audiotrack resetten
  25. // @name:pl YouTube Resetuj ścieżkę audio
  26. // @name:pt-BR YouTube Resetar trilha de áudio
  27. // @name:ro YouTube Resetare pistă audio
  28. // @name:ru YouTube Сброс аудиотрека
  29. // @name:sk YouTube Obnovenie zvukovej stopy
  30. // @name:sr YouTube Resetovanje audio trake
  31. // @name:sv YouTube Återställ ljudspår
  32. // @name:th YouTube รีเซ็ตแทร็กเสียง
  33. // @name:tr YouTube Ses parçasını sıfırlama
  34. // @name:uk YouTube Скинути аудіотрек
  35. // @name:ug YouTube ئاۋاز يېزىلىشنى قايتا توغرىلاش
  36. // @name:vi YouTube Đặt lại bản nhạc âm thanh
  37. // @version 0.1.5
  38. // @description Overrides automatic use of generated, translated audiotracks on YouTube videos. Resets to original audio.
  39. // @description:zh-TW 覆蓋YouTube視頻上自動生成的翻譯音軌。重置為原始音軌。
  40. // @description:zh-HK 覆蓋YouTube視頻上自動生成的翻譯音軌。重置為原始音軌。
  41. // @description:zh-CN 覆盖YouTube视频上自动生成的翻译音轨。重置为原始音轨。
  42. // @description:ja YouTube動画の自動生成された翻訳音声トラックを上書きします。元の音声にリセットします。
  43. // @description:kr YouTube 비디오에서 자동으로 생성된 번역된 오디오 트랙을 덮어씁니다. 원래 오디오로 재설정합니다.
  44. // @description:ar يتجاوز الاستخدام التلقائي للمسارات الصوتية المترجمة المولدة على مقاطع الفيديو الخاصة بـ YouTube. يعيد تعيين الصوت الأصلي.
  45. // @description:bg Пренаписва автоматичното използване на генерирани преведени аудиотреки в YouTube видеа. Нулира до оригиналния звук.
  46. // @description:cs Přepisuje automatické použití generovaných přeložených zvukových stop u videí YouTube. Resetuje na původní zvuk.
  47. // @description:da Omgår automatisk brug af genererede, oversatte lydspor på YouTube-videoer. Nulstiller til original lyd.
  48. // @description:de Überschreibt die automatische Verwendung von generierten, übersetzten Audiotracks in YouTube-Videos. Setzt auf den Originalton zurück.
  49. // @description:tel YouTube వీడియోలపై స్వయంచాలకంగా ఉత్పత్తి చేసిన అనువాద ఆడియో ట్రాక్స్‌ని ఓవర్‌రైడ్ చేస్తుంది. మౌలిక ఆడియోకి రీసెట్ చేస్తుంది.
  50. // @description:es Sobrescribe el uso automático de pistas de audio generadas y traducidas en videos de YouTube. Restablece el audio original.
  51. // @description:en Overrides automatic use of generated, translated audiotracks on YouTube videos. Resets to original audio.
  52. // @description:fr Remplace l'utilisation automatique des pistes audio générées et traduites dans les vidéos YouTube. Réinitialise l'audio original.
  53. // @description:fr-CA Remplace l'utilisation automatique des pistes audio générées et traduites dans les vidéos YouTube. Réinitialise l'audio original.
  54. // @description:he עוקף את השימוש האוטומטי במסלולי אודיו מתורגמים שנוצרו בסרטוני YouTube. מחזיר לאודיו המקורי.
  55. // @description:hu Felülírja a YouTube videók automatikusan generált, lefordított audiótracks használatát. Visszaállítja az eredeti hangot.
  56. // @description:id Menggantikan penggunaan otomatis trek audio terjemahan yang dihasilkan pada video YouTube. Mengatur ulang ke audio asli.
  57. // @description:it Sovrascrive l'uso automatico delle tracce audio tradotte generate nei video di YouTube. Ripristina l'audio originale.
  58. // @description:ko YouTube 비디오에서 자동 생성된 번역된 오디오 트랙의 자동 사용을 덮어씁니다. 원래 오디오로 재설정합니다.
  59. // @description:nb Omgår automatisk bruk av genererte, oversatte lydspor på YouTube-videoer. Tilbakestiller til original lyd.
  60. // @description:nl Overschrijft automatisch gebruik van gegenereerde, vertaalde audiotracks op YouTube-video's. Zet terug naar het originele geluid.
  61. // @description:pl Nadpisuje automatyczne użycie generowanych, przetłumaczonych ścieżek dźwiękowych w filmach YouTube. Resetuje do oryginalnego dźwięku.
  62. // @description:pt-BR Substitui o uso automático de faixas de áudio geradas e traduzidas nos vídeos do YouTube. Restaura para o áudio original.
  63. // @description:ro Suprascrie utilizarea automată a pieselor audio traduse generate pe videoclipurile YouTube. Resetează la audio original.
  64. // @description:ru Перезаписывает автоматическое использование сгенерированных переведенных аудиотреков в видео на YouTube. Возвращает к оригинальному аудио.
  65. // @description:sk Prepisuje automatické použitie generovaných preložených zvukových stôp na videách YouTube. Resetuje na pôvodný zvuk.
  66. // @description:sr Prepisuje automatsko korišćenje generisanih, prevedenih audio traka na YouTube video zapisima. Vraća na originalni zvuk.
  67. // @description:sv Överskriver automatisk användning av genererade översatta ljudspår på YouTube-videor. Återställer till original ljud.
  68. // @description:th แทนที่การใช้แทร็กเสียงที่แปลและสร้างโดยอัตโนมัติในวิดีโอ YouTube รีเซ็ตเป็นเสียงต้นฉบับ
  69. // @description:tr YouTube videolarındaki otomatik olarak oluşturulmuş, çevrilmiş ses izlerinin kullanımını geçersiz kılar. Orijinal sesine sıfırlar.
  70. // @description:uk Перезаписує автоматичне використання згенерованих, переведених аудіотреків на відео YouTube. Скидає до оригінального аудіо.
  71. // @description:ug يۇتۇب ۋىدىئولارىدىكى ئاپتوماتىك تەرجىمە قىلىنغان، ياراتىلغان ئاۋازلارنى ئايرىپ قويىدۇ. ئەسلى ئاۋازغا قايتۇرۇلىدۇ.
  72. // @description:vi Ghi đè việc sử dụng tự động các bản nhạc âm thanh đã được tạo và dịch trên video YouTube. Đặt lại về âm thanh gốc.
  73. // @author PolyMegos (https://github.com/polymegos)
  74. // @namespace https://github.com/polymegos/yt-original-audiotrack/
  75. // @supportURL https://github.com/polymegos/yt-original-audiotrack/issues
  76. // @license MIT
  77. // @match *://www.youtube.com/*
  78. // @match *://www.youtube-nocookie.com/*
  79. // @match *://m.youtube.com/*
  80. // @match *://music.youtube.com/*
  81. // @grant none
  82. // @run-at document-start
  83. // @compatible firefox
  84. // @compatible edge
  85. // @compatible safari
  86. // ==/UserScript==
  87.  
  88. (function() {
  89. 'use strict';
  90.  
  91. function redirectToDesktop() {
  92. // Check if we're on m.youtube.com or in a mobile setting
  93. const isMobile = window.location.hostname === 'm.youtube.com' ||
  94. (window.location.hostname === 'www.youtube.com' &&
  95. (document.documentElement.classList.contains('mobile')));
  96. // Look whether desktop param already in URL
  97. const hasDesktopParam = window.location.search.includes('app=desktop');
  98. if (isMobile && !hasDesktopParam) {
  99. // Appending desktop parameter for new URL
  100. let newUrl = window.location.href;
  101. if (newUrl.includes('?')) {
  102. newUrl += '&app=desktop';
  103. } else {
  104. newUrl += '?app=desktop';
  105. }
  106. // Redirect to desktop version
  107. console.log('Redirecting to desktop version of YouTube...');
  108. window.location.href = newUrl;
  109. return true; // redirect
  110. }
  111. return false; // no redirect needed
  112. }
  113.  
  114. // Wait for an element to appear in the DOM
  115. function waitForElement(selector, timeout = 10000) {
  116. return new Promise((resolve, reject) => {
  117. const element = document.querySelector(selector);
  118. if (element) return resolve(element);
  119. const observer = new MutationObserver((mutations, obs) => {
  120. const target = document.querySelector(selector);
  121. if (target) {
  122. obs.disconnect();
  123. resolve(target);
  124. }
  125. });
  126. observer.observe(document.body, { childList: true, subtree: true });
  127. setTimeout(() => {
  128. observer.disconnect();
  129. reject(new Error(`Timeout: Element ${selector} not found within ${timeout}ms`));
  130. }, timeout);
  131. });
  132. }
  133.  
  134. // Simulate a click on the given element
  135. function clickElement(element) {
  136. if (element) {
  137. element.click();
  138. }
  139. }
  140.  
  141. // Wait until no ad shown
  142. function waitForNoAds(timeout = 10000) {
  143. return new Promise((resolve, reject) => {
  144. const player = document.querySelector('.html5-video-player');
  145. if (!player || !player.classList.contains('ad-showing')) return resolve();
  146. const observer = new MutationObserver((mutations, obs) => {
  147. if (!player.classList.contains('ad-showing')) {
  148. obs.disconnect();
  149. resolve();
  150. }
  151. });
  152. observer.observe(player, { attributes: true, attributeFilter: ['class'] });
  153. setTimeout(() => {
  154. observer.disconnect();
  155. reject(new Error('Timeout: Ad still showing.'));
  156. }, timeout);
  157. });
  158. }
  159.  
  160. // Main function to reset the audiotrack
  161. async function checkAudiotrack() {
  162. try {
  163. if (redirectToDesktop()) {
  164. return; // Early return to redirect to desktop view
  165. }
  166.  
  167. // Wait for the video element and ensure no ad is playing
  168. await waitForElement('video');
  169. await waitForNoAds();
  170.  
  171. // Open the settings menu
  172. const settingsButton = await waitForElement('.ytp-settings-button');
  173. clickElement(settingsButton);
  174. const settingsMenu = await waitForElement('.ytp-popup.ytp-settings-menu');
  175.  
  176. // Find and click the "Audiotrack" item
  177. const audioTrackItem = Array.from(settingsMenu.querySelectorAll('.ytp-menuitem'))
  178. .find(item => item.textContent.includes('Audiotrack'));
  179.  
  180. if (audioTrackItem) {
  181. clickElement(audioTrackItem);
  182.  
  183. // Wait for the audiotrack submenu to appear
  184. const audioTrackMenu = await waitForElement('.ytp-popup.ytp-settings-menu');
  185.  
  186. // Click the "Original" option
  187. const originalOption = Array.from(audioTrackMenu.querySelectorAll('.ytp-menuitem'))
  188. .find(item => item.textContent.toLowerCase().includes('original'));
  189.  
  190. if (originalOption) {
  191. clickElement(originalOption);
  192. } else {
  193. console.warn('"Original" audiotrack not found.');
  194. }
  195. // Close settings menu
  196. clickElement(settingsButton);
  197. } else {
  198. console.warn('Audiotrack menu not found.');
  199. // Close half-open settings menu
  200. clickElement(settingsButton);
  201. }
  202. } catch (error) {
  203. console.error('Error in script:', error);
  204. }
  205. }
  206.  
  207. // Initial trigger on page load
  208. checkAudiotrack();
  209.  
  210. // Re-run the script after SPA navigation events (when switching videos)
  211. document.addEventListener('yt-navigate-finish', () => {
  212. checkAudiotrack();
  213. });
  214. })();