Last active
August 29, 2015 14:16
-
-
Save st98/d11200a770117a4e63d6 to your computer and use it in GitHub Desktop.
ニコニコ動画のマイリストの合計再生時間を出力するヤツ。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| if (!(String.prototype.repeat)) { | |
| String.prototype.repeat = function (n) { | |
| if (n < 0) throw RangeError('Invalid repeat count'); | |
| return Array(n + 1).join(this); | |
| }; | |
| } | |
| function zfill(s, n) { | |
| if (s.length >= n) return s; | |
| return ('0'.repeat(n) + s).slice(-n); | |
| } | |
| var s = 0; | |
| [].forEach.call(document.getElementsByClassName('vinfo_length'), function (e) { | |
| var v = e.firstChild.firstChild.nodeValue; | |
| v.split(':').reverse().forEach(function (c, i) { | |
| s += parseInt(c, 10) * Math.pow(60, i); | |
| }); | |
| }); | |
| console.log([s / 3600, (s % 3600) / 60, s % 60].map(function (a) { | |
| return zfill(String(Math.floor(a)), 2); | |
| }).join(':')); | |
| })(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function(){String.prototype.repeat||(String.prototype.repeat=function(a){if(0>a)throw RangeError("Invalid repeat count");return Array(a+1).join(this)});var b=0;[].forEach.call(document.getElementsByClassName("vinfo_length"),function(a){a.firstChild.firstChild.nodeValue.split(":").reverse().forEach(function(a,c){b+=parseInt(a,10)*Math.pow(60,c)})});console.log([b/3600,b%3600/60,b%60].map(function(a){a=String(Math.floor(a));a=2<=a.length?a:("0".repeat(2)+a).slice(-2);return a}).join(":"))})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment