By gomaxfire
Has 12 other scripts.
// ==UserScript==
// @name twitter_lite
// @namespace http://gomaxfire.dnsdojo.com/
// @description a twitter client
// @include *
// @version 0.2999931
// ==/UserScript==
(function(){
//----------------------------------------------------
// utility for debug using Firebug
//----------------------------------------------------
var debugMode = false;
var debug = (function(){
if(debugMode &&
unsafeWindow.hasOwnProperty("console") &&
unsafeWindow.console.debug){
return function(s){
unsafeWindow.console.debug(s);
};
} else {
return function(s){};
}
})();
var debugByJSON = (function(){
if(debugMode &&
unsafeWindow.hasOwnProperty("console") &&
unsafeWindow.console.debug){
return function(object){
unsafeWindow.console.debug(objectToJSON(object));
};
} else {
return function(object){};
}
})();
debug("test");
//----------------------------------------------------
// utility for DOM operation
//----------------------------------------------------
function $(id){
return document.getElementById(id);
}
function $child(parent, name){
var child = null;
var children = $children(parent, name);
if(children && children.length > 0){
child = children[0];
}
return child;
}
function $children(parent, name){
var result = [];
var childNodes = parent.childNodes;
for(var i=0,child;child=childNodes[i];i++){
if(child.tagName && child.tagName.match(new RegExp(name, "i"))){
result.push(child);
}
}
return result;
}
function $add(parent, children){
if(arguments.length < 2) return "";
for(var i=1, child; child=arguments[i];i++){
if(typeof child == "string"){
child = document.createTextNode(child);
}
parent.appendChild(child);
}
return parent;
}
function $event(element, type, func){
element.addEventListener(type, func, true);
}
function $tag(tagName, option){
var tag = document.createElement(tagName);
if(option){
for(a in option){
if(option.hasOwnProperty(a)){
tag[a] = option[a];
}
}
}
with(tag.style){
margin = "0";
padding = "0";
}
return tag;
}
function $text(text){
return document.createTextNode(text);
}
function $rm(element){
element.parentNode.removeChild(element);
}
//----------------------------------------------------
// utility for JSON
//----------------------------------------------------
function parseJSON(json){
var obj = {};
json = json.replace(/^(\s*)(\S)*(\s*)$/, "$2");
if(!json.match(/^[\"\{\[]/))return obj;
if(json){
obj = eval(["(", json, ")"].join(""));
}
return obj;
}
var jsEscape =function(str){
return str.replace(/\\/ig,"\\\\")
.replace(/\f/ig,"\\f")
.replace(/\n/ig,"\\n")
.replace(/\r/ig,"\\r")
.replace(/\t/ig,"\\t")
.replace(/\'/ig,"\\'")
.replace(/\"/ig,"\\\"");
}
var objectToJSON = function(object){
var rtn;
if(object==null){
rtn = "null";
}else{
var callee = arguments.callee;
switch(object.constructor){
case Boolean:
rtn = object ? "true" : "false";
break;
case Number:
rtn = isNaN(object) || !isFinite(object)? "null" : object.toString(10);
break;
case String:
rtn = ["\"", jsEscape(object), "\""].join("");
break;
case Array:
var buf = [];
object.forEach(function(item){
//for(var i=0;i<object.length;i++){
buf.push(callee(item));
});
rtn = ["[", buf.join(","), "]"].join("");
break;
case Object:
var buf = [];
for(var key in object){
if(object.hasOwnProperty(key)){
buf.push(callee(key)+":"+callee(object[key]));
}
}
rtn = ["{", buf.join(","), "}"].join("");
break;
default:
rtn = "null";
break;
}
}
return rtn;
};
function escapeHTML(text){
return text
.replace(/\&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/\"/g, """)
.replace(/\s?(https?:\/\/\S+)/g,"<a href=\"$1\">$1</a>")
.replace(/\n/g,"<br />\n");
}
function escapeHTML(text){
return text
.replace(/\&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/\"/g, """)
.replace(/\s?(https?:\/\/\S+)/g,"<a style=\"background-color:blue;border 1px dotted #333333;color:white\" href=\"$1\" title=\"$1\">LINK</a>")
.replace(/\n/g,"<br />\n");
}
function convertAnchor(text){
return text
.replace(/\s?(https?:\/\/\S+)/g,"<a style=\"background-color:blue;border 1px dotted #333333;color:white\" href=\"$1\" title=\"$1\">LINK</a>")
.replace(/\n/g,"<br />\n");
}
function futaketa(n){
if(n < 10){
n = "0" + n;
}
return n;
}
Date.prototype.gotinFormat = function(){
return (futaketa(this.getMonth()+1))
+ "/"
+ futaketa(this.getDate())
+ " "
+ futaketa(this.getHours())
+ ":"
+ futaketa(this.getMinutes())
+ ":"
+ futaketa(this.getSeconds());
}
//----------------------------------------------------
// utility for GM_xmlhttpRequest
//----------------------------------------------------
var XHR = {
count:0,
mkParamData:function(params){
var array = [];
for(a in params){
if(params.hasOwnProperty(a)){
array.push([encodeURIComponent(a),
"=",
encodeURIComponent(params[a])].join(""));
}
}
return array.join("&");
},
post:function(url, params, func, errorFunc){
XHR.count++;
debug("try post:"+XHR.count);
debug("URL:" + url);
var data = XHR.mkParamData(params);
debug("data:" + data);
GM_xmlhttpRequest({url:url,
method:"POST",
headers:{
"Content-Type": "application/x-www-form-urlencoded",
"X-Twitter-Client":"twitter_lite.user.js",
"X-Twitter-Client-Version":"0.02931",
"X-Twitter-Client-URL":"http://d.hatena.ne.jp/gotin/20070413/1176397931"},
data:data,
onload:function(xhr){
XHR.count--;
debug("posted:"+XHR.count);
func(xhr);
},
onerror:function(xhr){
debug("error:"+url);
if(typeof errorFunc == "function" ){
errorFunc(xhr);
}
}
});
},
get:function(url, params, func, errorfunc){
XHR.count++;
debug("try get:"+XHR.count);
var data = XHR.mkParamData(params);
GM_xmlhttpRequest({
url:[url,data].join("?"),
method:"GET",
onload:function(xhr){
XHR.count--;
debug("got:"+XHR.count);
typeof func == "function" ? func(xhr) : null;
},
onerror:function(xhr){
debug("error:"+url);
typeof errorFunc == "function" ? errorFunc(xhr) : null;
}
});
}
}
//----------------------------------------------------
// Keybind object
//----------------------------------------------------
var Keybind = {
phrases:{},
add:function(phrase, func){
if(this.phrases.hasOwnProperty(phrase)) return;
this.phrases[phrase] = true;
$event(document, "keydown",
function(event){
var target = event.target;
var tagName = target.tagName;
var type = target.type;
if(phrase == Keybind.code(event) &&
!(tagName == "INPUT" &&
(!type.type || type=="text")) &&
tagName != "TEXTAREA"){
func();
}});
},
code: function(event){
var code = [];
if(event.shiftKey){
code.push("S");
} else if(event.ctrlKey){
code.push("C");
} else if(event.altKey){
code.push("M");
}
code.push(Keybind.kc2char(event.keyCode));
return code.join("-");
},
kc2char:function(kc){
var between = function(a,b){
return a <= kc && kc <= b;
};
var _32_40 = "space pageup pagedown end home left up right down".split(" ");
var kt = {
8 : "back",
9 : "tab" ,
13 : "enter",
16 : "shift",
17 : "ctrl",
27 : "esc",
46 : "delete",
};
return (between(65,90) ? String.fromCharCode(kc+32) : // a-z
between(48,57) ? String.fromCharCode(kc) : // 0-9
between(96,105) ? String.fromCharCode(kc-48) : // num 0-9
between(32,40) ? _32_40[kc-32] :
kt.hasOwnProperty(kc) ? kt[kc] :
kc);
}
};
//----------------------------------------------------
// sound utility
//----------------------------------------------------
var sound_pi = "data:audio/x-wav,RIFF%22%19%00%00WAVEfmt%20%10%00%00%00%01%00%01%00%22V%00%00D%AC%00%00%02%00%10%00data%FE%18%00%00%FF%FF%01%00%FF%FF%01%00%FF%FF%01%00%FF%FF%01%00%FF%FF%01%00%FF%FF%01%00%FF%FF%01%00%FE%FF%01%00%FC%FF%04%00%FB%FF%04%00%FB%FF%05%00%FA%FF%06%00%F7%FF%09%00%F5%FF%0D%00%EF%FF%16%00%E0%FF9%00%ED%F9%84%F8s%F8%F5%F7%DD%F7%9B%F7%CB%F7%0D%F8%89%F8%AE%F8%C3%F8%AE%F8%7D%F8.%F8%FC%F7%C5%F7%BF%F7%E1%F7Q%F8%90%F8%97%F8r%F8U%F8%0B%F8%D2%F7%C9%F7%08%F8%23%F89%F8%40%F8*%F8%E8%F7%B6%F7%AE%F7%D3%F7%02%F8%25%F8%0B%F8%E1%F7%CE%F7%A5%F7c%F7a%F7%BB%F7%1A%F85%F8J%F8O%F8%0B%F8%93%F7%3A%F7.%F7g%F7%BD%F7%03%F8F%F8a%F8.%F8%AF%F7%3A%F7%1B%F7)%F7N%F7f%F7%A8%F7%D8%F7%CA%F7%AE%F7%B9%F7%AE%F7%88%F7T%F7%20%F7%E8%F6%D3%F6%09%F7%5B%F7%8D%F7%AE%F7%B7%F7%8A%F7A%F7%0C%F7%DF%F6%E4%F6%2C%F7%95%F7%C7%F7%E6%F7%C9%F7%5C%F7%DC%F6l%F6%3E%F6*%F6y%F6%FD%F6%5E%F7%93%F7%CB%F7%DE%F7%A0%F7A%F7%F2%F6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A%B0%26%D21%BC(%08%0E%96%EAR%C9%98%B4%2B%B3%C2%C5P%E6%12%0A2%26%D51%0A)%85%0E%0F%EB%FA%C9F%B5%AA%B3%CD%C5%DA%E5U%09%90%25%901u)v%0Fj%EC%40%CB)%B6%DF%B3n%C5%0B%E5%89%08%BC%24%3C1%9F)4%101%ED%FA%CB%C7%B6%EA%B3%0F%C5d%E4%0D%08%B7%24%BE1_*%1B%11S%EE%C9%CC%F0%B6%CF%B3%B4%C4%FB%E3w%07R%24%871%DA*%24%12y%EF)%CE%E3%B7%F2%B3%E5%C3%E4%E2%8F%06%DD%23%DF1%B0%2B%3E%13%84%F0%AA%CE%0E%B8%DB%B3%9A%C3p%E2%1A%06%A7%23%D81J%2CI%14%EF%F1%C5%CF%BB%B8%FD%B3D%C3%A4%E1K%051%23%FB1%D4%2C%2C%15%BB%F2%91%D0%1F%B9%F5%B3%EC%C2%1D%E1%07%05%14%23%202--%BF%15c%F3%00%D1%A9%B94%B4%14%C3%40%E1%FE%04%EF%22%FE1E-%08%16%FB%F3%0E%D2%8C%BA%07%B5%22%C3%E2%E0S%04r%22%D01%82-%D1%16%F5%F4%F8%D2%5B%BB%8B%B5p%C3%84%E0%82%03%60!%081%5C-%98%17%AD%F6%00%D5%D5%BC%13%B6%10%C3%9D%DFH%02Y%20%890%95-)%18E%F7%CB%D5%DA%BD%F4%B6p%C3o%DF%F6%01%F9%1F%600%9E-%B9%18%16%F8%81%D68%BE%F3%B6%1A%C3%03%DFq%01%BC%1FL0%1F.%3B%19%D7%F8%FA%D6U%BE%97%B6~%C2~%DE%0A%01%B8%1F%C40%DF.%05%1AP%F93%D7J%BE%3A%B6%F6%C1%B2%DD%A0%00%9C%1F(1%7F%2F%17%1B%96%FA%0E%D8q%BE%B5%B5%02%C1%B1%DC%FC%FFz%1F%A61j00%1C4%FBH%D8%1A%BE%F1%B4%D7%BF%83%DB%25%FFR%1F52%881%87%1D0%FC%84%D8w%BD%AE%B3o%BEv%DA%82%FEl%1F%D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14x.%9F7z%2CT%10%DB%EC%C4%CCh%BAr%BB%02%D0(%F1X%14%99.%DF7%EB%2C%20%11%80%ED%5C%CDr%BA%FA%BA%07%CFV%F0%C1%13p.%168%8D-%DE%119%EE%0F%CE%F5%BA%FC%BAs%CE3%EF_%12%80-%138%97.%95%13L%F0%AD%CF%C2%BB%D1%BAt%CD%C3%ED%15%11%81%2C%D47%20%2F-%15%0F%F2%3B%D1%86%BC%8C%BA-%CC%A2%EB3%0F%7F%2B%EA760%D5%16r%F3%10%D0%C7%B8%A7%B9v%D3G%F8!%18%AA*%EF%2BL%1A%EF%FD%AF%E4%C7%D7%13%D7%AE%DE%0D%EB%04%FAM%08P%12%00%14x%0C%86%FE%7B%EF%B9%E3%0E%DF%1D%E3%DD%EE%1E%FD%23%09D%0F%08%0E%E7%05%C7%F9%CC%EDf%E5X%E3b%E8%C1%F2%BE%FE%3C%08v%0C%10%0A%F2%01%C3%F66%EC%E3%E5%3D%E6)%ED%C0%F7%8D%02%60%0A%A4%0C9%08h%FEw%F2%8D%E8%00%E42%E6%C9%EE%E2%FA%8F%06%AF%0D%7F%0E%1B%08%BB%FC%1C%F0Z%E63%E2%FD%E4t%EE%DC%FBv%083%10%8E%10f%09%BB%FC%94%EE%C8%E3%FD%DF%7C%E4%FC%EF%7D%FES%0BO%12%81%11%ED%08%EF%FAw%EC%15%E2%40%DF%C9%E4K%F1%98%00%9E%0D%0C%14%8F%11%16%07%03%F8%B5%E9%7B%E0%86%DF%D9%E6)%F4%03%03%96%0E%82%13%E3%0F%11%05W%F6%A1%E80%E0%AF%DFc%E7%DF%F4%CF%03%89%0FY%14%AA%10N%05%1B%F6%BB%E7%FE%DE%92%DE%DE%E6!%F5%D3%04%93%10%D4%14%13%10(%04%D5%F4i%E7%15%E0%B6%E0)%E9%86%F6w%04%81%0E%AA%119%0D%DF%02%CD%F5%5D%EA%F4%E3i%E4h%EB%A2%F6Q%02%DE%0A%05%0E%01%0B%7B%02%85%F7k%EDS%E7%0E%E7%B0%ECB%F6%9E%00%9C%08%C5%0B8%09%97%01%CF%F7%B5%EEO%E9%C8%E8%AA%EDI%F6%F7%FFr%07%94%0A%9A%08%13%02%BC%F8%FF%EF%3D%EA%60%E9%93%ED%DA%F5d%FF%15%07%BB%0A%F5%08h%021%F9%40%F0%99%EA%E5%E9%93%EE%BA%F6%B9%FF%C4%06%90%09p%07%1F%01%16%F9g%F1%CD%EC7%EC%E7%EF%A8%F6%8E%FE%F0%04%1A%08p%07%C7%02o%FB%B8%F3%E2%ED%CB%EB)%EEn%F4%A4%FC%91%04H%09%23%09I%04%8A%FC%0A%F4%8C%EDG%EB%C4%ED%1E%F4W%FC%03%04%94%08%C9%08z%04%06%FD%9D%F4N%EE%14%EC%5C%EE%2F%F4%D7%FB%F3%025%07u%07%EC%03%C9%FD%9B%F6y%F0%83%EDz%EE%2F%F3%DA%F9%EB%00%EC%05S%07%9D%04%B2%FEz%F7%F8%F0%B1%ED7%EE%C7%F2%E3%F9%3F%01A%06%5D%077%04%EA%FD%9A%F6%9C%F0%D6%ED%22%EF%E0%F3%8E%FA%F1%00l%05P%06%93%03%AC%FD%BE%F6%DD%F0%E5%ED%BB%EEN%F3a%FAI%01%D2%05%89%06U%03%1E%FD%CF%F5%C8%EFH%ED%F8%EEs%F4%82%FB%17%02%F7%05%F4%05%1C%02%9E%FB%DE%F4%15%F0h%EEn%F0%80%F5%24%FC%BA%01%0D%05%AA%04%E2%00%F3%FA%CE%F4H%F0%C8%EE%F0%F0%F3%F5N%FC%FD%01(%05%E7%04F%01.%FB%B8%F4%FA%EFw%EE%A0%F0%CD%F5%3A%FC%03%02%2F%05%CC%04%F3%00.%FB%19%F5%AC%F0%3A%EFH%F1%02%F6%EB%FB%22%01*%04%02%04%89%00%0B%FBN%F5%0A%F1%BF%EF%DC%F1%81%F6M%FC6%01%BB%03%FB%02T%FF%11%FA%CE%F4%8F%F1%04%F1G%F3%95%F7x%FC%93%00f%02%8F%01g%FE%F4%F9%7F%F5v%F2%0E%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_%FAk%FA%13%FB%BE%FB%7D%FC%A1%FCl%FC%C4%FBG%FB%C4%FA%8C%FA%A4%FA%E7%FA%2C%FB%99%FB%17%FCY%FCi%FCg%FC%F8%FB4%FB_%FA%01%FA%25%FA%C9%FA%9B%FBi%FC%FC%FC%F7%FCa%FC%B0%FB%05%FB%87%FAT%FA%85%FA%01%FB%92%FBH%FC%9F%FC%DA%FC%8C%FC%15%FCS%FB%B2%FAW%FAN%FA%94%FA4%FB%EF%FB%8E%FC%A9%FC%96%FC%17%FC%60%FB%99%FA%3B%FA8%FA%88%FA9%FB%17%FC%B7%FC%C5%FC%5C%FC%CD%FBD%FBz%FA*%FAe%FA%FA%FA%82%FB%1E%FC%8E%FC%A7%FCF%FC%92%FB%A8%FA%01%FA%BC%F9%E8%F9%C6%FA%BE%FB%BA%FC%08%FD%DC%FC%EE%FB%BF%FA%94%F9%E0%F8(%F9";
function playSound(sound_data){
var sound = <OBJECT ID="sound1"
CLASSID="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
HEIGHT="0" WIDTH="0">
<param name="autostart" value="true" />
<param name="src" value={sound_data} />
<embed src={sound_data}
type="audio/wav"
console="sound1"
controls="All"
height="0"
width="0"
autostart="true"
name="sound1" />
</OBJECT>;
var div = $tag("div",{innerHTML:sound.toString()});
$add(document.body, div);
setTimeout(function(){$rm(div);}, 3000);
}
//----------------------------------------------------
// window-like element object
//----------------------------------------------------
var MiniWindow = function(title, app){
this.title = title;
this.app = app;
this.config = new Configuration(title, app, this);
//this.config.load();
this.app.window = this;
this.root = null;
this.makeDOM();
//this.config.load();
};
MiniWindow.prototype = {
makeDOM:function(){
this.close = false;
body = $tag("div", {id:this.title + "_body"});
this.appDOM = this.app.root;
this.configDOM = this.config.root;
$add(body, this.appDOM, this.configDOM);
this.root = $tag("div");
var closeButton = $tag("input", {type:"button",
value:"x"});
var self = this;
$event(closeButton, "click",
function(event){
self.hide();
self.app.stop();
});
var title = $tag("h2", {id:"__title__" ,textContent:this.title});
var configA = $tag("a", {textContent:"config"});
with(configA.style){
fontSize = "small";
textDecoration = "underline";
color = "blue";
}
this.statusBar = $tag("div");
with(this.statusBar.style){
background = "transparent";
color = "black";
fontFamily = "courier new";
fontSize = "x-small";
width = "100%";
height = "20px";
}
$add(this.root, closeButton, title, configA, body, this.statusBar);
with(this.root.style){
position = "fixed";
bottom = "0px";
right = "2px";
padding = "2px";
backgroundColor = "#CCCCFF";
borderTop = "1px solid white";
borderLeft = "1px solid white";
borderRight = "1px solid #333333";
borderBottom = "1px solid #333333";
width = "250px";
height = "400px";
zIndex = "999999";
textAlign = "left";
display = "none";
}
with(closeButton.style){
padding = "1px";
margin = "1px";
}
with(body.style){
backgroundColor = "white";
width = "100%";
height = "370px";
borderBottom = "1px solid white";
borderRight = "1px solid white";
borderLeft = "1px solid #333333";
borderTop = "1px solid #333333";
fontSize = "small";
fontFamily = "courier new";
}
with(title.style){
color = "black";
padding = "2px";
fontSize = "small";
display = "inline";
textAlign = "left";
}
$event(this.root, "click",
function(event){
if(event.target == configA){
self.showConfig();
}
if(event.target != this.root &&
event.target != title)return;
event.preventDefault();
if(self.close){
self.show();
} else {
self.showOnlyTitle();
}
self.close = !self.close;
});
$event(window, "resize",
function(event){self.resize();});
},
inWindow:function(target){
for(var t = target;
t && t.tagName != "BODY"
&& t.tagName != "INPUT"
&& t.tagName != "TEXTAREA"
;t = t.parentNode){
if(t == this.root) return true;
}
return false;
},
show:function(option){
if($("__orig__")) return;
var orig = $tag("div", {id:"__orig__"});
with(orig.style){
marginRight = "255px";
float = "right";
}
var body = document.body;
with(body.style){
padding = "0";
margin = "0";
}
while(body.lastChild){
orig.insertBefore(body.lastChild, orig.firstChild);
}
$add(document.body, orig, this.root);
this.resize();
var self = this;
with(this.root.style){
display = "block";
bottom = "0px";
right = "0";
}
this.app.setStatusBar();
},
resize:function(){
if(!$("__orig__")) return;
if(this.root.style.right == "-160px"){
this.root.bottom = (20 - window.innerHeight) + "px";
} else {
this.root.style.height = (window.innerHeight - 4) + "px"
$(this.title + "_body").style.height = (window.innerHeight - 52) + "px"
$("__command_content__").style.height = (window.innerHeight - 82) + "px"
//$("__command_content__").style.height = "100%";
var orig =$("__orig__");
var origHeight =window.innerHeight;
var origWidth = document.body.clientWidth - 255;
orig.style.height = origHeight + "px"
orig.style.width = origWidth + "px"
orig.style.overflow = "scroll";
// if(orig.scrollWidth > origWidth
// && orig.clientHeight > origHeight){
// orig.style.overflow = "scroll";
// } else if(orig.clientWidth > origWidth){
// orig.style.overflow = "scrollX";
// } else if(orig.clientHeight > origHeight){
// orig.style.overflow = "scrollY";
// } else {
// orig.style.overflow = "none";
// }
}
},
hide:function(){
$rm(this.root);
var orig = $("__orig__");
var body = document.body;
while(orig.lastChild){
body.insertBefore(orig.lastChild, body.firstChild);
}
$rm(orig);
},
showOnlyTitle:function(){
var orig = $("__orig__");
var body = document.body;
while(orig.lastChild){
body.insertBefore(orig.lastChild, body.firstChild);
}
$rm(orig);
with(this.root.style){
display = "block";
bottom = (20 - window.innerHeight) + "px";
right = "-160px";
}
},
showConfig:function(){
this.app.stop();
this.show();
this.configDOM.style.display = "block";
this.appDOM.style.display = "none";
},
notifyConfig:function(){
this.app.setConfig(this.config.config);
},
showApplication:function(){
this.show();
this.configDOM.style.display = "none";
this.appDOM.style.display = "block";
this.app.start();
}
};
var Application = function(){
this.config = {};
};
Application.prototype = {
setConfig:function(config){
for(name in config){
this.config[name] = config[name];
}
if("setConfigAux" in this
&& typeof this.setConfigAux == "function"){
this.setConfigAux();
}
},
requestConfig:function(){
if(this.hasOwnProperty("window")){
this.window.showConfig();
}
}
};
var Configuration = function(name, app, window){
this.name = name;
this.window = window;
this.app = app;
this.configTemplate = app.configTemplate;
this.config = {};
this.root = null;
this.load();
this.makeDOM();
};
Configuration.prototype = {
save:function(configData){
for(name in configData){
GM_setValue(this.name + "_" + name,
"value:" + escape(configData[name]));
this.config[name] = configData[name];
}
this.app.setConfig(this.config);
},
load:function(){
for(name in this.configTemplate){
var escapedValue = GM_getValue(this.name + "_" + name);
if(escapedValue){
var unescapedValue = unescape(escapedValue);
unescapedValue.match(/value:(.*)/);
this.config[name] = RegExp.$1;
}
}
this.app.setConfig(this.config);
},
makeDOM:function(){
this.root = $tag("form", {id:"___configuration___"});
var h2 = $tag("h2", {textContent:this.name});
var table = $tag("table", {id:"__config_table__"});;
table.style.width = "100%";
var tbody = $tag("tbody");
$add(table, tbody);
var inputs = [];
for(name in this.configTemplate){
if(this.configTemplate.hasOwnProperty(name)){
var tr = $tag("tr");
var value = this.config[name];
if(!value){
value = this.configTemplate[name];
}
var input = null;
var options ={id:"prompt:" + name,
value:value};
if(value.indexOf("\n") >= 0){
options.cols = 50;
options.rows = 4;
input = $tag("textarea", otpions);
} else {
input = $tag("input", options);
}
inputs.push(input);
var th = $tag("th", {align:"right", textContent:name + ":"});
with(th.style){
backgroundColor = "#EEEEEE";
fontSize = "small";
color = "black";
fontFamily = "courier new";
textAlign="right";
}
var td = $tag("td");
with(td.style){
fontSize = "small";
color = "black";
fontFamily = "courier new";
textAlign="left";
}
$add(td, input);
$add(tr, th, td);
$add(tbody, tr);
}
}
var apply = $tag("input",{type:"submit",value:"ok"});
var cancel = $tag("input",{type:"button",value:"cancel"});
var self = this;
var window = this.window;
$event(this.root,"submit",
function(event){
event.preventDefault();
var data = {};
inputs.forEach(function(input){
input.id.match(/prompt\:(.*)/);
var name = RegExp.$1;
var value = input.value;
data[name] = value;
});
self.save(data);
self.window.showApplication();
return false;
});
$event(cancel, "click",
function(event){
self.window.showApplication();
});
$add(this.root, h2, table, apply, cancel);
with(this.root.style){
display = "none";
opacity = "1.0";
}
}
};
//----------------------------------------------------
// CUI application
//----------------------------------------------------
var CUI = function(){
this.init.apply(this, arguments);
};
CUI.prototype = {
init:function(action, max, dblClickListener){
this.max = max ? max : 20;
this.dblClickListener = dblClickListener;
this.root = null;
this.content = null;
this.input = null;
this.action = action;
this.makeDOM();
},
outputHTML:function(content){
var line = $tag("div", {innerHTML:escapeHTML(content)});
with(line.style){
background = "transparent";
width = "100%";
padding = "2px";
borderBottom = "1px dotted #333333";
}
this.output(line);
},
outputLine:function(content){
var line = $tag("div");
with(line.style){
background = "transparent";
width = "100%";
padding = "2px";
borderBottom = "1px dotted #333333";
}
this.output($add(line, content));
},
output:function(content){
var newLine = $tag("div", {className:"__command_line__"});
$add(newLine, content);
var lines = this.content.childNodes;
if(!lines || lines.length <= 0){
$add(this.content, newLine);
} else {
this.content.insertBefore(newLine, lines[0]);
lines = this.content.childNodes;
if(lines.length >= this.max){
this.content.removeChild(lines[lines.length - 1]);
}
}
var blue = 0;
var id = setInterval(function(){
newLine.style.backgroundColor = "rgb(255,255," + blue + ")";
blue++;
if(blue > 255){
clearInterval(id);
}
}, 1);
},
commandAction:function(input){
if(typeof this.action == "function"){
try{
this.action(input);
}catch(e){
var errorMessage = $tag("div", {textContent:e.message});
with(errorMessage.style){
color = "red";
border = "1px solid red";
padding = "2px";
backgroundColor = "lightyellow";
}
this.output(errorMessage);
}
}
},
changeToInput:function(textarea){
var input = $tag("input");
with(input.style){
width = "100%";
padding = "2px";
}
this.root.insertBefore(input, textarea);
this.root.removeChild(textarea);
this.input = input;
var self = this;
$event(this.input, "keydown",
function(event){
if(Keybind.code(event) == "S-enter" &&
self.input.tagName == "INPUT"){
self.changeToTextarea(input);
event.preventDefault();
}
});
this.addDblClickListener();
this.input.focus();
},
addDblClickListener:function(){
if(!this.dblClickListener || typeof this.dblClickListener != "function") return;
var self = this;
$event(this.input, "dblclick",
function(event){self.dblClickListener();});
},
changeToTextarea:function(input){
var textarea = $tag("textarea",{rows:4, value:input.value + "\n"});
with(textarea.style){
width = "100%";
fontSize = "small";
color = "black";
padding = "2px";
}
input.parentNode.insertBefore(textarea, input);
input.parentNode.removeChild(input);
this.input = textarea;
var self = this;
$event(textarea, "keydown",
function(event){
var phrase = Keybind.code(event);
if(phrase == "C-m" || phrase == "C-enter"|| phrase == "S-enter"){
self.commandAction(textarea.value);
textarea.value = "";
self.changeToInput(textarea);
event.preventDefault();
}
});
this.addDblClickListener();
this.input.focus();
},
makeDOM:function(){
this.root = $tag("form", {action:""});
this.root.style.height = "100%";
with(this.root.style){
textAlign = "left";
}
this.input = $tag("input");
with(this.input.style){
width = "100%";
padding = "2px";
}
var submit = $tag("input", {type:"submit", value:"do"});
submit.style.display = "none";
with(submit.style){
padding = "1px";
fontSize = "small";
fontFamily = "courier new";
}
var content = $tag("div",{id:"__command_content__"});
with(content.style){
overflow = "scroll";
width = "100%";
}
this.content = content;
$add(this.root, this.input, submit, content);
var self = this;
$event(this.root, "submit",
function(event){
event.preventDefault();
if(self.input.value.replace(/\s/g,"").length <= 0)
return;
self.commandAction(self.input.value);
self.input.value = "";
return false;
});
$event(this.input, "keydown",
function(event){
if(Keybind.code(event) == "S-enter" &&
self.input.tagName == "INPUT"){
self.changeToTextarea(self.input);
event.preventDefault();
}
});
this.addDblClickListener();
var style =
["#__command_content__ {",
" font-family:courier new;",
" background-color:white;",
" border: 1px solid #333333;",
" padding:2px;",
" font-size:small;",
"}",
".__command_line__ {",
" width:100%",
" text-align:left;",
" font-size:small;",
" color:black;",
"}"
].join("\n");
GM_addStyle(style);
}
};
//----------------------------------------------------
// command manager
//----------------------------------------------------
var CommandManager = {
defaultCommand:"twit",
comlets : {},
add : function(comlet, commands){
if(arguments.length < 2) return;
for(var i=1,command;command = arguments[i];i++){
this.comlets[command] = comlet;
}
},
dispatch : function(message){
var command = null;
if(!message.match(/^\s*\:(\S+)/)){
if(this.defaultCommand){
command = this.defaultCommand;
message = ":" + command + " " + message;
} else {
return false;
}
} else {
command = RegExp.$1;
}
if(!this.comlets.hasOwnProperty(command)) return false;
this.comlets[command].execute(message);
return true;
}
};
//----------------------------------------------------
// twitter client
//----------------------------------------------------
var Twitter = {
config:function(auth, format){
var user = auth.username;
var pass = auth.password;
Twitter.baseURL = ["http://", user, ":", pass, "@",
"twitter.com"].join("");
var mkURL = function(path){
return [Twitter.baseURL,
path,
".",
format].join("");
};
Twitter.updateURL = mkURL("/statuses/update");
Twitter.friendsURL = mkURL("/statuses/friends");
Twitter.timelineURL = mkURL("/statuses/friends_timeline");
Twitter.publiclineURL = mkURL("/statuses/public_timeline");
},
update:function(doing, func, errorFunc){
try{
XHR.post(Twitter.updateURL, {"status":doing},
function(xhr){
debug(xhr.responseText);
func(xhr);
},
function(xhr){
errorFunc();
});
}catch(e){
errorFunc();
}
},
friends:function(func, errorFunc){
try{
XHR.get(Twitter.friendsURL, {},
function(xhr){
debug(xhr.responseText);
func(xhr);
},
function(xhr){
errorFunc();
});
}catch(e){
errorFunc();
}
},
timeline:function(mode, since, func, errorFunc){
var params = {};
if(since){
params.since = since;
// params.since_id = since;
}
try{
var returned = false;
var count = 0;
var url = (mode == "friend") ? Twitter.timelineURL : Twitter.publiclineURL;
var post = function(){
XHR.get(url, params,
function(xhr){
returned = true;
debug(xhr.responseText);
func(xhr);
},
function(xhr){
returned = true;
errorFunc();
});
setTimeout(function(){
if(!returned){
count++;
debug("retry:" + count);
post();
}
}, 1000*60);
};
post();
}catch(e){
errorFunc();
}
}
};
//----------------------------------------------------
// application
//----------------------------------------------------
function run(){
//----------------------------------------------------
// twitter client application
//----------------------------------------------------
var twitterApp = new Application();
twitterApp.mode = "friend";
twitterApp.lastTime = null;
twitterApp.lastId = null;
twitterApp.configTemplate = {
username:"username",
password:"password",
shortcut:"S-t",
interval:"30",
sound:"false"
};
var inputListener = function(input){
if(!CommandManager.dispatch(input)){
if(input.match(/^\s*:(\S*)/)){
ph("\"" + RegExp.$1 + "\" was unknown command.");
}
}
};
var dblClickListener = function(){
if(this.input.tagName == "INPUT"){
this.changeToTextarea(cui.input);
}
this.input.value = ["reading" ,
document.title,
document.location.href].join("\n");
};
var cui = new CUI(inputListener, 100, dblClickListener);
twitterApp.root = cui.root;
twitterApp.start = function(){
if(this.autoReload){
return;
}
if(!this.checkConfig()){
return;
}
this.autoReload = true;
this.timeline();
};
twitterApp.makeRecordDOM = function(line){
var recordId = "__twitter_line__" + line.id;
if($(recordId)){
debug("existed record");
return null;
}
var record = $tag("div");
record.style.width = "100%";
var table = $tag("table", {id:recordId, className:"__twitter_record__"});
with(table.style){
background = "transparent";
width = "100%";
padding = "2px";
borderBottom = "1px dotted #333333";
}
var tr = $tag("tr");
var imgTd = $tag("td",{valign:"top"});
with(imgTd.style){
verticalAlign = "top";
width = "24px";
}
var imgA = $tag("a", {href:"http://twitter.com/" + line.user.name});
var img = $tag("img", {src:line.user.profile_image_url,
width:"24", height:"24"});
img.style["float"] = "left";
img.setAttribute("style","float:left;");
with(img.style){
display = "block";
}
var dataTd = $tag("td");
with(dataTd.style){
textAlign = "left";
fontSize = "small";
}
var nameA = $tag("a", {href:"http://twitter.com/" + line.user.screen_name});
with(nameA.style){
color = "blue";
}
var nameAndDate = $tag("div");
with(nameAndDate.style){
fontSize = "x-small";
textAlign = "left";
color = "#333399";
}
var name = $tag("span", {textContent:line.user.screen_name});
var date = $tag("span", {textContent:" [" +new Date(line.created_at).gotinFormat() + "]"});
var doing = $tag("div", {innerHTML:convertAnchor(line.text)});
with(doing.style){
lineHeight = "120%";
margin = "2px";
padding = "2px";
textAlign = "left";
}
$add(record,
$add(table,
$add(tr,
$add(imgTd, $add(imgA, img)),
$add(dataTd,
$add(nameAndDate,
$add(nameA, name),
date),
doing))));
return record;
};
twitterApp.timelineMode = "friend";
twitterApp.command = "twit";
twitterApp.status = "";
twitterApp.setTimelineMode = function(text){
this.timelineMode = text;
this.setStatusBar();
};
twitterApp.setCommand = function(text){
this.command = text;
this.setStatusBar();
};
twitterApp.setStatus = function(text){
this.status = text;
this.setStatusBar();
};
twitterApp.setStatusBar = function(){
if(!this.window.statusBar) return;
this.window.statusBar.innerHTML =
"["
+ this.command
+ "]"
+ this.timelineMode
+ " <span style='color:red'>"
+ this.status
+ "</span>";
};
twitterApp.timeline = function(){
var self = this;
var last = self.lastTime;
if(this.mode == "public"){
last = self.lastId;
}
Twitter.timeline(this.mode, last, function(xhr){
debug("response status:" +xhr.status);
var info = parseJSON(xhr.responseText);
if(!(info instanceof Array)){
if(xhr.responseText.match(/html/i) || (xhr.status != 304 && xhr.status != 200)){
self.setStatus("twitter server error");
}
self.reload();
return;
}
self.setStatus("");
var added = false;
for(var i=info.length-1;i>=0;i--){
var line = info[i];
var record = self.makeRecordDOM(line);
if(!record)continue;
cui.output(record);
added = true;
var time = line.created_at;
if(time)self.lastTime = time;
var id = line.id;
if(id)self.lastId = id;
}
if(added && twitterApp.config.sound.match(/true/i)){
playSound(sound_pi);
}
self.reload();
},
function(){
self.reload();
});
};
twitterApp.reload = function(){
var interval =parseInt(this.config.interval);
if(!interval || interval < 5){
interval = 5;
}
if(this.autoReload){
var self = this;
this.timeoutId = setTimeout(function(){
if(self.autoReload)self.timeline();
}, interval * 1000);
}
};
twitterApp.stop = function(){
debug("stop:");
if("timeoutId" in this && this.autoReload){
clearTimeout(this.timeoutId);
this.autoReload = false;
}
};
twitterApp.setConfigAux = function(){
Twitter.config(this.config, "json");
var self = this;
var shortcut = this.config.shortcut;
if(!shortcut){
this.requestConfig();
} else {
Keybind.add(shortcut,
function(){
if(self.window.root.parentNode &&
self.window.root.style.display == "block"){
self.window.hide();
} else {
self.window.show();
self.start();
setTimeout(function(){cui.input.focus()}, 500);
}
});
}
};
twitterApp.checkConfig = function(){
if(!this.config.username || !this.config.password
|| !this.config.interval || !this.config.shortcut
|| !this.config.sound){
this.stop();
this.requestConfig();
return false;
} else {
return true;
}
};
var twitterWin = new MiniWindow("twitter lite", twitterApp);
//----------------------------------------------------
// comlet
//----------------------------------------------------
var Comlet = function(command){
if(!(command instanceof Array)){
command = [command];
}
command.unshift(this);
CommandManager.add.apply(CommandManager, command);
};
Comlet.prototype = {
echo:true,
execute:function(message){
var command = "";
var inputValue = "";
if(message.replace(/\r/g,"").replace(/\n/g,"\t").match(/^\s*\:(\S+)\s+(.*)$/)){
command = RegExp.$1;
inputValue = RegExp.$2.replace(/\t/g, "\n");
}
if(this.echo){
cui.outputHTML(message);
}
try{
this.executeAux(command, inputValue);
}catch(e){
debug(e);
}
}
};
//----------------------------------------------------
// twitter comlet(defulat command)
//----------------------------------------------------
var twitterComlet = new Comlet("twit");
twitterComlet.echo = false;
twitterComlet.executeAux = function(command, input){
twitterApp.stop();
Twitter.update(input, function(xhr){
twitterApp.start();
});
};
//----------------------------------------------------
// keep omlet
//----------------------------------------------------
var keepComlet = new Comlet("keep");
keepComlet.executeAux = function(command, keep){
CommandManager.defaultCommand = keep;
ph("set default command : \"" + keep + "\".");
twitterApp.setCommand(keep);
};
//----------------------------------------------------
// amazon search comlet
//----------------------------------------------------
var amazonComlet = new Comlet("amazon");
amazonComlet.parse = function(keyword, xml){
var parser = new DOMParser();
var doc = parser.parseFromString(xml, "text/xml");
var items = doc.getElementsByTagName("Item");
var length = items.length;
if (!length) {
ph("not found \"" + keyword + "\" by amazon. ");
return;
}
ph("amazon search result:\"" + keyword + "\":(" + length + ") ");
for(var i=0,item;item = items[i];i++){
var link = item.getElementsByTagName("DetailPageURL")[0].textContent;
var attrs = item.getElementsByTagName("ItemAttributes")[0];
var title = attrs.getElementsByTagName("Title")[0].textContent;
var M_IMG = item.getElementsByTagName("MediumImage")[0];
var line = $tag("div");
with(line.style){
background = "transparent";
width = "100%";
padding = "2px";
borderBottom = "1px dotted #333333";
}
if(M_IMG){
var img_url =
M_IMG.getElementsByTagName("URL")[0].textContent;
var img =$tag("img",{src:img_url});
img.style.display = "block";
$add(line, img);
}
cui.output($add(line,
$tag("a",
{href:link,
textContent:"\"" + title + "\" "})));
}
};
amazonComlet.executeAux = function(command, keyword){
var url = "http://webservices.amazon.co.jp/onca/xml";
var params = {
Service:"AWSECommerceService",
SubscriptionId:"0JWRDGQGA4HQ9MGH63G2",
AssociateTag:"gonikki-22",
Operation:"ItemSearch",
SearchIndex:"Books",
ResponseGroup:"Medium",
Keywords:keyword
};
var self = this;
var func = function(xhr){
var xml = xhr.responseText;
self.parse(keyword, xml);
};
XHR.get(url, params, func);
ph("I'll search \"" + keyword + "\" by amazon... ");
};
function through(data){
return data;
}
var flickrComlet = new Comlet("flickr");
flickrComlet.executeAux = function (command, keyword) {
var params = {api_key: "68cc97afffd6cb18f2396305bef9cc17",
method:"flickr.photos.search",
per_page:"10",
sort:"date-posted-desc",
format:"json",
jsoncallback : 'through',
text:keyword
};
var url = 'http://www.flickr.com/services/rest/';
var self = this;
var func = function(xhr){
var json = eval(xhr.responseText);
self.parse(keyword, json);
};
XHR.get(url, params, func);
ph("I'll search \"" + keyword + "\" by flickr... ");
};
flickrComlet.parse = function (keyword, data){
if (!data.photos ) return;
var list = data.photos.photo;
if (!list) return;
var length = list.length;
if (!length) {
ph("not found \"" + keyword + "\".");
return;
}
cui.output("flickr search result:\"" + keyword + "\":(" + length + ") ");
list.forEach(function(photo){
var a = $tag("a", {href:'http://www.flickr.com/photos/'+
photo.owner+'/'+photo.id+'/'});
var img = $tag("img", {src:'http://static.flickr.com/'+photo.server+
'/'+photo.id+'_'+photo.secret+'_s.jpg'});
p($add(a, img, photo.title));
});
};
var twitterSearchComlet = new Comlet("search");
twitterSearchComlet.executeAux = function(command, keyword){
var params = {keyword: keyword};
var url = 'http://twitter.1x1.jp/rss/search/';
var self = this;
var func = function(xhr){
self.parse(keyword, xhr.responseText);
};
XHR.get(url, params, func);
ph("I'll search \"" + keyword + "\" by twitter search... ");
};
twitterSearchComlet.parse = function (keyword, xml){
// Can't parse responseText as xml. I don't know why...
// Instead of using xml parser, I use innerHTML technique.
// But, "link" tag was maintained as no-content tag by that technique.
// So, I get text-content of "link" tag from "link"-tag's next sibling.
// What darty code! :-(
var doc = $tag("div", {innerHTML:xml});
var items = doc.getElementsByTagName("item");
var length = items.length;
if (!length) {
ph("not found \"" + keyword + "\" by twitter search. ");
return;
}
cui.output("twitter search result:\"" + keyword + "\":(" + length + ") ");
for(var i=length-1;i>=0;i--){
var item = items[i];
var link = $child(item, "link");
var a = $tag("a", {href:link.nextSibling.textContent});
var user = $tag("span", {textContent:$child(item, "title").textContent});
var desc = $tag("div", {textContent:$child(item, "description").textContent});
var pubDate = $child(item, "pubdate");
var time = $tag("span", {textContent:new Date(pubDate.textContent).gotinFormat()});
p($add($tag("div"),
$add($tag("div"),
user,
$add(a, time)),
desc));
}
};
var closeComlet = new Comlet("close");
closeComlet.executeAux = function(command, args){
twitterWin.hide();
};
var minComlet = new Comlet("min");
minComlet.executeAux = function(command, args){
twitterWin.showOnlyTitle();
};
var jsComlet = new Comlet("js");
function p(s){
cui.outputLine(s);
}
function ph(s){
cui.outputHTML(s + "");
}
var print = ph;
function timer(t){
setTimeout(function(){
ph(t + "seconds!");
}, t * 1000);
return "timer start:" + t + "seconds";
}
jsComlet.executeAux = function(command, script){
if(!script){
ph("js command usage: js [javascript]");
return;
}
try{
var result = eval(script);
if(result != 0 && result != "" && !result){
return;
}
ph(result);
}catch(e){
ph(e);;
}
};
var modeComlet = new Comlet("mode");
modeComlet.executeAux = function(command, arg){
if(arg == "friend" || arg == "public"){
twitterApp.mode = arg;
ph("set timeline mode :" + arg);
twitterApp.setTimelineMode(arg);
} else if(arg == "auto"){
if(!twitterApp.autoReload){
twitterApp.autoReload = true;
twitterApp.reload();
}
ph("set auto-reload mode");
} else if(arg == "stop"){
twitterApp.autoReload = false;
ph("stop auto-reload mode");
} else {
ph("mode command usage: mode [friend|public]");
}
};
GM_registerMenuCommand("show twitter-lite",
function(){
twitterWin.show();
twitterApp.start();
});
var helpComlet = new Comlet("help");
helpComlet.executeAux = function(arg){
};
}
if(unsafeWindow.parent==unsafeWindow){
run();
var style = <><![CDATA[
.__twitter_record__ {
color:black;
font-weight:normal;
font-style:normal;
font-family:courier new;
text-decoration:normal;
}
.__twitter_record__ a {
color:blue;
text-decoration:underline;
font-weight:normal;
font-style:normal;
font-family:courier new;
}
]]>
</>;
GM_addStyle(style);
}
})();