1æ¥ã§æ´æ°
æ´æ°æ©ããã¼ã¨ãè¨ããªãã§ãã ãã。ã¯ã¦ãªã¹ã¿ã¼ã¨ãã¯ã¦ãã¨ãLDCã§å¼ç¨ãããããªãã§ãã ãã。
ãã£ã¨、ã¾ã夿´ç¹ãã°
・DOMContentLoadedãå¹ãå ´åã¨å¹ããªãå ´åãåãã¦å¦çãã¦ãã¾ã(æ¡å¼µåãuser.jsã®æã¨.jsã®æã)
・mallowlabsããã«ææããã、詳細éè¡¨ç¤ºã®æã«ããã¦ã³ãã¼ããªã³ã¯ãåºãããã«ãã¾ãã。
・ãã¨、Operaå°ç¨ã«ãªãã¾ãã。
・ä»ã®ãã©ã¦ã¶ã§ã¯、contentWindow.postMessageã触ããªãã£ãã®ã ã、ã¯ãã¹ã³ãã。
・UserScriptãããªããã°ç¹ã«åé¡ãªããã ãã©ãã。
・ãã、ãªãã¦æ¡å¼µæ©è½(ã¢ããªã³)?
・çé¢ç®ã«ããã¨ã¢ã¬ãªã®ã§、çé¢ç®ã«ããããæ¹ã«ãä»»ããã¾ã。
・Safariãªäººã¯æ¨æºæ©è½ã§ãã¦ã³ãã¼ãåºæ¥ããã、ãã®ã¹ã¯ãªããã¯ãããªããã。
ã½ã¼ã¹ã³ã¼ã
// ==UserScript==
// @name nicovideo down
// @namespace http://looxu.blogspot.com/
// @include http://flapi.nicovideo.jp/*
// @include http://www.nicovideo.jp/watch/*
// @author ArcCosine
// @version 1.2
// ==/UserScript==
(function(){
if( location.href.indexOf('www.nicovideo') > 0 ){
var video_id = '';
if(/watch\/([^/]+)$/.test(location.href)){
video_id = RegExp.$1;
}
var obj = document.createElement('object');
obj.data = 'http://flapi.nicovideo.jp/api/getflv?v='+video_id;
obj.style.visibility = 'hidden';
obj.style.width = '1px';
obj.style.height= '1px';
obj.addEventListener('load',function(){ obj.contentWindow.postMessage('dummy','*'); }, false ); //post to client
//æ¡å¼µåãuser.jsã§ã.jsã§ãåãããã«
if( !document.body ){
document.addEventListener('DOMContentLoaded', function(){ document.body.appendChild(obj); }, false );
}else{
document.body.appendChild(obj);
}
window.addEventListener('message',function(e){
if(e.origin !== 'http://flapi.nicovideo.jp' ) return;
var text = e.data;
if( /url=(.+?)&/.test(text) ){
var h1 = document.getElementsByTagName('h1')[0]; //詳細表示æ
var h2 = document.getElementsByTagName('h2')[0]; //詳細çç¥æ
var aTag= document.createElement('a');
aTag.href = decodeURIComponent(RegExp.$1);
aTag.target = '_blank';
aTag.style.marginLeft = '5px';
aTag.appendChild(document.createTextNode('[download]'));
h1.parentNode.insertBefore(aTag,h1);
h2.parentNode.insertBefore(aTag.cloneNode(true),h2);
}
},false );
}else if( location.href.indexOf('flapi') > 0 ){
window.addEventListener('message', function(e){
if(e.origin !== 'http://www.nicovideo.jp' ) return;
var video_id = '';
if(/v=(.*)/.test(location.search)){
video_id = RegExp.$1;
}
var text = document.body.textContent;
e.source.postMessage(text,'*'); //post to parent window
}, false );
}
})();
ã¨ã¦ãé åçãªè¨äºã§ãã。
è¿ä¿¡åé¤ã¾ãéã³ã«ãã¾ã。
ãããã¨ããããã¾ã。