deviantART - PLZ Legend

By DavidJCobb Last update Aug 31, 2008 — Installed 552 times. Daily Installs: 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 2, 0, 0, 0, 4, 0, 1, 2, 0, 0, 1, 0, 0, 0

There are 1 previous version of this script.

Add Syntax Highlighting (this will take a few seconds, probably freezing your browser while it works)

// ==UserScript==
// @name           deviantART - PLZ Legend
// @namespace      http://davidjcobb.deviantart.com/
// @description    Adds a link to comment boxes allowing you to view a legend of PLZ accounts and copy their icon codes. The legend is fully searchable.
// @include        http://*.deviantart.com/*
// ==/UserScript==

// TODO:
//  - Add links to comment boxes (next to "Emoticons", add "PLZes")
//  - Make openable from the User Script Commands menu.

unsafeWindow.PLZLegend=
{
   "SearchBusy":false,
   "CancelSearch":false,
   "LastSearchedName":"",
   "LastSearchedKW":"",
   "Default_Saved_PLZes":"1984plz|1984 science fiction future george orwell orwellian novel book dystopic dystopia\n2twatplz|twat point emote emoticon blankstare blank stare\nabfcnoesplz|abfc oh noes noes! yeffsie\nackbarplz|ackbar its it's a trap trap! colonel star wars\naerosmithplz|aerosmith music band\nafro1plz|afro mosiac\nafro2plz|afro mosiac\nafro3plz|afro mosiac\nafro4plz|afro mosiac\nafro5plz|afro mosiac\nafro6plz|afro mosiac\nafro7plz|afro mosiac\nafro8plz|afro mosiac\nahoyplz|ahoy pirate emoticon emote\nallyourbaseplz|all your base are belong to us katz ayb aybabtu zero wing\nangelwingleftplz|angel wing wings angelic modifier left mosiac\nangelwingrightplz|angel wing wings angelic modifier right mosiac\nanswerplz|42 answer to life the universe and everything hitchhiker's guide to the galaxy\naranrhod|the legend of zelda ocarina of time n64 navi hey hey! listen listen! fairy blue\narbysplz|arbys arby's i'm thinkin' thinking\nashnoesplz|oh noes ash ketchum pokemon anime pkmn\naxel-plz|axel final fantasy ff\nayumi1plz|ayumi hamasaki japanese pop j-pop music musician stamp left\nayumi2plz|ayumi hamasaki japanese pop j-pop music musician stamp right\nbabybodyplz|baby body\nbageltimeplz|bagel time clock\nbananahammockplz|banana hammock literal\nbarbossafireplz|pirates of the caribbean captain barbossa fire\nbeckettplz|pirates of the caribbean lord cutler beckett\nbeefyplz|beefy beefed up muscle muscular man macho\nbenderseesyoutoo|bender sees you too i see what you did there futurama\nberriesncreamplz|berries 'n n and cream\nbetacommunity|beta community deviantart tester subscriber = symbol\nbetchplz|bitch betch\nbigbrotherplz|1984 science fiction future george orwell orwellian novel book dystopic dystopia big brother\nbillnyeplz|bill nye the science guy\nbinladen-osama|osama bin laden terrorist al queda al-queda terror\nblackplz|black space block\nblahblahblahplz|blah blah! meh whatever\nblanksexplz|rabbit bunny bunnies rabbits blankstare blank stare emote emoticon sex\nblankstare|blank stare emote emoticon blankstare\nbobsagetplz|bob saget full house america's americas funniest videos\nboratplz|borat sacha baron cohen kazakhstan comedy comedian\nborder1plz|border line double corner \u2554\nborder2plz|border line double straight \u2551\nborder3plz|border line double corner \u255A\nborder4plz|border line double straight \u2550\nborder5plz|border line double corner \u255D\nborder6plz|border line double straight \u2551\nborder7plz|border line double corner \u2557\nborder8plz|border line double straight \u2550\nbowserplz|bowser mario king koopa paper\nbudweiserplz|budweiser beer can\nbucktoothplx|bucktooth buck tooth toothed bucktoothed emote emoticon\nbunnehplz|bunny rabbit\ncatslug|cat slug catslug\ncelinedionplz|celine dion singer music musician\ncheezburgerplz|i can has cheezburger lolcat lol cat\nchriscrockerplz|chris crocker leave britney brittney alone youtube\nchristianmagic|pope wand magic electric electricity christian\nchristmasplz|its not time yet christmas xmas tree dead\nchucknorris-plz|chuck norris\ncloseplz|close closed locked lock pringles emote emoticon\ncockblockplz|cock block rooster innuendo double entendre\nconfusedplz|confused emote emoticon\ncookiemonsterplz|sesame street cookie monster\ncottonplz|pirates of the caribbean cotton\ncuteplz|cute person japanese asian\ndaaaaaaaplz|daaaaaaa da daa daaa daaaa daaaaa daaaaaa rayman raving rabbids rabbid\ndaddysparrowplz|pirates of the caribbean jack sparrow father dad daddy\ndarwinplz|charles darwin darwinism zap laser emote emoticon\ndavidblaineplz|david blaine parody what the eff f fuck street magic\ndaveyjonesplz|pirates of the caribbean davey davy jones locker dead man's man mans chest\ndeadaccount|dead emote emoticon\ndeadhorseplz|beating a dead horse\ndesudesuplz|desu emote emoticon :<\ndesuplx|desu\ndesuplz|desu\ndeviltailplz|devil tail demon right\ndevilwingplz|devil wing left mosiac\nrdevilwingplz|devil wing right mosiac\ndonotenterplz|do not enter sign\ndonotwantplz|do not want\ndontmessspartaplz|300 sparta spartan leonidas three hundred\ndontstabmeplz|don't dont stab me plz please\ndrphilplz|dr dr. phil\ndweebdanceplz|dweeb dance\nelmoplz|sesame street elmo\nemoblankstare|emote emoticon blankstare blank stare\nenterplz|gun pistol shoot fire right entry enter wound bullet\nenterpwn|enter return key pwn own\nepicfailplz|epic fail george w dubya bush\nepic-win|epic-win epicwin epic win winning winner wins good awesome\nexitplz|gun pistol shoot fire left exit wound bullet\nfacepalmplz|facepalm captain pickard cp star trek\ndoublefacepalmplz|facepalm captain pickard cp star trek\ntriplefacepalmplz|facepalm captain pickard cp star trek\ngoogolfacepalmplz|facepalm captain pickard cp star trek googol\nfaqplz|deviantart da please plz read the faq help and\nfailsignplz|failsign fail sign\nfella|deviantart da mascot fella\nfiredplz|you're youre ur fired the apprentice donald trump fired!\nfirefoxplz|mozilla firefox web browser awesome\nforscience|for science scientist college magic wand electric electricity\nfranceplz|because of france\nfrycantalk|talking animated fry i see sees what you did there futurama\nfuckonfirstdateplz|i fuck on the first date fat\nfuckyeahplz|fuck yeah emote emoticon animated\ngeorgebush|george bush middle finger flip the bird\ngeorgebushplz|george w. w dubya bush\ngibbsfireplz|pirates of the caribbean gibbs fire fire!\ngodwinslawplz|godwin godwin's godwins law nazi nazism hitler adolf comparison\ngoldmemberplz|goldmember gold member austin powers\ngringlomp|grin biggrin big glomp emote emoticon gringlomp\ngtfiplz|get the fuck in gtfi\ngtfoplz|get the fuck out gtfo\nhaloplz|halo angel angelic\nheylistenplz|the legend of zelda ocarina of time hey hey! listen listen! navi fairy\nhitlerwtfplz|adolf hitler wtf spaz spas\nhomerplz|homer simpson simpsons\nhouseplz|dr. dr gregory house\nidontbelieveit|i don't dont believe it you have to be kidding me\nidontseewhatyoudid|fry i don't dont see what you did there futurama\nimhappyplz|imhappy im happy\nblankstareplz|imhappy im happy blankstare blank stare\nimhighplz|imhappy im happy high\nimsarcasticplz|imhappy im happy sarcastic\nimsoseriousplz|imhappy im happy so serious why joker batman dark knight\nimthinkingplz|imhappy im happy thinking\nhappyhitlerplz|imhappy im happy i'm hitler adolf\nnononoplz|imhappy im happy no nonono nono\nnotimpressedplz|imhappy im happy not impressed\nurhappyplz|imhappy im happy ur\nwooooplz|imhappy im happy ghost woooo ghosts spooky\nwthplz|imhappy im happy wth what the heck hell\ninternetexplorerplz|internet explorer microsoft windows ie crap web browser\niseewhatyoudidthere|fry i see what you did there futurama\nishityounot|i shit you not\nitcantbeplz|300 sparta spartan leonidas three hundred\niyellatyou|i yell at you what the fuck\njackfireplz|pirates of the caribbean jack sparrow fire fire!\njackseeswhatyoudid|pirates of the caribbean jack sparrow\njefffoxworthyplz|jeff foxworthy comedian comedy might be a redneck\njustkiddingplz|just kidding emote emoticon\nkonquerorplz|konqueror web browser\nleonidasplz|300 sparta spartan leonidas three hundred\nlolwattplz|lol wut wut? watt watt? pear light bulb lightbulb\nliljohnplz|lil john dave chapelle what huh okay yeah\nlolwutplz|lol wut wut? pear\nlongcatarmplz|longcat long cat arm mosiac\nlongcatbodyplz|longcat long cat body mosiac\nlongcatbody2plz|longcat long cat body mosiac\nlongcatfeetplz|longcat long cat feet mosiac\nlongcatheadplz|longcat long cat head mosiac\nlongcattailplz|longcat long cat tail mosiac\nmadnessplz|300 sparta spartan persian messenger this is blasphemy madness\nmarioplz|super mario 64 n64 nintendo\nmariofacepalmplz|super mario 64 facepalm\nmeatwadplz|meatwad aqua teen hunger force hungerforce\nmissingnoplz|missingno missingno. glitch pokemon pkmn\nmorecowbellplz|more cowbell gene frankle will ferrell saturday night live snl\nmudkipplz|mudkip so i herd u liek mudkips pokemon pkmn hoenn\nmurder|murder murderer fire gun pistol\nnouplz|no u you\nnouplz2|no u you\nfoshoplz|no u fo for sho sure\nfuckuplz|no u fuck\nicuplz|no u i c i see you\nloluplz|lol wut wut? u pear\nnobloo|no u bloo\nnoeveryoneplz|no u everyone every1\nnoherplz|no u her\nnoitplz|no u it\nnojewplz|no u jew\nnomewplz|no u mew pokemon pkmn kanto 151\nnomeplz|no u me\nnomudkipplz|no u mudkip\nnonobodyplz|no u nobody\nnospartaplz|no u 300 sparta spartan leonidas three hundred\nnothemplz|no u them\nnourdadplz|no u ur dad\nnourmomplz|no u ur mom\nnousplz|no u us\nnowhoplz|no u who\nohgodplz|no u oh god\nohmaiplz|no u oh mai my\nohmeplz|no u oh me\nohshitplz|no u oh shit\nohuplz|no u oh\nuhoplz|no u ho\nohusplz|no u oh us\npwntplz|no u pwnt owned pwnd pwn\nroflzplz|no u roflz rofl\nuranusplz|no u ur anus uranus\nurmomplz|no u ur mom\nusuckplz|no u suck suk\nwhymeplz|no u why me\nyesmeplz|no u yes me\noaknoesplz|oh noes professor prof prof. oak samuel sam pokemon pkmn\nobjectionplz|objection objection! phoenix wright\noverruledplz|objection overruled overruled! phoenix wright\npikachuplz|pikachu pokemon pkmn kanto 25\npokedexplz|pokedex pokemon pkmn project\npoliticsplz|pirates of the caribbean jack sparrow politics\nrarecandyplz|rare candy pokemon pkmn item\nreadplz|read before you comment on a deviation\nreplyv5|please use the reply button to reply to a comment\nsadspartaplz|300 sparta spartan leonidas three hundred sad cry crying\nsawwhatyoudidthere|fry i saw what you did there futurama\nseewhatididthere|fry see what i did there futurama\nshoopda|shoop da whoop imma chargin firin firing mah laser lazer\nwhoopp|shoop da whoop imma chargin firin firing mah laser lazer\nspartaplz|300 sparta spartan leonidas three hundred\nspeedycatplz|speedycat speedy cat head\nspeedycatplz2|speedycat speedy cat body\nspeedycatplz3|speedycat speedy cat feet\nspongebobplz|spongebob squarepants\nthumbsupplz|thumbs up\ntonberryplz|tonberry final fantasy ff\ntonberry2plz|tonberry final fantasy ff\ntransparentplz|blank space empty transparent trans nothing spacer spacing invisible\nwhaatplz|lil john dave chapelle what huh okay yeah\nzoidbergseestoo|zoidberg sees what you did too futurama"
};

