Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name YouTube Auto Select Original Audio Language
- // @namespace https://greasyfork.org/en/users/85671-jcunews
- // @version 1.0.1
- // @license AGPL v3
- // @author jcunews
- // @description Context: https://old.reddit.com/r/CodingHelp/comments/17aadka/youtube_pick_a_language_option_on_page_load/
- // @match https://www.youtube.com/*
- // @grant none
- // ==/UserScript==
- (rx => {
- rx = /original/i;
- setInterval((e, a) => {
- if (e = window.movie_player) {
- a = e;
- while (a?.tagName) {
- if (getComputedStyle(a).display === "none") return;
- a = a.parentNode
- }
- if ((a = e.getAvailableAudioTracks()).length && !rx.test(e.getAudioTrack().Qc.name)) {
- a.some(o => {
- if (rx.test(o.Qc.name)) {
- e.setAudioTrack({id: o.id});
- return true
- }
- })
- }
- }
- }, 200)
- })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement