前回のに若干修正を加えました。
待望のFirefox対応で、あなたも今日からfast clip!
スクリプト入手先http://userscripts.org/scripts/show/58048
待望のFirefox対応で、あなたも今日からfast clip!
スクリプト入手先http://userscripts.org/scripts/show/58048
// ==UserScript==
// @name fast ldc
// @namespace http://looxu.blogspot.com/
// @description Fast post to livedoor clip
// @include http://*
// @exclude http://mail.google.com/*
// @author Arc Cosine
// @version 1.2
// ==/UserScript==
// License : Public Domain
// Get Post key bookmarklet;
// javascript:(function(){ var n=document.getElementsByTagName('input');var p;for( var i=0,l=n.length; i<l; i++ ){ if(n[i].name.match(/postkey/)){ p=n[i].value;break;}}window.prompt('Your postkey',p);})();
(function(){
var LDC = {
/* config ここから */
postkey : 'Your Post Key',
firekey : 'c', //クリップを動かすショートカットキー。使用できるのは0-9a-zA-Zだと思う。A-ZはShift+a-zと解釈される
pub : 'on', //公開|非公開の設定。公開の場合はon 非公開の場合はoff
/* config ここまで*/
init : function(){
LDC.preLoad();
window.addEventListener( 'keypress', function(e){
LDC.addKeyBind( LDC.firekey , function(){ LDC.postBox() }, e );
LDC.addKeyBind( 'q', function(){ LDC.rate_change(-1); }, e);
LDC.addKeyBind( 'w', function(){ LDC.rate_change(1);}, e);
},false );
},
imgList : [],
preLoad : function(){
for( var i=0; i<6; i++ ){
LDC.imgList[i] = new Image();
LDC.imgList[i].src = 'http://clip.livedoor.com/img/rate/pad/' + i + '.gif';
}
},
addKeyBind : function( keyChar, func, eve ){
var t=eve.target;
var n=t.tagName.toLowerCase();
if( t.nodeType != 1 || n == 'input' || n == 'textarea' ){
return;
}
var pressKey = eve.which;
keyChar = keyChar.charCodeAt(keyChar);
if( pressKey == keyChar ){
eve.preventDefault(); //Stop Default Event
func.apply();
}
},
rate : 0,
rate_change : function(arg){
LDC.rate = parseInt(document.getElementById('rate').value) + arg;
if( LDC.rate < 0 ) LDC.rate = 0;
if( LDC.rate > 5 ) LDC.rate = 5;
var el = document.getElementById('rate_img');
//el.src = 'http://clip.livedoor.com/img/rate/pad/' + LDC.rate + '.gif';
el.src = LDC.imgList[LDC.rate].src;
document.getElementById('rate').value = LDC.rate;
},
postBox : function(){
var t_div = document.getElementById('t_div');
if( !t_div ){
t_div = document.createElement('div');
t_div.id = 't_div';
t_div.style.position = 'absolute';
t_div.style.top = (window.pageYOffset || window.scrollY)+ 20 + 'px';
t_div.style.left = '20px';
t_div.style.width = '400px';
t_div.style.padding = '10px';
t_div.style.border = '3px solid #aaaaaa';
t_div.style.textAlign = 'center';
t_div.style.backgroundColor = '#fefefe';
var myForm = document.createElement('form');
myForm.style.fontSize = '12px';
var url = 'http://clip.livedoor.com/clip/add';
myForm.method = 'POST';
myForm.target = 'crossIframe';
myForm.innerHTML = 'LDC Fast Clip<dl><dt style="width: 390px; margin-bottom: 2px;"><label style="font-size:12px; width: 48px; float:left; display: block;">レート</label><img id="rate_img" src="http://clip.livedoor.com/img/rate/pad/0.gif"> w key:rate up,q key:reate down</dt><dt style="width: 390px; margin-bottom: 2px;"><label style="font-size:12px; width: 48px; float:left; display: block;">タグ</label><input style="font-size: 12px; border: 1px solid #aaaaaa; width:300px;" tabindex=1 type="text" id="tagArea" value=""></dt><dt style="width: 390px; margin-bottom: 2px;"><label style="font-size:12px; width: 48px; float:left; display: block;">コメント</label><textarea tabindex=2 style="font-size: 12px; border:1px solid #aaaaaa; width:300px; height: 50px;" id="clipTextNote"></textarea></dt></dl><input tabindex=3 type="submit" value="送信"><input type="hidden" name="link" value="' + location.href +'"><input type="hidden" name="rate" id="rate" value="0">';
t_div.appendChild(myForm);
document.body.appendChild(t_div);
var crossIframe= document.createElement('iframe');
crossIframe.name = 'crossIframe';
crossIframe.id = 'crossIframe';
crossIframe.src = 'about:blank';
crossIframe.style.display = 'none';
myForm.addEventListener( 'submit', function(){
var text = encodeURIComponent(document.getElementById('clipTextNote').value);
var tags = encodeURIComponent(document.getElementById('tagArea').value);
myForm.action = url + '?title=' + encodeURIComponent(document.title) + '¬es=' + text + '&tags=' + tags + '&public=' + LDC.pub + '&postkey=' + LDC.postkey;
var cnt = 0;
crossIframe.addEventListener( 'load', function(){
if( cnt++ == 0 ){
myForm.submit();
}else{
crossIframe.parentNode.removeChild(crossIframe);
t_div.parentNode.removeChild(t_div);
}
}, false );
}, false );
document.body.appendChild(crossIframe);
close_div = document.createElement('div');
close_div.style.backgroundColor = '#dee3ea';
close_div.style.fontSize = '12px';
close_div.style.position = 'absolute';
close_div.style.top = '5px';
close_div.style.right='10px';
close_div.style.width = '60px';
close_div.style.border = '1px solid #0f0f0f';
close_div.innerHTML='閉じる';
t_div.appendChild(close_div);
close_div.addEventListener( 'click', function(){
crossIframe.parentNode.removeChild(crossIframe);
t_div.parentNode.removeChild(t_div);
}, false);
}else{
var crossIframe = document.getElementById('crossIframe');
crossIframe.parentNode.removeChild(crossIframe);
t_div.parentNode.removeChild(t_div);
}
}
};
LDC.init();
})();
コメント
コメントを投稿