Skip to content

Instantly share code, notes, and snippets.

@tony-0tis
Last active May 8, 2023 15:53
Show Gist options
  • Save tony-0tis/d1337b3fd5f0b9a93378e52172324d15 to your computer and use it in GitHub Desktop.
Save tony-0tis/d1337b3fd5f0b9a93378e52172324d15 to your computer and use it in GitHub Desktop.
Youtube. Move your lang to top of the list of translate languages
let langToUp = 'Русский';
settingsObserver = new MutationObserver((list, observer)=>{
list.forEach(mutation=>{
if(mutation.addedNodes.length){
let node = [...mutation.addedNodes].find(node=>node.innerText.indexOf(langToUp)>-1);
if(node){
setTimeout(()=>{
let doc = document.querySelectorAll('.ytp-panel-menu')[0];
if(!doc) return;
[...doc.children]
.sort((a,b)=>{
if(a.innerText.indexOf(langToUp)>-1){return -1;}
if(b.innerText.indexOf(langToUp)>-1){return 1;}
return 0;
}).forEach(a=>{
doc.appendChild(a);
});
console.log('done');
},1000);
}
}
})
});
if(document.querySelector('.ytp-settings-menu')){
settingsObserver.observe(document.querySelector('.ytp-settings-menu'), {childList: true})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment