d2jsp
Log InRegister
d2jsp Forums > d2jsp > General Help > One-click Add Any Bbcode To Any Text Field On Jsp > Greasemonkey Script
Prev12345Next
Add Reply New Topic
Banned
Posts: 2,525
Joined: Jan 2 2012
Gold: 0.01
Warn: 10%
Feb 4 2012 01:10pm
Quote (batman2 @ 4 Feb 2012 20:07)
in followed your instructions, but it does nothing.
File is saved as a .js, not a TXT.
i have greasmonkey installed, and the userscripted installed, both enabled
nothing happens though.


did you use the newest version from last post?
do you have something like noscript enabled?

Can you check the error console? ctrl+shift+j, click clear, select "errors", then reload jsp (e.g. this topic) and see if something shows up.
Member
Posts: 1,648
Joined: Jan 17 2012
Gold: Locked
Trader: Scammer
Warn: 10%
Feb 4 2012 01:14pm
Thanks works fine for me now
Member
Posts: 13,294
Joined: Jul 30 2011
Gold: 10.00
Feb 4 2012 01:21pm
Test

This post was edited by Roflmfao6 on Feb 4 2012 01:22pm
Banned
Posts: 2,525
Joined: Jan 2 2012
Gold: 0.01
Warn: 10%
Feb 4 2012 03:02pm
UPDATE
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("[B][COLOR=Purple]", "[/COLOR][/B]");
  }
 }
}
]

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');
if (ppx.length == 0) {
 ppx = document.getElementsByName("note");
}
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" + bbcode_in + "\n" + link_in + "\n" + __insf + "\n\n__insf();";
__insb.type = "text/javascript";
document.getElementsByTagName('head')[0].appendChild(__insb);



- Now it supports guild chat too (or should, no way to test :P)
- you can now easily put buttons into your bookmark's bar if you don't like floating transparent ninjas!

To do so, make sure your personal bar is enabled (or you see all bookmarks) and create a bookmark in form:
Code

name: any name you want
url: javascript:bbcode_in("opening tag", "closing tag");


so for example button to bold your text could look:
Code

name: bold
url: javascript:bbcode_in("[b]", "[/b]");


and it sits in your bookmarks - click it and you have bold text. Why that way? Because it's easier to edit and add more buttons. Whatever you prefer :) some people will still prefer ninjas, both work!

thanks for all donations too :)

Quote

install procedure
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.

Member
Posts: 64,749
Joined: Oct 10 2008
Gold: 10,357.30
Feb 5 2012 12:44am
Works!
Banned
Posts: 2,525
Joined: Jan 2 2012
Gold: 0.01
Warn: 10%
Feb 7 2012 01:04pm
I'll bump it every few days if you don't mind, so more people might like it :^

enjoy. And always check last post for newest version.

At least 3 people actively use it now, yay :P
Member
Posts: 14,754
Joined: Dec 14 2006
Gold: 0.00
Feb 8 2012 01:55am
Latest update won't work for me no matter what I do, or what browser I use, all others worked fine.
I was really excited about the guild chat color finally working.
Is the update strictly bookmark version or does it also include ninja icon?
Banned
Posts: 2,525
Joined: Jan 2 2012
Gold: 0.01
Warn: 10%
Feb 8 2012 04:48am
I know you use aurora, and few days ago it stopped working for me too: But it wasn't because of script, but because of scriptish you (and me) use. Aurora seems to be updated few times a day, and one of them broke scriptish. The scriptish was still there, had its menu items, but when I went to tools -> scriptish -> manage user scripts it opened normal extension managament, not userscript. The latter wasn't there at all.

Solution is to reinstall scriptish completly:
- uninstall scriptish, restart aurora
- go to scriptish addon https://addons.mozilla.org/en-US/firefox/addon/scriptish/
- click "add to firefox", and confirm you want to do this on unsupported version, restart aurora
- install script just fine.

It will work with ninja icon AND bookmarks, depends what you prefer. And guild chat should be fixed.

Let me know if there is any other hidden from me place where it should work :P

This post was edited by ikusus on Feb 8 2012 04:50am
Banned
Posts: 2,525
Joined: Jan 2 2012
Gold: 0.01
Warn: 10%
Feb 10 2012 01:07pm
Quote (ikusus @ 7 Feb 2012 20:04)
I'll bump it every few days if you don't mind, so more people might like it :^

enjoy. And always check last post for newest version.

At least 3 people actively use it now, yay :P


Should have a nice update soon.

Vote for graphic editor for buttons and I might do it finally :P
Member
Posts: 1,251
Joined: Feb 19 2012
Gold: 160.95
Feb 23 2012 04:23am
I dunno, been trying to get this to work in FF10.
There's no ninja icon, greasemonkey has a little JS icon on the top instead. It recognizes the BBcode script in the list of scripts but when I hit Add reply over here and type something in, then click...nothing happens.

ISO some help.
Go Back To General Help Topic List
Prev12345Next
Add Reply New Topic