ページ

2012年10月16日

Nico Comment Graph

// ==UserScript==
// @name Nico Comment Graph
// @version 0.20121016
// @description Niconico video comment chart script for Chrome
// @include http://www.nicovideo.jp/watch/*
// @require http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js
// ==/UserScript==

(function(){
player = document.getElementById('flvplayer');
videoLength = unsafeWindow.Video.length + 1;
barQty = 0;
arrayBar = Array();
arrayTime = Array();
arrayColor = [
'000', '00f', '33c', '36c', '39c', '3cc', '3c9', '3c6',
'3c3', '6c3', '9c3', 'cc3', 'c93', 'c63', 'c33', 'f00'
];
func = {
container : function(){
doc = document.createElement('div');
doc.id = 'graph_container';
$('#WATCHFOOTER').prepend($(doc));
$('#graph_container').html('<table><tr><td id="graph_body"></td><td id="graph_text"></td><tr></table>');
this.body();
},
body : function(){
for (i = 0; i < 10; i++) {
if(player.ext_getComments(i).length > 0) threadId = i;
}
arrayComment = player.ext_getComments(threadId);
for (i = 0; i < arrayComment.length; i++) {
if (videoLength + 1 < Math.floor(arrayComment[i].vpos / 1000)) {
videoLength += 10;
break;
}
}
barTimeLength = videoLength / barQty;
for (i = 0, barTime = 0, barNumMax = 0; i < barQty; i++) {
barTime += barTimeLength;
arrayBar[i] = 0;
for (j = 0; j < arrayComment.length; j++) {
vpos = arrayComment[j].vpos / 1000;
if (barTime - barTimeLength <= vpos && vpos < barTime) arrayBar[i]++;
}
if (arrayBar[i] > barNumMax) barNumMax = arrayBar[i];
vposMin = Math.floor((barTime - barTimeLength) / 60);
vposSec = Math.floor(barTime - barTimeLength) - vposMin * 60;
if (vposMin < 10) vposMin = '0' + vposMin;
if (vposSec < 10) vposSec = '0' + vposSec;
arrayTime[i] = vposMin + ':' + vposSec + ' - ';
vposMin = Math.floor(barTime / 60);
vposSec = Math.floor(barTime) - vposMin * 60;
if (vposMin < 10) vposMin = '0' + vposMin;
if (vposSec < 10) vposSec = '0' + vposSec;
arrayTime[i] += vposMin + ':' + vposSec;
}
for (i = 0, bar = ''; i < barQty; i++) {
strColor = arrayColor[Math.round(arrayBar[i] / barNumMax * 15)];
if(arrayBar[i] == 0) strColor = 'fff';
strComment = arrayBar[i] + ' ' + arrayTime[i];
bar += '<div class="graph_bar" style="margin-top:' + arrayBar[i] + 'px;background:#' + strColor + ';" title="Comment : ' + strComment + '"></div>';
}
$('#graph_body').html(bar);
$('#graph_text').html('<a id="reload">' + arrayComment.length + ' Comment GET</a>');
$('#reload').click(function(){func.body()});
}
}
if (player.getAttribute('flashvars').indexOf('isWide=1') > 0) {
if (videoLength < 600) {
barQty = 170;
}else if (videoLength < 6000) {
barQty = 163;
}else{
barQty = 156;
}
}else{
if (videoLength < 600) {
barQty = 106;
}else if (videoLength < 6000) {
barQty = 99;
}else{
barQty = 92;
}
}
t = setInterval(function(){
if (player.ext_getStatus() != 'stopped') {
func.container();
clearInterval(t);
}
}, 3000);
GM_addStyle((<><![CDATA[
#player_bottom_textlink a{
color: #ccc;
}
#graph_container{
margin: -506px 0 0 75px;
color: #333;
font-size: 12px;
}
#graph_text{
padding: 504px 5px 0;
cursor: pointer;
}
.graph_bar{
width: 2px;
height: 500px;
float: left;
}
]]></>).toString());
})();

2012年2月28日

heatmeter

// ==UserScript==
// @name NicoWatch Tools heatmeter
// @description Nico Nico Douga Greasemonkey script
// @include http://www.nicovideo.jp/watch/*
// @version 0.5.20110519.20120228
// @require http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js
// ==/UserScript==

