UD Profile Expander

(Urban Dead) Shows users' profile information in-game

当前为 2020-02-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @author haliphax (https://roadha.us)
  3. // @match http://urbandead.com/map.cgi*
  4. // @match http://www.urbandead.com/map.cgi*
  5. // @include http://*urbandead.com/map.cgi*
  6. // @exclude http://*urbandead.com/map.cgi?log*
  7. // @name UD Profile Expander
  8. // @namespace https://roadha.us
  9. // @description (Urban Dead) Shows users' profile information in-game
  10. // @require http://code.jquery.com/jquery-3.4.1.min.js
  11. // @version 0.0.1.20200207170940
  12. // ==/UserScript==
  13.  
  14. var trackSkills = [
  15. 'Free Running',
  16. 'Body Building',
  17. 'Lab Experience',
  18. 'Ransack',
  19. 'Scent Trail',
  20. 'Brain Rot'
  21. ];
  22.  
  23. /******************************************************************************/
  24. jQuery(document).on('click', '#UDProfileSniff', function () {
  25. $('#UDProfileSniff').remove();
  26. gt = $('div.gt')[1];
  27. var glob_rgx = /<a[^>]+?href="profile\.cgi\?id=\d+"[^>]*?>(?!<b>).+?<\/a>/ig;
  28. var rgx = /<a[^>]+?href="profile\.cgi\?id=(\d+)"[^>]*?>(?!<b>)(.+?)<\/a>/i;
  29. var matches = gt.innerHTML.match(glob_rgx);
  30. var profilesTbl = '<table style="clear:both;"><tr><td id="udptbl"></td></tr></table>';
  31. gt.innerHTML = gt.innerHTML.replace(/Also here.*?\.<br><br>/, '');
  32. gt.innerHTML += profilesTbl;
  33.  
  34. for(a = 0; a < matches.length; a++)
  35. {
  36. var submatches = rgx.exec(matches[a]);
  37. var udp = $('#udptbl')[0];
  38.  
  39. udp.innerHTML += '<div style="float:left;margin:8px;padding:8px;">'
  40. + matches[a] + '<br /><span style="font-size:8pt" id="udptbl_'
  41. + submatches[1] + '"></span></div>';
  42.  
  43. $.ajax({
  44. async: true,
  45. url: 'http://'
  46. + (window.location.hostname.match(/^w/i) ? 'www.' : '')
  47. + 'urbandead.com/profile.cgi?id=' + submatches[1],
  48. dataType: 'html',
  49. success: function(txt, stat)
  50. {
  51. var vals = txt.match(/<td[^>]+?class="slam">.+?<\/td>/ig);
  52. var id = /href="contacts\.cgi\?add=(\d+)"/i.exec(txt)[1];
  53. var pd = new Array();
  54.  
  55. for(b = 0; b < vals.length; b++)
  56. pd[b] = /<td[^>]+?class="slam">(.+?)<\/td>/i
  57. .exec(vals[b])[1];
  58.  
  59. var skills = /<td rowspan=10 class="slam">(?:.|\n)*?<\/td>/im
  60. .exec(txt)[0];
  61. var span = $('#udptbl_' + id)[0];
  62.  
  63. span.innerHTML += '<b>' + pd[3] + '</b><br />'
  64. + 'Level: ' + pd[1] + ', XP: ' + pd[2]
  65. + '<br />';
  66.  
  67. for(b = 0; b < trackSkills.length; b++)
  68. if(skills.indexOf('>' + trackSkills[b] + '<') >= 0)
  69. span.innerHTML += trackSkills[b] + '<br />';
  70. }
  71. });
  72. }
  73. });
  74.  
  75. $(document.body).html($(document.body).html().replace(
  76. /(<div class="gt">)You are (?!<)/,
  77. '$1<a style="cursor:pointer;font-size:8pt;" id="UDProfileSniff">Expand Profiles<br /></a>You are '));