this is the most recant source:



Code:

// ==UserScript==
// @name       test
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description  enter something useful
// @match      http://stackoverflow.com/questions/2744423/javascript-bbcode-parser-recognizes-only-first-list-element
// @copyright  2012+, You
// ==/UserScript==
function parse(str) {
search = new Array(
      RegExp('/\[karma\](.*?)\[\/karma\]/gi',"gi"),
      RegExp('spud2451',"gi"),
      RegExp('KermMartian',"gi"),
      RegExp('ComicIdiot',"gi"),
      RegExp('tifreak8x',"gi"),
      RegExp('LuxenD',"gi"));

replace = new Array(
      '<input type="button" value="$1++" onClick="document.getElementById(\'saxtalk\').value = \'$1++\';saxAdd();">',
      'Spud',
      'Kerm',
      'Comic',
      'TI-Freak',
      'Luxen');

for (i = 0; i < search.length; i++) {
    str = str.replace(search[i], replace[i]);
}

return str;}

document.body.innerHTML = parse(document.body.innerHTML);
You should change your first reguler expression a bit, currently you could easily inject some javascript code by putting something like
[karma]';alert('test');'[/karma]
I'd suggest something like RegExp('/\[karma\]([a-zA-Z0-9 ]*?)\[\/karma\]/gi',"gi"),
That's a good point, I think I will!
how come this messes up the page?


Code:

function parse(str) {
search = new Array(
      RegExp('/\[karma\]([a-zA-Z0-9 ]*?)\[\/karma\]/',"gi"),
      RegExp('/\[size\=(.*?)\](.*?)\[\/size\]/',"gi"),
      RegExp('Spud',"gi"),
      RegExp('Kerm',"gi"),
      RegExp('Comic',"gi"),
      RegExp('tifreak8x',"gi"),
      RegExp('Luxen',"gi"));

replace = new Array(
      '<input type="button" value="$1++" onClick="document.getElementById(\'saxtalk\').value = \'$1++\';saxAdd();">',
      '<font size="$1">$2</font>',
      'Spud',
      'Kerm',
      'Comic',
      'TI-Freak',
      'Luxen');

for (i = 0; i < search.length; i++) {
    str = str.replace(search[i], replace[i]);
}

return str;}

document.body.innerHTML = parse(document.body.innerHTML);


EDIT: Never mind I figured it out!
I'm not familiar with REGEX but if it is case sensitive it won't ever match my name as you have it, my first word is lowercase and the second word is uppercase. But, if it works fine don't worry about it Smile


Code:
RegExp('ComicIdiot',"gi")


Why do you change it to just one word in the second post?


Code:
RegExp('Comic',"gi"),
Actually the script did it, because it automaticly changed it even though it was in the text box.
My improved ++ script! actually redone from scratch


Code:
function getElementsByClassName(node, classname) {
    var a = [];
    var re = new RegExp('(^| )'+classname+'( |$)');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}
var names = getElementsByClassName(document,'name');
for (var el in names) {
   var ih = names[el].getElementsByTagName("b")[0].innerHTML;
   names[el].innerHTML += ' <a href="javascript:void(0);" onClick="document.getElementById(\'saxtalk\').value = \''+ ih + '++\';saxAdd();"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAASCAYAAABM8m7ZAAACkElEQVR42rWW204UQRCG90V8AnwAn4UETFCUaPCWK1wOGzZgojeauOMNMUoAl6zxRm9MJ5pwQcjOns/n81uU9ddSsz3DAEZkk2F3uqr7q/q7uppIxPo4Kw9pbe7enTzO6mOKBD/H8U0xJhj8K5WkVqtFnU6Her0e9ft9Gg6HNB6PaTQayW+Mdbtd8YFvs9mger1O1WqVKpUKlUolKhQKlM/nKZvN0o/PH+ndo3lhnLzZmwWAgeTuNtVqNWo0GrxQk9rttiwOyGAwEKjC8Y6gYIcf/DEP8wEul8tULBYFnsvlKJPJkOu6dLC9LvCpvM+X6P2TBXHGRF4kyotFedEoQ+XhLFMMNPxtGGoYathu2Ncw0PA8w0B5GGgY6Gq2gNrqvuXMndVlkmx/Hh+IPJALkf+N1LBpttfJHAR//7RPLx/cn4LheBU4KDOgusfT/fWDbYkBhsT6G0GcnZ5O5cYfRIcJusc37a+CwzK+Cmy/e2AMwhmTFexlrFIz1C4s2NucsRaVgC+KConYILzrGLL2wHCAQcFhUn97HZcJPvBFxl/iG2LTPQ6CkZStggdGFBj8FzB8bwJDBVsJDwwjnGwwFv2fYLvaPXA6nZasqxU/GAXkPF0MbYGpVzFK8PkPsx3G1n2VDLDdVHxgRAajdi6VGxmiuDTjSwXGAZ7sbokNiiGzYNfCu6rhnp/PwDjUgMP5tuCwdqknBjY0K2kgH14sE9pYEGyfZe1cwV5tV7ae5TCw9ghkjfbsPFsi75JAA8ee6H5gESyGRVUBVUEr3m6p2ljUrk/LOuvJvdjsksAHVxUGcHXhCtNzra0UkYbdXHbVTyYTUUSDsBX5/TUpVy4YRzsbl+9lXNZ39Y9AYmXRB/wDaTtQkxaZAXIAAAAASUVORK5CYII=" /></a>';
}


