您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
statirics the total,longest,shortest time of youtube playlist video
当前为
- // ==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);
- })();