您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Makes it possible to select the desired Audio Track.
当前为
// ==UserScript== // @name YouTube Default Audio Track // @namespace bp-yt-audio-track-default // @version 1.0 // @description Makes it possible to select the desired Audio Track. // @author BuIlDaLiBlE // @match https://www.youtube.com/* // @icon https://www.youtube.com/favicon.ico // @grant none // @run-at document-end // @license MIT // ==/UserScript== // Configuration const DESIRED_AUDIO_TRACK = "original"; // The desired audio track name (can be partial) // Entry point if(window.location.href.includes("youtube.com/shorts")) { document.addEventListener("yt-player-updated", main); } else { window.addEventListener("load", main); } function main() { const player = getPlayer(); updateSettings(player); } function updateSettings(player) { try { const availableAudioTracks = player.getAvailableAudioTracks(); const currentAudioTrack = player.getAudioTrack(); if(availableAudioTracks === undefined || availableAudioTracks.length == 0) { return; } if(!currentAudioTrack.vc.name.toLowerCase().includes(DESIRED_AUDIO_TRACK.toLowerCase())) { for(const track of availableAudioTracks) { if(track.vc.name.toLowerCase().includes(DESIRED_AUDIO_TRACK.toLowerCase())) { player.setAudioTrack(track); break; } } } } catch(error) { console.error("An error occurred:", error.message); } } function getPlayer() { let yt_player; if(window.location.href.includes("youtube.com/shorts")) { yt_player = document.getElementById("player").player_; } else { yt_player = document.getElementById("movie_player"); } if(!yt_player) { throw new Error("YouTube Player not found!"); } return yt_player; }