Neopets - Neoboard Enhancements

Adds some useful icons to the neoboards

  1. // ==UserScript==
  2. // @name Neopets - Neoboard Enhancements
  3. // @author Jawsch
  4. // @match http://www.neopets.com/island/tradingpost.phtml*
  5. // @include http://www.neopets.com/neoboards/topic.phtml?topic=*
  6. // @version 0.0.1.20180611113234
  7. // @namespace Diceroll / Jawsch ;D
  8. // @description Adds some useful icons to the neoboards
  9. // ==/UserScript==
  10. var do_tradingpost_also = true; // enable it if you'd like. :P (set to true)
  11. ///////////
  12. $.urlParam = function(url, name) {
  13. var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url);
  14. if (results===null) {
  15. return null;
  16. } else {
  17. return results[1] || 0;
  18. }
  19. };
  20. var linkmap = { // for urls and images
  21. trade: {
  22. "url": "http://www.neopets.com/island/tradingpost.phtml?type=browse&criteria=owner&search_string=%s",
  23. "img": "http://images.neopets.com/icons/trades.gif",
  24. "hint": "View this user's other trades!"
  25. },
  26. auction: {
  27. "url": "http://www.neopets.com/genie.phtml?type=find_user&auction_username=%s",
  28. "img": "http://images.neopets.com/icons/ul/auctions.gif",
  29. "hint": "View this user's auctions!"
  30. },
  31. shop: {
  32. "url": "http://www.neopets.com/browseshop.phtml?owner=%s",
  33. "img": "http://i.imgur.com/zTqY0jn.png",
  34. "hint": "View this user's shop!"
  35. },
  36. gallery: {
  37. "url": "http://www.neopets.com/gallery/index.phtml?gu=%s",
  38. "img": "http://images.neopets.com/trophies/222_1.gif",
  39. "hint": "View this user's gallery!"
  40. },
  41. stamp: {
  42. "url": "http://www.neopets.com/stamps.phtml?owner=%s",
  43. "img": "http://i.imgur.com/lb3Ms90.png",
  44. "hint": "View this user's stamp album!"
  45. },
  46. neomail: {
  47. "url": "http://www.neopets.com/neomessages.phtml?type=send&recipient=%s",
  48. "img": "http://images.neopets.com/icons/ul/neomail.gif",
  49. "hint": "Neomail this user!"
  50. },
  51. };
  52. function buildAccountLinks(obj, string) {
  53. var result = "";
  54. function sprintf(str, repl) {
  55. return str.replace("%s", repl);
  56. }
  57. $.each(obj, function(k, v) {
  58. result += '<a title="' + v['hint'] + '" href="' + sprintf(v['url'], string) + '" target="_blank"><img src="' + sprintf(v['img'], string) + '" width="20px" height="20px"></a> ';
  59. });
  60. return result;
  61. }
  62. // Trading Post
  63. if(document.URL.indexOf("/island/tradingpost") != -1 && do_tradingpost_also === true) {
  64. reports = $("a[href*='autoform_abuse']"); // we'll put the links before this.
  65. $.each(reports, function(index, value) {
  66. user = $.urlParam($(this).attr("href"), "offender");
  67. $(this).before(buildAccountLinks(linkmap, user) + " | ");
  68. });
  69. }
  70. // NeoBoards
  71. if(document.URL.indexOf("neoboards/topic.phtml") != -1) {
  72. $(".topicAuthor.sf").each(function(index, value) {
  73. user = $.urlParam($(this).find("a[href*='userlookup']").eq(0).attr("href"), "user");
  74. $(this).find("a[href*='userlookup']").eq(0).after("<hr noshade size='1' color='#D1D1D1'>" + buildAccountLinks(linkmap, user));
  75. // aaaand the pet page
  76. pet = $.urlParam($(this).find("a[href*='petlookup']").eq(1).attr("href"), "pet");
  77. if (pet) { // I mean...can people post if they have no pet? Eh, this will make sure it doesn't break if they can.
  78. $(this).find("a[href*='petlookup']").eq(1).after("<br><a href='http://www.neopets.com/~" + pet + "' target='_blank'><img src='http://images.neopets.com/games/arcade/cat/word_games_30x30.png' height='20px' width='20px'></a>");
  79. // removes "Active Neopet" text
  80. html = $(this).find("a[href*='petlookup']").parent().parent().html();
  81. $(this).find("a[href*='petlookup']").parent().parent().html(html.replace("Active Neopet", ""));
  82. }
  83. });
  84. }