window.PLZSetup=function() {
   var code='<div class="light pppp plzselector">\n   <style>\n   .DJC_PlzContainer{padding:2px;width:272px;height:272px;overflow-y:auto;background:#A1B1A3;border:1px solid #2C3635;}\n   .DJC_PlzSelect{padding:1px;background-color:#A1B1A3;}\n   .DJC_PlzSelect>div,.DJC_PlzSelectSEL>div{width:50px;height:50px;}\n   .DJC_PlzSelect>div{border:1px solid #000;}\n   .DJC_PlzSelectSEL>div{border:2px solid #E8F0EC;}\n   .DJC_PlzSelectSEL{padding:0px;background-color:#A1B1A3;}\n   #DJC_PlzPreview{width:50px;height:50px;}\n   </style>\n   <div class="title"><h3>Select a PLZ Account</h3></div>\n   <div class="h btns">\n      <table>\n         <tr>\n            <td style="margin:none;padding:none;" rowSpan="2">\n               <div id="DJC_PlzContainer" class="DJC_PlzContainer">\n                  <table cellspacing="0" cellpadding="0" style="padding:none;margin:none;">\n                     <tr>\n                     </tr>\n                  </table>\n               </div>\n               <input type="text" id="DJC_PlzOutput" maxlength="26" style="width:137px;"><!--\n               --><input type="button" value="Rmv. Selected" onclick="if(confirm(\'Are you sure you want to remove the selected PLZ?\'))PLZLegend.rmvPlz(document.getElementById(\'DJC_PlzOutput\').value.replace(/^\\:icon([a-z\\-]+?)\\:$/i,\'$1\'))" style="width:137px;">\n            </td>\n            <td style="margin:none;padding:none;" valign="top">\n               <div style="background:#BAC5BA;border:5px;-moz-border-radius:5px;margin-bottom:4px;padding:4px;">\n                  <h4 style="margin:0px 0 0px 0;text-align:center;">Search</h4>\n                  <table><tr><td><b>Name:</b> <input type="text" id="DJC_PlzSearch" maxlength="20" size="15"></td></tr><tr><td><b>Keywords:</b> <input type="text" id="DJC_PlzKWSearch" rows="3" size="15"></td></tr><tr><td><input type="button" value="Search" onClick="PLZLegend.searchPlz(document.getElementById(\'DJC_PlzSearch\').value,document.getElementById(\'DJC_PlzKWSearch\').value)"></td></tr></table>\n               </div>\n               <div style="background:#AFBBB0;border:5px;-moz-border-radius:5px;margin-bottom:4px;padding:4px;">\n                  <h4 style="margin:0px 0 0px 0;text-align:center;">Add a user</h4>\n                  <table><tr><td><b>Name:</b> <input type="text" id="DJC_PlzInput" maxlength="20" size="15"></td></tr><tr><td><b>Keywords:</b> <input type="text" id="DJC_PlzKWInput" size="15"></td></tr><tr><td><input type="button" value="Add Plz Account" onClick="PLZLegend.addPlz(document.getElementById(\'DJC_PlzInput\').value,document.getElementById(\'DJC_PlzKWInput\').value)"></td></tr></table>\n               </div>\n            </td>\n         </tr>\n      </table>\n\n   </div>\n\n   <div style="text-align: center; margin-top: 4px;">\n      <input name="ok" value="OK" class="btn_ok" type="submit">\n      <input name="cancel" value="Cancel" class="btn_cancel" type="submit">\n   </div>\n</div>';
   var b=document.createElement("form")
   b.innerHTML=code;
   b.id="DJC_PlzForm";
   //code for a plz in the legend:
   //\n                  <div id="DJC_PLZ_plz-WhosWho" class="DJC_PlzSelect"></div>
   unsafeWindow.PLZLegend.code=code;
   unsafeWindow.PLZLegend.form=b;

   // add link
   var base,a,b;
   if(unsafeWindow.Comment.nodes.submit){
      base=unsafeWindow.Comment.nodes.submit;
      a=document.createElement("a");
      a.style.textDecoration="underline";a.style.cursor="pointer";
      a.addEventListener("click",unsafeWindow.PLZLegend.openLegend,true);
      a.innerHTML="PLZes";
      b=document.createTextNode(" | ");
      unsafeWindow.Tree.get(base,"span.clinks").insertBefore(a,unsafeWindow.Tree.get(base,"span.clinks").getElementsByTagName("a")[1]);
      unsafeWindow.Tree.get(base,"span.clinks").insertBefore(b,unsafeWindow.Tree.get(base,"span.clinks").getElementsByTagName("a")[2]);
   }
   if(document.getElementById("replybox")){
      base=document.getElementById("replybox");
      a=document.createElement("a");
      a.style.textDecoration="underline";a.style.cursor="pointer";
      a.addEventListener("click",unsafeWindow.PLZLegend.openLegend,true);
      a.innerHTML="PLZes";
      b=document.createTextNode(" | ");
      unsafeWindow.Tree.get(base,"span.clinks").insertBefore(a,unsafeWindow.Tree.get(base,"span.clinks").getElementsByTagName("a")[1]);
      unsafeWindow.Tree.get(base,"span.clinks").insertBefore(b,unsafeWindow.Tree.get(base,"span.clinks").getElementsByTagName("a")[2]);
   }
   GM_registerMenuCommand("Open PLZ Legend", unsafeWindow.PLZLegend.openLegend);

};
window.addEventListener("load",window.PLZSetup,true);

