youtube playlist statitics

statirics the videos duration of youtube playlist video include total,longest,shortest time

Stan na 18-06-2017. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         youtube playlist statitics
// @name:zh-CN   统计YouTube播放列表的时长
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  statirics the videos duration of youtube playlist video include total,longest,shortest time
// @description:zh-cn 统计YouTube播放列表的时长包括总时长,最长,最短,平均
// @author       Youer@https://github.com/youerning
// @match        https://www.youtube.com/playlist?list=*
// @grant        none
// @require      https://code.jquery.com/jquery-2.2.4.min.js
// ==/UserScript==

(function() {
    //'use strict';
    //var allSpan = document.getElementsByTagName("tbody")[0].getElementsByTagName("span");
    var allSpan = $("ul").find("tbody").find('span[aria-label]');
      // Total seconds
    var sumAll = 0;
    var vidTime = 0;
    var timeList = [];

    for(var i=0;i<allSpan.length;i++) {
      var sp = allSpan[i];
      var spText = sp.innerText;
      var sumOne = 0;
      if (spText.indexOf(":") >= 0) {
            var spTextLis = spText.split(":");
            var lg = spTextLis.length;
            for (var j=0; j < lg; j++){
                var m = Math.pow(60, (lg - 1 - j));
                vidTime = parseInt(spTextLis[j]) * m;
                sumOne += vidTime;
            }
        } else {
            vidTime = parseInt(spText);
            sumOne += vidTime;
      }
      timeList.push(sumOne);
      sumAll += sumOne;
    }
    // console somethings
    console.log("The playlist is total: " + (sumAll/3600).toFixed(2) + "hours");
    console.log("average time of all: " + (sumAll / (60 * allSpan.length)).toFixed(2) + "minutes");
    console.log("longest video time: " + (Math.max.apply(Math, timeList)) / 60 + "minutes");
    console.log("shortest video time: " + (Math.min.apply(Math, timeList)) / 60 + "minutes");
})();