well, make sure you really see file extensions, it should just work :F
Anyway, small update. Now it doesn't load external scripts and is really simplified, while providing a way to bind to other events (e.g. mouse over icon instead of clicking).
INSTALL:1. uninstall old version
2. create empty file called color.user.js -
make sure it doesn't end in .txt - windows often hides file extensions, disable that!3. paste following code into it, edit buttons section (to have bbcode of your choice) save and exit
4a. (firefox only) install scriptish or greasemonkey if you didn't already
4b. drag and drop the file into chrome/firefox window.
Code// ==UserScript==
// @name D2JSP custom bbcode button
// @namespace MEH
// @description adds custom bbcode buttons
// @author ikusus
// @license wtfpl
// @include
http://forums.d2jsp.org/*.php*// @version 1
// ==/UserScript==
function __insf() {
var buttons = [
{
"name": "color",
"html": "<img src='http://forums.d2jsp.org/html/emoticons/ph34r.gif' />",
"code": {
"click": function() {
bbcode_in("
", "");
}
}
}
]
var box = document.createElement("div");
box.setAttribute("class", "bbcodebox" );
for( i in buttons ) {
var a = document.createElement("a");
qc = buttons[i]["code"];
for( j in qc )
a.addEventListener( j, qc[j], false );
a.innerHTML = buttons[i]["html"];
a.title = buttons[i]["name"];
box.appendChild( a );
}
document.body.appendChild( box );
function bbcode_in(_o,_c) {
_t = "";
var ppx = document.getElementsByName('Post');
for(iq in ppx) {
p = ppx[iq];
if( p )
p.focus();
ms=_o.length;
if(document.selection && document.selection.createRange) {
var s = document.selection.createRange();
_x=s.text!=""?s.text:_t;
s.text = txt = _o+_x+_c;
s.moveStart('character',-txt.length+ms);
s.moveEnd('character',-txt.length+ms+_x.length);
s.select();
} else if(p.selectionStart!='undefined') {
_s=p.selectionStart;
_e=p.selectionEnd;
_x=p.value.substring(_s,_e);
if(_x=="")_x=_t;
txt = _o+_x+_c;
p.value=p.value.substr(0,_s)+txt+p.value.substr(_e);
p.selectionEnd=p.selectionStart=_s+ms;
p.selectionEnd+=_x.length;
} else{
p.value+=_o+_c;
}
}
}
function link_in(url) {
document.location = url;
}
}
var style = document.createElement("style");
style.type = "text/css";
style.innerHTML = "div.bbcodebox{ color: #000; width: 30px; position: fixed; top: 0px; left: 0px; opacity: 0.1; z-index: 9999999; }\n";
style.innerHTML += "div.bbcodebox:hover{ opacity: 1; }\n";
style.innerHTML += "div.bbcodebox a{ color: #fff;cursor: pointer; display: block;}\n";
document.getElementsByTagName("head")[0].appendChild(style);
var __insb = document.createElement("script");
__insb.textContent = "\n" + __insf + "\n\n__insf();";
__insb.type = "text/javascript";
document.getElementsByTagName('head')[0].appendChild(__insb);
After refreshing forums.d2jsp.org you should get this little transparent ninja:
http://i.imgur.com/jnCbm.png
If you hover it with your mouse it'll be more visible:
http://i.imgur.com/Cu46S.png
When you click it, it'll add
purple bold text bbcode (by default; edit buttons section to suit your needs; pm me in case of trouble)
AH. One more thing. If you use noscript or simillar you might need to disable it for forums.d2jsp.org for this to work!
when they save it.