Skip to content

Instantly share code, notes, and snippets.

@diceroll123
Last active February 18, 2023 03:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save diceroll123/2b8fc93b9bf25c2c1664 to your computer and use it in GitHub Desktop.
Save diceroll123/2b8fc93b9bf25c2c1664 to your computer and use it in GitHub Desktop.
Allows you to see your neoHTML changes in realtime!
// ==UserScript==
// @name Neopets - Live Neoboards Signature Editor
// @author diceroll123
// @match *://*.neopets.com/neoboards/preferences.phtml*
// ==/UserScript==
function html_escape(string) {
// Create a node, give it the input string as text, and read the resulting escaped HTML.
return $('<div/>').text(string).html();
}
function makeCounter(textbox) {
$("[name='" + textbox + "']").after('<div align="center" id="' + textbox + 'Counter"></div>');
}
function counter(textbox) {
current = $("[name='" + textbox + "']").val().length;
maxlength = $("[name='" + textbox + "']").attr("maxlength");
message = current + "/" + maxlength;
if(current == maxlength) {
message = "<b>" + message + "</b>";
}
$("#" + textbox + "Counter").html(message);
}
// preview warning
$("b:contains(Preview)").after(" - <i>Using /u/diceroll123's Live Preview script. If you forget to close your tags, it may look fixed, but will not save that way.</i>");
makeCounter("neoHTML");
makeCounter("neoSig");
function neohtml2html(string) {
var fontstuff = [];
fontstuff['c='] = ' color=';
fontstuff['f='] = ' face=';
fontstuff['s='] = ' size=';
var smilies = [];
smilies[':)'] = 'smiley';
smilies['*clap*'] = 'clap';
smilies[':('] = 'sad';
smilies['*cough*'] = 'cough';
smilies[':K'] = 'vampire';
smilies['*angry*'] = 'angry';
smilies['B)'] = 'sunglasses';
smilies['*complain*'] = 'complain';
smilies[':O'] = 'oh';
smilies['*moneybag*'] = 'moneybag';
smilies[':P'] = 'tongue';
smilies['*star*'] = 'star';
smilies[';)'] = 'winking';
smilies['*yarr*'] = 'yarr';
smilies[':*'] = 'kisskiss';
smilies['*carrot*'] = 'carrot';
smilies[':D'] = 'grin';
smilies['0:'] = 'angel';
smilies['*unsure*'] = 'unsure';
smilies['*lol*'] = 'lol';
smilies['*cry*'] = 'cry';
smilies['*facepalm*'] = 'facepalm';
smilies['*codestone*'] = 'codestone';
smilies['*dubloon*'] = 'dubloon';
smilies['*sloth*'] = 'sloth';
smilies['*dung*'] = 'dung';
smilies['*coltzan*'] = 'coltzan';
smilies['*mrcoconut*'] = 'mrcoconut';
smilies['*hanso*'] = 'hanso';
smilies['*jazan*'] = 'jazan';
smilies['*happiness*'] = 'happinessfaerie';
smilies['*flower*'] = 'flower';
smilies['*illusen*'] = 'illusen';
smilies['*jhudora*'] = 'jhudora';
smilies['*babypb*'] = 'babypb';
smilies['*faeriepb*'] = 'faeriepb';
smilies['*piratepb*'] = 'piratepb';
smilies['*dariganpb*'] = 'dariganpb';
smilies['*bff*'] = 'bff';
smilies['*baf*'] = 'baf';
smilies['*bef*'] = 'bef';
smilies['*bdf*'] = 'bdf';
smilies['*blf*'] = 'blf';
smilies['*bwf*'] = 'bwf';
smilies['*swabbie*'] = 'swabbie';
smilies['*boatswain*'] = 'boatswain';
smilies['*cabinboy*'] = 'cabinboy';
smilies['*cook*'] = 'cook';
smilies['*gunner*'] = 'gunner';
smilies['*mate*'] = 'mate';
smilies['*quartermaster*'] = 'quartermaster';
smilies['*rigger*'] = 'rigger';
smilies['*rower*'] = 'rower';
smilies['*kqkey*'] = 'kqkey';
smilies['*bree*'] = 'bree';
smilies['*kqdoor*'] = 'kqdoor';
smilies['*bgc*'] = 'bgc';
smilies['*suap*'] = 'suap';
smilies['*mspp*'] = 'mspp';
smilies['*0.'] = '0';
smilies['*tombstone*'] = 'tombstone';
smilies['*nox*'] = 'nox';
smilies['*aaa*'] = 'aaa';
smilies['*abigail*'] = 'abigail';
smilies['*lulu*'] = 'lulu';
smilies['*sock*'] = 'sock';
smilies['*turmaculus*'] = 'turmaculus';
smilies['*snowager*'] = 'snowager';
smilies['*paperlantern*'] = 'paperlantern';
smilies['*firecrackers*'] = 'firecrackers';
smilies['*luckydraik*'] = 'luckydraik';
smilies['*shamrock*'] = 'shamrock';
smilies['*brynn*'] = 'brynn';
smilies['*nabile*'] = 'nabile';
smilies['*physical*'] = 'physical';
smilies['*light*'] = 'light';
smilies['*dark*'] = 'dark';
smilies['*earth*'] = 'earth';
smilies['*air*'] = 'air';
smilies['*water*'] = 'water';
smilies['*fire*'] = 'fire';
smilies['*monocle*'] = 'monocle';
smilies['*indubitably*'] = 'indubitably';
smilies['*tophat*'] = 'tophat';
smilies['*negg*'] = 'negg';
smilies['*happynegg*'] = 'happynegg';
smilies['*angrynegg*'] = 'angrynegg';
smilies['*festivalnegg*'] = 'festivalnegg';
smilies['*lawyerbot*'] = 'lawyerbot';
smilies['*angrylawyerbot*'] = 'angrylawyerbot';
smilies['*omelette*'] = 'omelette';
smilies['*shopwiz*'] = 'shopwiz';
smilies['*eventidepppb*'] = 'eventidepppb';
smilies['*eventidepb*'] = 'eventidepb';
smilies['*velm*'] = 'velm';
smilies['*rohane*'] = 'rohane';
smilies['*mipsy*'] = 'mipsy';
smilies['*talinia*'] = 'talinia';
smilies['*jellykacheek*'] = 'jellykacheek';
smilies['*jelly*'] = 'jelly';
smilies['*cake*'] = 'cake';
smilies['*cookie*'] = 'cookie';
smilies['*stonepie*'] = 'stonepie';
smilies['*pie*'] = 'pie';
smilies['*capn3legs*'] = 'capn3legs';
smilies['*techomaster*'] = 'techomaster';
smilies['*bacon*'] = 'bacon';
smilies['*tigerfruit*'] = 'tigerfruit';
smilies['*starberry*'] = 'starberry';
smilies['*twirlyfruit*'] = 'twirlyfruit';
smilies['*blurf*'] = 'blurf';
smilies['*swipe*'] = 'swipe';
smilies['*yarn*'] = 'yarn';
smilies['*coffee*'] = 'coffee';
smilies['*tea*'] = 'tea';
smilies['*rballoon*'] = 'rballoon';
smilies['*gballoon*'] = 'gballoon';
smilies['*yballoon*'] = 'yballoon';
smilies['*bballoon*'] = 'bballoon';
smilies['*moon*'] = 'moon';
smilies['*fishnegg*'] = 'fishnegg';
smilies['*fyora*'] = 'fyora';
smilies['*islandpb*'] = 'islandpb';
smilies['*maractitepb*'] = 'maractitepb';
smilies['*woodlandpb*'] = 'woodlandpb';
smilies['*wraithpb*'] = 'wraithpb';
smilies['*chadley*'] = 'chadley';
smilies['*dreamy*'] = 'dreamy';
smilies['*scroll*'] = 'scroll';
smilies['*map*'] = 'map';
smilies['*popcorn*'] = 'popcorn';
smilies['*icecream*'] = 'icecream';
smilies['*cupcake*'] = 'cupcake';
smilies['*book*'] = 'book';
smilies['*wizard*'] = 'wizard';
smilies['*genie*'] = 'genie';
smilies['*battleduck*'] = 'battleduck';
smilies['*dbd*'] = 'dbd';
smilies['*bluesand*'] = 'bluesand';
smilies['*greensand*'] = 'greensand';
smilies['*orangesand*'] = 'orangesand';
smilies['*pinksand*'] = 'pinksand';
smilies['*cloud*'] = 'cloud';
smilies['*raincloud*'] = 'raincloud';
smilies['*ummagine*'] = 'ummagine';
smilies['*acara*'] = 'acara';
smilies['*kyrii*'] = 'kyrii';
smilies['*aisha*'] = 'aisha';
smilies['*lenny*'] = 'lenny';
smilies['*blumaroo*'] = 'blumaroo';
smilies['*lupe*'] = 'lupe';
smilies['*bori*'] = 'bori';
smilies['*lutari*'] = 'lutari';
smilies['*bruce*'] = 'bruce';
smilies['*meerca*'] = 'meerca';
smilies['*buzz*'] = 'buzz';
smilies['*mynci*'] = 'mynci';
smilies['*chia*'] = 'chia';
smilies['*moehog*'] = 'moehog';
smilies['*chomby*'] = 'chomby';
smilies['*nimmo*'] = 'nimmo';
smilies['*cybunny*'] = 'cybunny';
smilies['*ogrin*'] = 'ogrin';
smilies['*draik*'] = 'draik';
smilies['*peophin*'] = 'peophin';
smilies['*elephante*'] = 'elephante';
smilies['*poogle*'] = 'poogle';
smilies['*eyrie*'] = 'eyrie';
smilies['*pteri*'] = 'pteri';
smilies['*flotsam*'] = 'flotsam';
smilies['*quiggle*'] = 'quiggle';
smilies['*gelert*'] = 'gelert';
smilies['*ruki*'] = 'ruki';
smilies['*gnorbu*'] = 'gnorbu';
smilies['*scorchio*'] = 'scorchio';
smilies['*grarrl*'] = 'grarrl';
smilies['*shoyru*'] = 'shoyru';
smilies['*grundo*'] = 'grundo';
smilies['*skeith*'] = 'skeith';
smilies['*hissi*'] = 'hissi';
smilies['*techo*'] = 'techo';
smilies['*ixi*'] = 'ixi';
smilies['*tonu*'] = 'tonu';
smilies['*jetsam*'] = 'jetsam';
smilies['*tuskaninny*'] = 'tuskaninny';
smilies['*jubjub*'] = 'jubjub';
smilies['*uni*'] = 'uni';
smilies['*kacheek*'] = 'kacheek';
smilies['*usul*'] = 'usul';
smilies['*kau*'] = 'kau';
smilies['*wocky*'] = 'wocky';
smilies['*kiko*'] = 'kiko';
smilies['*xweetok*'] = 'xweetok';
smilies['*korbat*'] = 'korbat';
smilies['*yurble*'] = 'yurble';
smilies['*kougra*'] = 'kougra';
smilies['*zafara*'] = 'zafara';
smilies['*krawk*'] = 'krawk';
smilies['*feepit*'] = 'feepit';
smilies['*meepit*'] = 'meepit';
smilies['*slorg*'] = 'slorg';
smilies['*weewoo*'] = 'weewoo';
smilies['*mootix*'] = 'mootix';
smilies['*larnikin*'] = 'larnikin';
smilies['*pinchit*'] = 'pinchit';
smilies['*kadoatie*'] = 'kadoatie';
smilies['*kadoatery*'] = 'kadoatery';
smilies['*purplebug*'] = 'purplebug';
smilies['*niptor*'] = 'niptor';
smilies['*jimmi*'] = 'jimmi';
smilies['*woogy*'] = 'woogy';
smilies['*yooyu*'] = 'yooyu';
smilies['*meowclops*'] = 'meowclops';
smilies['*zomutt*'] = 'zomutt';
smilies['*plumpy*'] = 'plumpy';
smilies['*spyder*'] = 'spyder';
smilies['*angelpuss*'] = 'angelpuss';
smilies['*warf*'] = 'warf';
smilies['*jinjah*'] = 'jinjah';
smilies['*snowbunny*'] = 'snowbunny';
smilies['*altador*'] = 'altador';
smilies['*brightvale*'] = 'brightvale';
smilies['*darigan*'] = 'darigan';
smilies['*faerieland*'] = 'faerieland';
smilies['*haunted*'] = 'hauntedwoods';
smilies['*kikolake*'] = 'kikolake';
smilies['*krawkisland*'] = 'krawkisland';
smilies['*kreludor*'] = 'kreludor';
smilies['*lostdesert*'] = 'lostdesert';
smilies['*maraqua*'] = 'maraqua';
smilies['*meridell*'] = 'meridell';
smilies['*mystery*'] = 'mysteryisland';
smilies['*moltara*'] = 'moltara';
smilies['*rooisland*'] = 'rooisland';
smilies['*shenkuu*'] = 'shenkuu';
smilies['*terror*'] = 'terrormountain';
smilies['*tyrannia*'] = 'tyrannia';
smilies['*virtupets*'] = 'virtupets';
smilies['*bauble*'] = 'bauble';
smilies['*xmastree*'] = 'xmastree';
smilies['*santa*'] = 'santa';
smilies['*rednose*'] = 'rednose';
smilies['*snowflake*'] = 'snowflake';
smilies['*present*'] = 'present';
smilies['*holly*'] = 'holly';
smilies['*snowman*'] = 'snowman';
smilies['*candycane*'] = 'candycane';
smilies['*jinjah*'] = 'jinjah';
smilies['*mistletoe*'] = 'mistletoe';
smilies['*witch*'] = 'witchhat';
smilies['*ghost*'] = 'ghost';
smilies['*spyder*'] = 'spyder';
smilies['*web*'] = 'web';
smilies['*creepyspyder*'] = 'creepyspyder';
smilies['*pumpkin*'] = 'pumpkin';
smilies['*jackolantern*'] = 'jackolantern';
smilies['*redleaf*'] = 'redleaf';
smilies['*yellowleaf*'] = 'yellowleaf';
smilies['*leafleft*'] = 'greenleafleft';
smilies['*leafright*'] = 'greenleafright';
smilies['*brownleaf*'] = 'brownleaf';
smilies['*sun*'] = 'sun';
smilies['*eekeek*'] = 'eekeek';
smilies['*aishadow*'] = 'aishadow';
smilies['*fence*'] = 'fence';
smilies['*candle*'] = 'candle';
smilies['*roses*'] = 'roses';
smilies['*heart*'] = 'heart';
smilies['*warf*'] = 'warf';
smilies['*angelpuss*'] = 'angelpuss';
smilies['*catfish*'] = 'catfish';
smilies['*violin*'] = 'violin';
smilies['*thieves*'] = 'thieves';
smilies['*sway*'] = 'sway';
smilies['*seekers*'] = 'seekers';
smilies['*awakened*'] = 'awakened';
smilies['*order*'] = 'order';
smilies['*brutes*'] = 'brutes';
string = html_escape(string);
replacement = "";
while((matches = string.match(/\[(\/)?(br|b|i|u|sup|sub|s|p|center|font)=?(.*?)\]/i)) !== null) {
tag = matches[2];
slash = matches[1];
if(slash === undefined) {
slash = "";
}
switch(tag) {
case 'br':
case 'b':
case 'i':
case 'u':
case 'sup':
case 'sub':
case 's':
case 'p':
case 'center':
replacement = "<" + slash + tag + ">"
break;
case 'font':
params = matches[3];
// neopets only allows up to font size 4
sizefix = params.match(/s=(\d+)/i);
if(sizefix !== null && parseInt(sizefix[1]) > 4) {
params = params.replace("s=" + sizefix[1], "s=4");
}
for(var key in fontstuff) {
params = params.replace(key, fontstuff[key]);
}
replacement = "<" + slash + tag + params + ">"
}
string = string.replace(matches[0], replacement);
}
for(key in smilies) {
string = string.split(key).join("<img src='http://images.neopets.com/neoboards/smilies/" + smilies[key] + ".gif'>");
}
return string;
}
function makeSig() {
neoHTML = neohtml2html($("[name='neoHTML']").val());
neoSig = neohtml2html($("[name='neoSig']").val());
if(neoHTML.substr(neoHTML.length-1) == "[" && neoSig.substr(0, 1) == "]") {
neoHTML = neoHTML.substr(0, neoHTML.length-1);
neoSig = neoSig.substr(1);
result = neoHTML + neoSig;
} else {
result = neoHTML + "<br><span style=\"color:#818181\">-------------------------</span><br>" + neoSig;
}
counter("neoHTML");
counter("neoSig");
result = result.replace("neoHTML", "This is how your post will look on the Neoboards.");
$(".topic").html("<br>" + result + "<br>");
}
$("[name='neoHTML'], [name='neoSig']").bind("keyup keydown change", makeSig);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment