Bookmarklets

From The Urban Dead Wiki
Jump to navigationJump to search

What are they?

Bookmarklets are hypertext links that you can store as a bookmark. However, instead of containing URLs, they contain simple bits of javascript that execute within the page you are viewing when you open that bookmark. By doing so, they can produce changes in or effects based upon the content of the page you are viewing. These functions are similar to what is seen when you are running a user script, but they are generally much simpler / more focused, and they only occur when the bookmark(let) is opened. While not able to produce certain complex effects user scripts can produce, or to function automatically on every page load, they also are not able to do certain malicious things user scripts potentially can do.

For more information about bookmarklets, as well as a wide array of ones you can use (some rather handy in UD as is or as inspiration for more developed versions), see http://www.bookmarklets.com/.

What do they have to do with Urban Dead?

Firefox extensions and User Scripts seem to be very popular with Urban Dead players. Bookmarklets can do many of the simpler jobs those handle, but are simpler to create and manage.

Examples of bookmarklets for Urban Dead

Because the wiki does not support non-http hypertext links, you will have to copy the bookmarklet text to use the bookmarklets. You can try them out by just pasting them in your browser location bar and hitting enter while viewing an urbandead page (you can try them with other pages too).

To use them as actual "bookmarklets", manually create a bookmark with a location equal to the given code text. The bookmarklets name can be whatever you like-the names given below are descriptive suggestions, but using a different one won't alter how they work.

I'm writing these mostly with clarity in mind and thus ignoring some of the rules of "good Bookmarklet scripting", which is designed to produce intentionally unreadable code that won't "bump into" any variables or function names a normal javascript page might use. Because Urban Dead uses no javascript, there is no need to worry about those concerns.

Drop All Contacts

Contact list a bit cluttered? Joining a new group, or just loading in a new set of contacts? This one does what it says- save it as a bookmark, hit it while viewing your contacts page, and all your contacts go away!

Javascript:rawIDs=document.body.innerHTML.match(/id=\d\d+/g);dropString=;for(i=0;rawIDs[i];i++){dropString+='c'+rawIDs[i].match(/\d\d+/)+'=d&'}; window.location='http://www.urbandead.com/contacts.cgi?'+dropString


A monkey with his finger on the f5 key

This Bookmarklet just copies the URL of the window it is opened in into a new window over and over as many times as you like with a fixed delay. This has the effect of duplicating your last action over and over, if that action was of the sort that that uses question marks.
To use it, first perform the action you want repeated (such as "search drugstore") and then paste the code into that windows url bar, or open the bookmark(let) in that window. The initial prompts will let you specify the total number of repetitions and the time between them. 4 and 10 is a good value for testing; it proves the script works without chewing up to may IP hits. Its an OK setup if you just want to search a location another 4 times and have a decent connection. On the other hand, if you use the ?rise command, than open the bookmark(let) and repetitions at 150 and the delay at 41 secs, you get a very effective rise bot for about an hour- but you'll need to have made that donation for the extra IP hits! 40 and 8 will let you grab about 20 FAKs if you use it in the mall after searching the drugstore, and assuming you have less than 20% encumbrance when you use it. I'm sure people can find other uses, but I should caution- it will NOT work for building barricades or attacking them, or attacking any target for that matter; that's a job for a different bookmarklet.

javascript:repTotal=prompt("Total number of repetitions:"); repTime=prompt("Seconds before and between repetitions:");function doRep(){void(window.open(location.href,"RepWin",""))}; function doAllReps(d){void(window.setTimeout("doRep()",d))}; for(rep=1;rep<=repTotal;rep++){void(doAllReps(1000*rep*(repTime)))};

ZMAZH!!!

I sometimes find that, when doing rapid-fire barricade attacks as a zombie, locating the "attack barricade" command is difficult. This Bookmarklet acts as an improved version of zUDtool's "bash barricade" button, launching multiple claw attacks (with a delay in between) with barricades as the target. Unlike the above "repeater" bookmarklet, this one does NOT require you to perform any action first. However, you do want to make sure you are logged into a zombie who is standing in front of barricades before using it!

javascript: bTotal=prompt("Total number of barricade attacks:"); bTime=prompt("Seconds before and between attacks:"); function Bash(){void(bWin=window.open("","bWin","")); void(bWin.document.write("<html><body><form name=ZMAZHform action='http://urbandead.com/map.cgi' method='post'> <input name='target' value='b'> <input name='weapon' value='maul'> </form> <script language='JavaScript' type='text/javascript'> document.ZMAZHform.submit(); </script> </body> </html>"))}; function ZMASH(d){void(window.setTimeout("Bash()",d))};for(rep=1;rep<=bTotal;rep++){void(ZMASH(1000*rep*bTime))}

Note that changing this one so it attacks "a zombie" with your fire ax is a pretty simple matter. You could also use a firearm as the weapon, but make sure you don't call for so many attacks that you run out of ammo!

Multi-Attack

This is a more advanced version of the above Bookmarklet script, which allows you to enter any target and weapon combination, rather than just attacking barricades with claws. It's handy for those marathon zombie axe chops low level firemen love to do.