unsafeWindow.PLZLegend.openLegend=
function(){
   var modal = unsafeWindow.Modals.push.call({gecko_fix: true}, unsafeWindow.PLZLegend.form, function(){});
   modal.innerHTML=modal.innerHTML; // required to get the contents to show up.
   modal.style.width="449px";modal.style.height="402px";
   modal.style.left=modal.style.right="50%";
   modal.style.margin="-201px -224px";
   unsafeWindow.PLZLegend.searchPlz("","");
};

unsafeWindow.PLZLegend.addPlz=
function(newplz,newKWplz){
   if(unsafeWindow.PLZLegend.SearchBusy) {
      if(confirm("PLZLegend is busy searching...\n\nWould you like to stop the search?\n(OK = Stop, Cancel = Continue)"))unsafeWindow.CancelSearch=true;
   }
   var e=document.createEvent("HTMLEvents");
   e.initEvent("DJCPlz_Add",true,true);
   e.wrappedJSObject.string=newplz;
   e.wrappedJSObject.keywords=newKWplz;
   window.dispatchEvent(e);
};

unsafeWindow.PLZLegend.rmvPlz=
function(targetplz){
   if(unsafeWindow.PLZLegend.SearchBusy) {
      if(confirm("PLZLegend is busy searching...\n\nWould you like to stop the search?\n(OK = Stop, Cancel = Continue)"))unsafeWindow.CancelSearch=true;
   }
   var e=document.createEvent("HTMLEvents");
   e.initEvent("DJCPlz_Rmv",true,true);
   e.wrappedJSObject.string=targetplz;
   window.dispatchEvent(e);
};

unsafeWindow.PLZLegend.getPlzAv=
function(targetplz,callback){
   if(!callback)callback=function(avatar){/*alert("Callback not specified! Avatar extension retrieved:\n"+avatar)*/};
   var a=callback;
   callback=function(s,d){arguments.callee.callback(unsafeWindow.PLZLegend.getPlzAv2(s,d))};
   callback.callback=a; // expando properties on functions work in GM, right?
   unsafeWindow.callback=callback;
   unsafeWindow.DiFi.pushPost("Comments","preview",[":icon"+targetplz+":",0], /*unsafeWindow.PLZLegend.DJC_getPlzAv2*/ callback,unsafeWindow);
   unsafeWindow.DiFi.send();
};
unsafeWindow.PLZLegend.getPlzAv2=
function(s,d){
   if(!d.response.content.match(/http\:\/\/a.deviantart.com\/avatars\/([a-z\-_])\/([a-z\-_])\/\1\2[a-z\-_]+?\.(gif|jpg|jpeg|png)/i))return null;
   return d.response.content.match(/http\:\/\/a.deviantart.com\/avatars\/([a-z\-_])\/([a-z\-_])\/\1\2[a-z\-_]+?\.(gif|jpg|jpeg|png)/i)[3];
};
unsafeWindow.PLZLegend.notifyAvLoaded=
function(name){
   var e=document.createEvent("HTMLEvents");
   e.initEvent("DJCPlz_AvatarLoaded",true,true);
   e.wrappedJSObject.string=name;
   window.dispatchEvent(e);
};
unsafeWindow.PLZLegend.showIconCode=
function(name){
   if(!document.getElementById("DJC_PlzOutput"))return null;
   if(!document.getElementById("DJC_PLZ_"+name.toLowerCase()))return false;
   if(unsafeWindow.Tree.get(document.getElementById("DJC_PlzContainer"),".DJC_PlzSelectSEL"))unsafeWindow.Tree.get(document.getElementById("DJC_PlzContainer"),".DJC_PlzSelectSEL").className=unsafeWindow.Tree.get(document.getElementById("DJC_PlzContainer"),".DJC_PlzSelectSEL").className.replace(/SEL/,"");
   document.getElementById("DJC_PlzOutput").value=":icon"+name.toLowerCase()+":";
   if(document.getElementById("DJC_PLZ_"+name.toLowerCase())) document.getElementById("DJC_PLZ_"+name.toLowerCase()).className="DJC_PlzSelectSEL";
};

unsafeWindow.PLZLegend.searchPlz=
function(search,searchKW){
   var e=document.createEvent("HTMLEvents");
   e.initEvent("DJCPlz_Display",true,true);
   e.wrappedJSObject.string=search;
   e.wrappedJSObject.keywords=searchKW;
   window.dispatchEvent(e);
};


window.updRecPlzVar=
function(){
   window.RecordedPlzes=GM_getValue("RecordedPlzes",unsafeWindow.PLZLegend.Default_Saved_PLZes);
   if(window.RecordedPlzes=="$$RESET"){
      GM_setValue("RecordedPlzes",unsafeWindow.PLZLegend.Default_Saved_PLZes);
      window.RecordedPlzes=GM_getValue("RecordedPlzes",unsafeWindow.PLZLegend.Default_Saved_PLZes);
   }
   return window.RecordedPlzes;
}


window.AddPlzAccount=
function(newplz,newKW){
   //if search is blank or undefined, show all
   if(!newplz||newplz.replace(/[\s]/g,"")==""){
      //alert("newplz is blank!\nnewplz=="+newplz+"\nnewKW=="+newKW+"\n\ntypeof newplz=="+(typeof newplz)+"\nBoolean(newplz)=="+Boolean(newplz));
      return;
   }else{
      if(!newKW)if(confirm("Are you sure you don't want to add any keywords to this PLZ?\nNot adding keywords will result in it not showing up in keyword searches.")){newKW="";}else{return false;}
      window.updRecPlzVar();
      // add username and keywords
      if(window.RecordedPlzes.indexOf(newplz+"|")==0||window.RecordedPlzes.indexOf("\n"+newplz+"|")>-1) return;
      var newval= window.RecordedPlzes+"\n"+newplz+"|"+newKW;
      GM_setValue("RecordedPlzes",newval);
      window.RecordedPlzes=GM_getValue("RecordedPlzes",unsafeWindow.PLZLegend.Default_Saved_PLZes);
      if(unsafeWindow.PLZLegend.LastSearchedName==""&&unsafeWindow.PLZLegend.LastSearchedKW=="") window.DisplayLegendContents("","");
   }
   //alert(window.RecordedPlzes);
};
window.addEventListener("DJCPlz_Add",function(e){window.AddPlzAccount(e.wrappedJSObject.string,e.wrappedJSObject.keywords)},true);

window.RmvPlzAccount=
function(targetplz){
   //if search is blank or undefined, show all
   if(!targetplz||targetplz.replace(/[\s]/g,"")==""){
      //alert("newplz is blank!\nnewplz=="+newplz+"\nnewKW=="+newKW+"\n\ntypeof newplz=="+(typeof newplz)+"\nBoolean(newplz)=="+Boolean(newplz));
      return;
   }else{
      window.updRecPlzVar();
      if(window.RecordedPlzes.indexOf(targetplz+"|")!=0&&window.RecordedPlzes.indexOf("\n"+targetplz+"|")==-1) return;
      var newval=window.RecordedPlzes.replace(new RegExp("(^|\\n)"+targetplz+"\\|[^\\b\\n]*?(\\n|$)","i"),"");
      GM_setValue("RecordedPlzes",newval);
      window.updRecPlzVar();
      if(unsafeWindow.PLZLegend.LastSearchedName==""&&unsafeWindow.PLZLegend.LastSearchedKW=="") window.DisplayLegendContents("","");
   }
   //alert(window.RecordedPlzes);
};
window.addEventListener("DJCPlz_Rmv",function(e){window.RmvPlzAccount(e.wrappedJSObject.string)},true);

window.RecordedPlzes="";window.updRecPlzVar();
unsafeWindow.SearchResults=[];
unsafeWindow.FinalSRLength=-1; // used to check that all avs for all search results have loaded.

unsafeWindow.Avatars={}; // "username":{"ext":"png","Didx":"index_of_display"}

// database format:
// username|keyword keyword keyword
// usrname2|keyword keyword keyword

window.DisplayLegendContents=
function(search,keywords){
   var KeysMatched=false;
   window.updRecPlzVar();
   var PLZes=window.RecordedPlzes.split("\n");
   if(!keywords||keywords.replace(/\s/g,"")=="")keywords="";
   unsafeWindow.PLZLegend.LastSearchedName=(!search||search.replace(/[^\s]/g,"")=="")?"":search;
   unsafeWindow.PLZLegend.LastSearchedKW=keywords;
   var keywords=keywords.split(" ");

   unsafeWindow.SearchResults=[];
   unsafeWindow.Avatars={};
   unsafeWindow.FinalSRLength=0;

   var container=document.getElementById("DJC_PlzContainer");
   if(!container)return;
   var table=container.getElementsByTagName("table")[0];

   //if search is blank or undefined, show all
   if((!search||search.replace(/[^\s]/g,"")=="")&&keywords==""){
      // show all
      for(var i=0;i<PLZes.length;i++) {
         unsafeWindow.SearchResults.push(PLZes[i].split("|")[0]);
         unsafeWindow.Avatars[PLZes[i].split("|")[0]]={"ext":null,"Didx":null};
         unsafeWindow.PLZLegend.getPlzAv(PLZes[i].split("|")[0],new unsafeWindow.Function("a","Avatars['"+PLZes[i].split("|")[0]+"']['ext']=a;PLZLegend.notifyAvLoaded('"+PLZes[i].split("|")[0]+"');"));
         unsafeWindow.FinalSRLength++;
      }
      //if(PLZes.length<2)alert(PLZes); // debug
   }else{
      unsafeWindow.PLZLegend.SearchBusy=true;
      for(var i=0;i<PLZes.length;i++) {
         if(unsafeWindow.PLZLegend.CancelSearch){
            unsafeWindow.PLZLegend.SearchBusy=unsafeWindow.PLZLegend.CancelSearch=false;
            unsafeWindow.SearchResults=[];
            var SSN=document.createElement("div");
            SSN.style.verticalAlign="center";SSN.style.textAlign="center";
            SSN.style.width=SSN.style.height="100%";
            SSN.innerHTML="The search was stopped.";
            if(!container||!table)return false;
            table.innerHTML="";
            table.appendChild(SSN);
            window.setTimeout("window.DisplayLegendContents('','')",2000);
            return false;
         }
         KeysMatched=false;
         if(PLZes[i].split("|")[0].indexOf(search)==-1)continue;
         if (keywords.length) {
            for(var a=0;keywords.length&&a<keywords.length;a++) {
               if((" "+PLZes[i].split("|")[1]+" ").indexOf(" "+keywords[a]+" ")!=-1){KeysMatched=true;break;}
            }
         }else{KeysMatched=true;}
//         if(KeysMatched) { unsafeWindow.PLZLegend.getPlzAv(PLZes[i].split("|")[0],new unsafeWindow.Function("a","SearchResults.push(["+PLZes[i].split("|")[0]+",a])"));unsafeWindow.FinalSRLength++; }
         if(KeysMatched) {
            unsafeWindow.Avatars[PLZes[i].split("|")[0]]={"ext":null,"Didx":null};
            unsafeWindow.PLZLegend.getPlzAv(PLZes[i].split("|")[0],new unsafeWindow.Function("a","Avatars['"+PLZes[i].split("|")[0]+"']['ext']=a;PLZLegend.notifyAvLoaded('"+PLZes[i].split("|")[0]+"');"));
         }
      }
   }

   if(!container||!table)return;
   table.innerHTML="<tr></tr>";
   var crow=null;
   for(var i in unsafeWindow.Avatars) {
      if(i in {} && unsafeWindow.Avatars[i]["ext"]!=null && !unsafeWindow.Avatars[i]["ext"]) continue;
//      container.innerHTML+='\n                  <div id="DJC_PLZ_'+i.toLowerCase()+'" class="DJC_PlzSelect"></div>';

      crow=table.rows[table.rows.length-1];
      if(crow.cells.length==5) crow=table.insertRow(table.rows.length);
      crow.innerHTML+='\n                  <td id="DJC_PLZ_'+i.toLowerCase()+'" class="DJC_PlzSelect"><div></div></td>';

      var n=document.getElementById("DJC_PLZ_"+i.toLowerCase());
      //if(n) n.addEventListener("click",new unsafeWindow.Function("","PLZLegend.showIconCode('"+i.toLowerCase()+"')"),true);
         // for some reason the above line only has an effect on the last icon to be added.
      if(n)n.setAttribute("onclick","PLZLegend.showIconCode('"+i.toLowerCase()+"')"); // will setAttribute work?
      if(unsafeWindow.Avatars[i]["ext"]) window.UpdateDisplayedAvatar(i);
   }
};
window.addEventListener("DJCPlz_Display",function(e){window.DisplayLegendContents(e.wrappedJSObject.string,e.wrappedJSObject.keywords)},true);
window.UpdateDisplayedAvatar=
function(name){
   var a=unsafeWindow.Avatars[name];
   if(!a)return;
   var n=document.getElementById("DJC_PLZ_"+name.toLowerCase());
   if(!n)return;
   n.getElementsByTagName("div")[0].style.backgroundImage="url(http://a.deviantart.com/avatars/"+name[0]+"/"+name[1]+"/"+name+"."+a.ext+")";
};
window.addEventListener("DJCPlz_AvatarLoaded",function(e){window.UpdateDisplayedAvatar(e.wrappedJSObject.string)},true);

window.GetPlzAvatar=
function(targetplz){
   //if search is blank or undefined, show all
   if(!targetplz||targetplz.replace(/[^\s]/g,"")==""){
      // use a GM_XmlHttpRequest to grab the avatar from the user's wishlist page:
      // http://USERNAME.deviantart.com/wishlist/?offset=9999999999
      // thanks to the offset (which guarantees there won't be any thumbs) this is 
      //    the most compact page guaranteed to contain the target user's avatar.
   }else{
      if(document.getElementById("DJC_PlzPreview"))document.getElementById("DJC_PlzPreview").src="";//need to add in base64 code for some sort of placeholder image.
   }
};
window.addEventListener("DJCPlz_Add",function(e){window.GetPlzAvatar(e.wrappedJSObject.string)},true);