what do you think?

ideas:
fix image vertical dumb looking
username(by avatar) links to profile
IRC link next to sax w/auto login

any others?
yay, also, a little suggestion:
These two codes are the same:

Code:

var myvar = 2;
var myothervar = 5;
var mynextawesomevar = 'test';

and

Code:

var myvar = 2,
    myothervar = 5,
    mynextawesomevar = 'test';
Does anyone have any ideas or suggestions for the next version of the Cemetech userscript?

Edit: this is a test of the newest tag!

[style=background-color: red; color: white;width:100px;]this is a test[/style]

[exe]alert('hello world');[/exe]
Here's an updated script with the new style tag included:

ps. please view with script off

Code:

// ==UserScript==
// @name       Cemetech Ultimate User Script
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description A small but usefull userscript for the cemetech.net website
// @match      www.cemetech.net/*
// @exclude    http://www.cemetech.net/forum/posting.php?mode=editpost*
// @copyright  2012+, You
// ==/UserScript==

function parse(str) {
search = new Array(
      /\[karma\](.*?)\[\/karma\]/gi,
      /spud2451/gi,
      /KermMartian/gi,
      /ComicIdiot/gi,
      /tifreak8x/gi,
      /LuxenD/gi,
      /\[style=(.*?)\](.*?)\[\/style\]/gi
);

replace = new Array(
      '<input type="button" value="$1++" onClick="document.getElementById(\'saxtalk\').value = \'$1++\';saxAdd();"/>',
      'Spud',
      'Kerm',
      'Comic',
      'TI-Freak',
      'Luxen',
     '<div style="$1">$2</div>'
);

for (i = 0; i < search.length; i++) {
    str = str.replace(search[i], replace[i]);
}

return str;}

document.body.innerHTML = parse(document.body.innerHTML);
Here's a demo of the style tag. This uses no images!

[style=background-color: #ff3333; border-width: 10px; border-style:solid; border-color:#ff3333; border-radius: 10px; box-shadow: 10px 10px 10px rgba(0,0,0,0.5) ;width: 300px; height: 300px;text-align: center;] Content Here [/style]
spud2451 wrote:
Here's a demo of the style tag. This uses no images!

[style=background-color: #ff3333; border-width: 10px;border-color:#ff3333; border-radius: 10px; box-shadow: 10px 10px 10px rgba(0,0,0,0.5) ;width: 300px; height: 300px;text-align: center;] Content Here [/style]


Any chance there will be a preview image for those of us who don't have this installed?
sure!
Update!
A new tag was added: [script]


Code:

// ==UserScript==
// @name       Cemetech Ultimate User Script
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description A small but usefull userscript for the cemetech.net website
// @match      www.cemetech.net/*
// @exclude    http://www.cemetech.net/forum/posting.php?mode=editpost*
// @copyright  2012+, You
// ==/UserScript==

function parse(str) {
search = new Array(
      /\[karma\](.*?)\[\/karma\]/gi,
      /spud2451/gi,
      /KermMartian/gi,
      /ComicIdiot/gi,
      /tifreak8x/gi,
      /LuxenD/gi,
      /\[style=(.*?)\](.*?)\[\/style\]/gi,
      /\[script\](.*?)\[\/script\]/gi
);

replace = new Array(
      '<input type="button" value="$1++" onClick="document.getElementById(\'saxtalk\').value = \'$1++\';saxAdd();"/>',
      'Spud',
      'Kerm',
      'Comic',
      'TI-Freak',
      'Luxen',
     '<div style="$1">$2</div>',
      '<input type="button" value="Press to execute javascript" onclick="$1"/>'
);

for (i = 0; i < search.length; i++) {
    str = str.replace(search[i], replace[i]);
}

return str;}

document.body.innerHTML = parse(document.body.innerHTML);
Also people, feel free to add your own tags to the script and post them!
This is hideously insecure.

[script]"autofocus="true" onfocus="alert('pwnt');"[/script]

It would have been easier if I didn't have to work around the syntax highlighter script for code blocks, but this works too.
I would love for more people to get involved with this project. I did say in the original post that I wanted it to be a community project. So if your interested in helping out feel free to just take the code and modify it then post it, if we like it we might just add it to the official script. Also if you feel like there is a feature we are missing then please let us know! And by us I mean the community! happy coding!
-spud2451
IMPORTANT!!!

All posts regarding this script should be directed Here
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement