youtube playlist statitics

statirics the total,longest,shortest time of youtube playlist video

目前为 2017-06-18 提交的版本。查看 最新版本

// ==UserScript==
// @name         youtube playlist statitics
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  statirics the total,longest,shortest time of youtube playlist video
// @author       Youer
// @match        https://www.youtube.com/playlist?list=*
// @grant        none
// @require      https://code.jquery.com/jquery-2.2.4.min.js
// ==/UserScript==

(function() {
    //'use strict';
    console.log("excuted");
    //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 + " hours");
    console.log("average time of all: " + (sumAll / allSpan.length));
    console.log("longest video time(minutes): " + (Math.max.apply(Math, timeList)) / 60);
    console.log("shortest video time(minutes): " + (Math.min.apply(Math, timeList)) / 60);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址