More UI part2

The second part to The GT UI+

当前为 2015-08-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name More UI part2
  3. // @namespace http://use.i.E.your.homepage/
  4. // @version 1.0.1
  5. // @description The second part to The GT UI+
  6. // @match http://www.ghost-trappers.com/fb/*
  7. // @copyright 2015+, GTNoAPI
  8. // @grant GM_xmlhttpRequest
  9. // ==/UserScript==
  10.  
  11. initUIv2();
  12.  
  13. function initUIv2(){
  14. GM_xmlhttpRequest({
  15. method: 'GET',
  16. url: 'https://gtnoapi.herokuapp.com/api/ghosts',
  17. headers: {
  18. "Accept": "application/json",
  19. "Pragma": "no-cache",
  20. "Cache-Control": "no-cache"
  21. },
  22. onload: function(rD) {
  23. $('.logText').each(function(){
  24. var ghostEncounter = $(this).find('a').html();
  25. var ghostInfo = getGhostByName(ghostEncounter, rD.response);
  26. if(ghostEncounter && ghostEncounter == ghostInfo.name){
  27. var perantEle;
  28. var childEle;
  29. if(ghostInfo.loot){
  30.  
  31. var arrow= $('<div></div>').css({
  32. 'width': '0' ,
  33. 'height': '0',
  34. 'border-top': '10px solid transparent',
  35. 'border-bottom': '10px solid transparent',
  36. 'border-left': '10px solid #223341',
  37. 'position': 'absolute',
  38. 'top': '10px',
  39. 'right': '-10px',
  40. })
  41.  
  42. childEle = $('<span></span>').css({
  43. 'position': 'absolute',
  44. 'top': '-14px',
  45. 'right': '40px',
  46. 'z-index': '9999999',
  47. 'font-size': '14px',
  48. 'display': 'none',
  49. 'background-color': '#223341',
  50. 'border': '1px solid #222',
  51. 'border-radius': '7px',
  52. 'padding': '10px',
  53. 'min-width': '150px'
  54.  
  55. }).html(ghostInfo.loot);
  56.  
  57.  
  58. perantEle = $('<div>?</div>').css({
  59. 'cursor':'pointer',
  60. 'padding': '1px 4.5px',
  61. 'border-radius': '50%',
  62. 'background-color': 'black',
  63. 'color': 'white',
  64. 'float': 'right',
  65. 'font-weight': 'bold',
  66. 'position': 'relative'
  67. });
  68.  
  69.  
  70. perantEle.hover(function(){
  71. if(childEle.css('display')=='none'){
  72. childEle.show();
  73. }
  74. else{
  75. childEle.hide();
  76. }
  77. });
  78.  
  79. arrow.appendTo(childEle);
  80. childEle.appendTo(perantEle)
  81. }
  82.  
  83.  
  84.  
  85.  
  86. $(this).append(perantEle);
  87. }
  88. });
  89. }
  90. });
  91. };
  92.  
  93.  
  94. function getGhostByName(name, jsonTxt){
  95. var obj = jQuery.parseJSON(jsonTxt);
  96. var result = '';
  97. for(var x = 0; x < obj.length; x++){
  98. if(obj[x].name == name){
  99. var title = '';
  100. for(var y = 0; y < obj[x].loot.length; y++){
  101. title += obj[x].loot[y] + '<br />';
  102. }
  103. result = {
  104. 'name':obj[x].name,
  105. 'loot':title,
  106. 'type':obj[x].type
  107. }
  108. }
  109. }
  110. return result;
  111. }