(function(){
var player = document.getElementById('flvplayer');
var video = unsafeWindow.Video;
var main = {
prm : {
color : [
'333', '33c', '36c', '39c', '3cc', '3c9', '3c6', '3c3',
'6c3', '9c3', 'cc3', 'c93', 'c63', 'c33', 'c33', 'c33'
],
videoLength : video.length,
titleNum : Array(),
chatNum : Array(),
widthSep : 0
},
container : function(){
doc = document.createElement("div");
doc.id = "meter_container";
$('#WATCHFOOTER').prepend($(doc));
$('#meter_container').html('<table><tr><td id="meter_body"></td><td id="meter_sub"></td><tr></table>');
this.body();
},
body : function(){
var nowTime = 0, chatNumMax = 0, bar = '';
for (i = 0; i < 100; i++) {
if(player.ext_getComments(i).length > 0) mainThreadId = i;
}
commentNum = player.ext_getComments(mainThreadId);
for (i = 0; i < commentNum.length; i++) {
if (this.prm.videoLength < Math.floor(commentNum[i].vpos / 1000)) {
this.prm.videoLength += 10;
break;
}
}
var timeInterval = (this.prm.videoLength * 100) / this.prm.widthSep;
for (i = 0; i < this.prm.widthSep; i++) {
nowTime += timeInterval;
this.prm.chatNum[i] = 0;
for (j = 0; j < commentNum.length; j++) {
vpos = commentNum[j].vpos / 10;
if (nowTime - timeInterval <= vpos && vpos < nowTime) this.prm.chatNum[i]++;
}
if (this.prm.chatNum[i] > chatNumMax) chatNumMax = this.prm.chatNum[i];
vposMin = Math.floor((nowTime - timeInterval) / 100 / 60);
vposSec = Math.floor((nowTime - timeInterval) / 100) - vposMin * 60;
if (vposMin < 10) vposMin = '0' + vposMin;
if (vposSec < 10) vposSec = '0' + vposSec;
timeSep = vposMin + ":" + vposSec + " - ";
vposMin = Math.floor(nowTime / 100 / 60);
vposSec = Math.floor(nowTime / 100) - vposMin * 60;
if (vposMin < 10) vposMin = '0' + vposMin;
if (vposSec < 10) vposSec = '0' + vposSec;
timeSep += vposMin + ":" + vposSec;
this.prm.titleNum[i] = timeSep;
}
this.prm.chatNumMax = chatNumMax;
for (i = 0; i < this.prm.widthSep; i++) {
strColor = this.prm.color[Math.round(this.prm.chatNum[i] / this.prm.chatNumMax * 15)];
strComment = this.prm.chatNum[i] + ' ' + this.prm.titleNum[i];
bar += '<div class="meter_bar" id="meter_bar' + i + '" style="background-color:#' + strColor + ';" title="Comment : ' + strComment + '"></div>';
}
for (i = 0, chatNumAll = 0; i < this.prm.widthSep; i++) {
chatNumAll += this.prm.chatNum[i];
}
$('#meter_body').html(bar);
$('#meter_sub').html('<a id="reload">' + chatNumAll + ' Comment GET</a>');
$('#reload').click(function(){main.body()});
}
}
if (player.getAttribute('flashvars').indexOf('isWide=1') > 0) {
if (main.prm.videoLength < 600) {
main.prm.widthSep = 170;
}else if (main.prm.videoLength < 6000) {
main.prm.widthSep = 163;
}else{
main.prm.widthSep = 156;
}
}else{
if (main.prm.videoLength < 600) {
main.prm.widthSep = 106;
}else if (main.prm.videoLength < 6000) {
main.prm.widthSep = 99;
}else{
main.prm.widthSep = 92;
}
}
t = setInterval(function(){
if (player.ext_getStatus() != 'stopped') {
main.container();
clearInterval(t);
}
}, 1000);
GM_addStyle((<><![CDATA[
#player_bottom_textlink a{
color: #ccc;
}
#meter_container{
margin: -9px 0 0 73px;
color: #999;
font-size: 12px;
}
#meter_body{
border: 2px solid #000;
}
#meter_sub{
padding: 5px 5px 0;
cursor: pointer;
}
.meter_bar{
width: 2px;
height: 16px;
float: left;
}
]]></>).toString());
})();