ShufflR

Shuffle a YouTube playlist

اعتبارا من 10-02-2016. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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)
}