YouTube Playlist Time

Adds a timestamp of all videos' time combined.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

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

// ==UserScript==
// @name        YouTube Playlist Time
// @namespace   YouTube Playlist Time
// @description Adds a timestamp of all videos' time combined.
// @author      kriscross07
// @include     *.youtube.com/*
// @version     1.6
// @grant       none
// @run-at      document-start
// ==/UserScript==

addEventListener('DOMContentLoaded',function(){
  var time,mins=0,interval=true;

  addControls();
  interval&&setInterval(addControls,100);
  
  function addControls(){
    if(time&&document.contains(time)||!/^https:\/\/www.youtube.com\/playlist/.test(location.href))return;
    
    time=document.createElement('span');
    
    time.onclick=updateTime;
    time.title=time.innerHTML='Click to update time.';
    
    document.querySelector('.playlist-actions').appendChild(time);
    updateTime();
  }
  function updateTime(){
    var stamps=document.querySelectorAll('.timestamp>span');
    mins=0;
    for(var i=0;i<stamps.length;i++){
      var min=stamps[i].innerHTML.split(':');
      mins+=min[1]>=30?parseInt(min[0])+1:parseInt(min[0]);
    }
    time.innerHTML=mins>60?(mins/60).toFixed(1)+' hours.':mins+' minutes.';
  }
});