Skip to content

Instantly share code, notes, and snippets.

@sters
Last active December 13, 2015 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sters/4978078 to your computer and use it in GitHub Desktop.
Save sters/4978078 to your computer and use it in GitHub Desktop.
"Supporterz" all night hackathon.
//--------------------------------------------------
// please read:
// 某ニコニコできる動画サイトにログインして、
// マイリストページでこのスクリプトを実行
// (ChromeならF12おしてconsoleにはっつけてください)
// すると、上から連続で再生してくれるかもしれない何かです。
//
// クロスフェードっぽい何かもついてますがうまくいかないかも...
// 動画が読み込めなかったときやエラーなど例外的なサムシングは考えてません。
//
// コードがあれなのも含めて、そのうちなおします...
// クロスフェードのせいで音量の保持とかされてひどい状態なので、外部に固定の再生停止や音量のコントローラをつけるとか。
// そもそもクロスフェードはいらないとか。
//--------------------------------------------------
// 作業用BGMのマイリストとか自動で流し続けられたらいいよね!みたいなあれ。
// そういう機能ないよね!とか思ったけど、確認したらあったオチ( ◞‸◟)
//--------------------------------------------------
var head = document.getElementsByTagName("head")[0];
var sc = document.createElement("script");
sc.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js";
head.appendChild(sc);
sc.onload = function(){
$.noConflict();
var _$ = jQuery;
var ifrms = [];
var found_player = function(doc) {
return doc.contents().find("#flvplayer_container").find("embed")[0];
}
var lists = _$(".watch");
var counter = 0;
ifrms.push(_$("<iframe>").attr("src", lists[0].href));
ifrms.push(_$("<iframe>").attr("src", lists[1].href));
_$("body").append(ifrms);
ifrms[0].load(function(){
var ifrm = ifrms[counter];
var fp = found_player(ifrm);
var totalTime = 0;
var lastTime = 0;
(function() {
if(fp.ext_getStatus){
var status = fp.ext_getStatus(),
time = fp.ext_getPlayheadTime();
if(status == "stopped" || status == "paused"){
fp.ext_play(1);
totalTime = fp.ext_getTotalTime();
var max = fp.ext_getVolume();
var rate = 100 / max;
fp.ext_setVolume(0);
(function(){
var n = fp.ext_getVolume();
if(n < max) {
fp.ext_setVolume(n + rate);
setTimeout(arguments.callee, 50);
}
})();
} else if(status == "playing") {
if(totalTime - time < 5) {
var last = [fp, ifrms[counter]], max = fp.ext_getVolume();
var n = max, rate = 100/max;
(function(){
last[0].ext_setVolume(n);
n -= rate;
if(n <= 0){
last[0].ext_setVolume(max);
last[1].remove();
} else {
setTimeout(arguments.callee, 50);
}
})();
counter++;
fp = found_player(ifrms[counter]);
var f = _$("<iframe>").attr("src", lists[counter+1].href);
ifrms.push(f);
_$("body").append(f);
}
}
}
setTimeout(arguments.callee, 500);
})();
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment