🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

YouTube Prevent Auto-Dub

Forces all YouTube videos to play in their original language audio instead of the AI dubbed language. Works in both normal videos and shorts. Can be manually overridden per-video.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name                YouTube Prevent Auto-Dub
// @name:zh-TW          YouTube 防止自動配音
// @name:zh-CN          YouTube 防止自动配音
// @name:ja             YouTube 自動吹き替え防止
// @icon                https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @author              ElectroKnight22
// @namespace           electroknight22_prevent_auto_dub_namespace
// @version             0.2.6
// @match               *://www.youtube.com/*
// @match               *://m.youtube.com/*
// @match               *://www.youtube-nocookie.com/*
// @exclude             *://www.youtube.com/live_chat*
// @require             https://update.greasyfork.org/scripts/549881/1698944/YouTube%20Helper%20API.js
// @run-at              document-idle
// @grant               none
// @inject-into         page
// @license             MIT
// @description         Forces all YouTube videos to play in their original language audio instead of the AI dubbed language. Works in both normal videos and shorts. Can be manually overridden per-video.
// @description:zh-TW   強制所有 YouTube 影片以原始語言音訊播放,而不是 AI 配音的語言。適用於一般影片和 Shorts。可針對單一影片手動關閉。
// @description:zh-CN   强制所有 YouTube 视频以原始语言音频播放,而不是 AI 配音的语言。适用于一般视频和 Shorts。可针对单个视频手动关闭。
// @description:ja      すべてのYouTube動画をAI吹き替えではなく、元の言語の音声で強制的に再生します。通常の動画とショート動画の両方で機能します。動画ごとに手動で無効にすることもできます。
// ==/UserScript==

/*jshint esversion: 11 */
/* global youtubeHelperApi */

(function () {
    'use strict';

    const api = youtubeHelperApi;
    if (!api) return console.error('Helper API not found. Likely incompatible script manager or extension settings.');

    let canUpdate = false;

    const checkAutoDub = (event) => {
        if (!canUpdate && !event.detail.isInit) return;
        try {
            const playingLanguage = event.detail.playingLanguage;
            if (!playingLanguage) throw new Error('Unable to determine the current audio track.');

            const isAutoDubbed = event.detail.isAutoDubbed;
            if (!isAutoDubbed) return;

            console.log('Auto-dub detected, trying to undo...');
            const originalLanguage = event.detail.originalLanguage;
            if (!originalLanguage) throw new Error('Unable to determine the original audio track.');
            api.apiProxy.setAudioTrack(originalLanguage);
            console.log(`Auto-dub undo successful. Audio track reverted from ${playingLanguage} to ${originalLanguage}.`);
        } catch (error) {
            console.warn('Failed to prevent YouTube auto-dubbing.', error);
        } finally {
            canUpdate = false;
        }
    };

    api.eventTarget.addEventListener('yt-helper-api-playback-language-updated', checkAutoDub);
    api.eventTarget.addEventListener('yt-helper-api-ready', () => {
        canUpdate = true;
        setTimeout(() => { canUpdate = false; }, 1000)
    });
})();