ShufflR

Shuffle a YouTube playlist

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        ShufflR
// @namespace   VoteToClose
// @description Shuffle a YouTube playlist
// @include     https://www.youtube.com/playlist*
// @version     1
// @grant       none
// ==/UserScript==
html_md=true
main=()=>document.getElementById('browse-items-primary').children[0].children[0]
items=[]
//while(main().children[1]) main().children[1].click() //TODO: fix infinite while loop
content=main().children[0].children[0]
for(i=0;i<content.children.length;i++){
  el=content.children[i].children[3].children[0]
  text=el.text.trim().replace(/\s?\[[^\]]*\]\s?-?\s?/g, '')
  href=el.href
  items.push(md?`[${text}](${href})`:html?`<li><a href="${href}">${text}</a></li>`:html_md?`<li>[${text}](${href})</li>`:`${text}: ${href}`)
}
window.shuffled=[]
while(items.length){
  rand=Math.floor(Math.random()*(items.length))
  shuffled.push(items[rand])
  items.splice(rand,1)
}
if(html||html_md){
  div=document.createElement('div')
  div.innerHTML=`<ul style="list-style:none">${shuffled.join('')}</ul>`
  document.body.prependChild(div)
}