javascript:bTarget=prompt("Target ID#, 'z' for 'a zombie' or 'b' for barricades:"); bWeapon=prompt("Enter one of the following as appropriate: maul, teeth, pistol, shotgun, flare, knife, axe, punch, crowbar, pipe, bat (possible others)"); bTotal=prompt("Total number of attacks:"); bTime=prompt("Seconds before and between attacks:");function Bash(){void(bWin=window.open("","bWin","")); void(bWin.document.write("<html><body><form name=ZMAZHform action='http://urbandead.com/map.cgi' method='post'><input name='target' value='"+bTarget+"'><input name='weapon' value='"+bWeapon+"'></form><script language='JavaScript' type='text/javascript'>document.ZMAZHform.submit();</script></body></html>"))};function ZMASH(d){void(window.setTimeout("Bash()",d))}; for(rep=1;rep<=bTotal;rep++){void(ZMASH(1000*rep*bTime))}

Hide Location

This bookmarklet alters the page code for the map and scene description to remove the information that would reveal your location in a screenshot or Iwitness record. It is possible that other information (such as maps drawn by firefox extensions) could still reveal your location. Using this bookmarklet is faster than editing an image after making a screenshot, and altering the code is the ONLY way to hide your location if you make a publicly available Iwitness report.

javascript:void(document.body.innerHTML=document.body.innerHTML.replace(/td class=%22b .*?%22/g,'td class=%22b fog%22').replace(/class=%22m\w%22 value=%22(.|[\r\n])*?%22/g,'class=%22md%22 value=%22fog%22').replace(/name=%22v%22 value=%22\d+-\d+%22/g,'name=%22v%22 value=%221-1%22').replace(/class=%22sb%22>(.|[\r\n])*?<\/td>/,'class=%22sb%22>CENSORED</td>').replace(/<span class=%22f\w%22>(.|[\r\n])*?<\/span>/g,''));var loc=document.body.innerHTML.match(/<div class=%22gt%22>(?:.|[\r\n])*?<b>((.|[\r\n])*?)<\/b>/);if(loc&&loc[1])void(document.body.innerHTML=document.body.innerHTML.replace(new RegExp(loc[1],[%22g%22]),'CENSORED'))

GPS

This bookmarklet can function as a GPS unit, because it displays your location co-ordinates when triggered. It is also a useful bit of code when creating bookmarklets (or even extensions) where you need to have the players location co-ordinates.

javascript:Xs=document.body.innerHTML.match(/\d\d?(?=-\d\d?" type="hidden">)/g); Ys=document.body.innerHTML.match(/\d\d?(?=" type="hidden">)/g);Xsum=0;Ysum=0;Xav=0;Yav=0; for(i=0;Xs[i];i++){Xs[i]=parseInt(Xs[i]);Ys[i]=parseInt(Ys[i]);Xsum+=Xs[i];Ysum+=Ys[i];} Xav=Xsum/Xs.length;Yav=Ysum/Ys.length;if(Xav<1){Xav=1;}if(Yav<1){Yav=1;}if(Xav>99){Xav=99;} if(Yav>99){Yav=99;}alert(Xav+"-"+Yav);

Search and Replace

This is a bookmarklet for use on the wiki, while editing. It looks at the editing window and replaces one user-chosen piece of text found there with another user selected text. To use it, go to the edit page of any article and paste the bookmarklet into the address bar. Then press enter and follow the pop-up prompts.

javascript:function goGadgetGo(){var leavingText=prompt("Enter the text to be replaced:","");var arrivingText=prompt("Replacement text:","");var textareas=document.getElementsByTagName("textarea");while (textareas[0].value.indexOf(leavingText) != -1) {textareas[0].value=textareas[0].value.replace(leavingText,arrivingText);}}goGadgetGo();

It's case sensitive.

Bookmarks

Because UD uses the "post" method for certain functions, simple bookmarks can in fact perform special game functions. For example, bookmarking the link to http://urbandead.com/map.cgi?rise and putting the bookmark on your bookmark toolbar under the bookmark name ?rise effectively gives you a ?rise button, assuming you log in at urbandead.com, and not www.urbandead.com. You can do this by right clicking on the following link - ?rise and adding it to your bookmarks in the bookmark toolbar folder.

Below is a selection of "special" bookmarks for Urban Dead- the urls (plus quite a few for more obscure / less useful actions) are found on the Actions via "question marks" page. Use the ones from the "urbandead.com" list if you normally use that URL to log in, and use the ones from the www.urbandead.com list is you prefer that URL. DEM's revive request tool uses the latter format, so it is probably the better to use if you like adding profiles of people you want to revive via that tool.

urbandead.com

  • ?rise - stand up when killed (otherwise just works as a refresh button)
  • ?zoom - view names in a location with more than 50 survivors (also works as refresh button)
  • ?search4Any - searches the location you are in
  • ?search4Gun - search the gun store in mall
  • ?search4Tech - search tech store in mall
  • ?seach4Hardware - search hardware store in mall
  • ?search4FAK - search drugstore in mall

www.urbandead.com

  • ?rise - stand up when killed (otherwise just works as a refresh button)
  • ?zoom - view names in a location with more than 50 survivors (also works as refresh button)
  • ?search4Any - searches the location you are in
  • ?search4Gun - search the gun store in mall
  • ?search4Tech - search tech store in mall
  • ?seach4Hardware - search hardware store in mall
  • ?search4FAK - search drugstore in mall

Please Contribute

Feel free to write your own Bookmarklets and special bookmarks, post them above, and ask questions / get help / offer suggestions on the talk page.