// ==UserScript==
// @name           cocoPostProxy
// @namespace      http://furyu-tei.sakura.ne.jp/
// @description    Use Poxy to post a comment to Cocolog. ver.0.01a
// @include        http://*
// ==/UserScript==

(function(w,d){

try{if(top!==self)throw 'NotTopWindow'}catch(e){return}
var	is_cocolog=!!(w.location.href.match(/^http:\/\/[^\/]*-nifty\.com\//));
if (!is_cocolog) {
	var	links=d.getElementsByTagName('link');
	for (var ci=0,len=links.length; ci<len; ci++) {
		var	link=links[ci];
		if (link.title&&link.title.toUpperCase()=='RSD') {
			if (link.href&&link.href.match(/^https?:\/\/app\.(?:f\.)?cocolog-nifty\.com\//)) {
				is_cocolog=true;
				break;
			}
		}
	}
}
if (!is_cocolog) return;

var form=d.getElementById('comment-form') || d.forms['comments_form'] || d.forms['comment-form'];
if (!form) return;

form.action="http://furyu-tei.sakura.ne.jp/cgi-bin/cocoPostProxy"+(form.action.match(/app\.f/)?"Free":"")+ ".cgi";
var inps=form.getElementsByTagName('input');
for (var ci=0,len=inps.length; ci<len; ci++) {
	var elm=inps[ci];
	if (elm.type!='submit') continue;
	with (elm.style) {
		color='blue';
		cursor='pointer';
	}
	elm.title='Proxy\u4f7f\u7528';
	var	onmouseover=function(){
		w.status=form.action;
	};
	try {
		if (elm.addEventListener) elm.addEventListener('mouseover',onmouseover,false);
		else if (elm.atachEvent) elm.attachEvent('onmouseover',onmouseover);
		else elm.onmouseover=onmouseover;
	} catch(e) {}
}

})(window,document);

