// ==UserScript==
// @name            Tag Buttons 2
// @namespace       http://www.kuribo.info/
// @author          kuribo
// @include         https://www2.blogger.com/comment.g?*
// @include         https://www2.blogger.com/comment.do
// @include         https://www.blogger.com/comment.g?*
// @include         https://www.blogger.com/comment.do
// @description     Tag Buttons 2
// ==/UserScript==

(function() {
var s = document.createElement("script");
s.innerHTML = "function insertTag(t,p){var el=document.getElementById('comment-body');var start=el.selectionStart;var end=el.selectionEnd;var body=el.value;body=body.substring(0,end)+'</'+t+'>'+body.substring(end);body=body.substring(0,start)+'<'+t+((p)?' '+p:'')+'>'+body.substring(start);el.value=body;var selection=start+2+t.length+((p)?p.length+1:0)+((start==end)?0:end-start+3+t.length);el.selectionStart=selection;el.selectionEnd=selection;el.focus();}function insertLink(){var url;var el=document.getElementById('comment-body');if(url=prompt('Enter URL.','http://')){insertTag('a','href=\"'+url+'\"');}}";
document.body.appendChild(s);



var el = document.getElementById("cbody");
var tagbuttonstyle = "<style type=\"text/css\">.tagbutton {border-bottom:0 !important;}.tagbutton img {margin-right:10px;}.tagbutton:hover img {background-color: #e1d4c0;}</style>";
var tagbutton = "<a href=\"javascript:insertTag('b', '');\" class=\"tagbutton\"><img src=\"http://tools.kuribo.info/tagbutton/gl.bold.gif\" width=\"18\" height=\"18\" alt=\"b\" title=\"Insert B Tags.\"/></a><a href=\"javascript:insertTag('i', '');\" class=\"tagbutton\"><img src=\"http://tools.kuribo.info/tagbutton/gl.italic.gif\" width=\"18\" height=\"18\" alt=\"i\" title=\"Insert I Tags.\" /></a><a href=\"javascript:insertLink();\" class=\"tagbutton\"><img src=\"http://tools.kuribo.info/tagbutton/gl.link.gif\" width=\"18\" height=\"18\" alt=\"a\" title=\"Insert A Tags.\" /></a>";
el.innerHTML = el.innerHTML.replace("<textarea class=\"comment\"", tagbuttonstyle + tagbutton + "<textarea class=\"comment\"");
//alert(el.innerHTML);
})();

