HTML Item List Creator

Auto create item lists from wowhead.com comparisons

目前为 2019-10-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name HTML Item List Creator
  3. // @description Auto create item lists from wowhead.com comparisons
  4. // @namespace http://mogboutique.tumblr.com/
  5. // @author http://mogboutique.tumblr.com/
  6. // @include http://*.wowhead.com/compare?items*
  7. // @grant none
  8. // @version 0.0.2
  9. // ==/UserScript==
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. $('#su_table').before("<div id='html_item_list' style='border:1px dashed;margin-botto:20px;padding:20px;'><h3>Hi! This is HTML Item List Creator.</h3>Click one of this buttons below to generate the code you need, then copy the contents:<br /><br /> <button id='autobtn' style='margin-right:10px;'>HTML Code (Blogs)</button><button id='reddit'>Markdown (Reddit)</button><button id='bbcode' style='margin-left:10px;'>BBCode (Forums)</button><br /><br />For updates, click <a href='http://tmblr.co/Zj6X5vZ-Es2N'>here</a>.<br /><br /><textarea id='autoitems' style='font-size:12px;display:none;width:100%;min-height:110px;background:transparent;border:1px solid;color:green;text-shadow:0 0 3px green;' spellcheck='false'></textarea></div>");
  17.  
  18.  
  19.  
  20.  
  21. var table2 = [
  22. '' ,//0
  23. 'Head: ' ,//1
  24. 'Neck: ' ,//2
  25. 'Shoulders: ' ,//3
  26. 'Shirt: ' ,//4
  27. 'Chest: ' ,//5
  28. 'Waist: ' ,//6
  29. 'Legs: ' ,//7
  30. 'Boots: ' ,//8
  31. 'Wrists: ', //9
  32. 'Hands: ' , //10
  33. '' , //11,
  34. '' , //12
  35. '1H Weapon: ',//13,
  36. 'Shield: ' , //14
  37. 'Ranged: ' , //15
  38. 'Cloak: ' , //16
  39. '2H Weapon: ' //17
  40.  
  41. ];
  42.  
  43.  
  44. table2[23] = 'Off-hand: ';
  45.  
  46.  
  47. var fakeDiv= $('<div id="fake" style="display:none;"></div>').appendTo('body');
  48.  
  49.  
  50.  
  51.  
  52.  
  53. function Markdown(url,name,slot) {
  54. }
  55.  
  56.  
  57.  
  58.  
  59. $('#autobtn').click(createList);
  60. $('#reddit').click(Markdown);
  61. $('#bbcode').click(BBCode);
  62.  
  63.  
  64.  
  65. function createList(){
  66. $( fakeDiv ).html( '' );
  67. $('div.summary-group-bottom .iconsmall a').each(function(){
  68. var href=$(this).attr('href');
  69. var match = href.match(/\/item=(\d+)/)[1];
  70. var url = 'http://www.wowhead.com/item='+ match;
  71. if(match) {
  72. var a = $('<a>').attr('href','http://www.wowhead.com/item='+ match );
  73. $( fakeDiv ).append( a );
  74. var slot = g_items[match].jsonequip.slot;
  75. var name = g_items[match].name_enus;
  76. if( slot && table2[slot] )
  77. $( a ).before( table2[slot] );
  78.  
  79. if( name )
  80. $( a ).text( name );
  81. $(a).after('<br>');
  82. }
  83. });
  84. text = fakeDiv.html();
  85. text = text + '<br><a href="http://www.wowhead.com' + $('#su_link').attr('href') +'">View on Wowhead</a>';
  86.  
  87. baseURI = document.baseURI;
  88. var uri = baseURI.match(/http:\/\/[a-z]+.wowhead.com\//)[0];
  89. if(uri) {
  90.  
  91. $('#autoitems').text(text).fadeIn() ;
  92. }
  93. else {
  94. $('#autoitems').text('Error :(').fadeIn() ;
  95. }
  96. }
  97.  
  98. function Markdown(){
  99. $( fakeDiv ).html( '' );
  100. $('div.summary-group-bottom .iconsmall a').each(function(){
  101. var href=$(this).attr('href');
  102. var match = href.match(/\/item=(\d+)/)[1];
  103. var url = 'http://www.wowhead.com/item='+ match;
  104. if(match) {
  105. var slot = g_items[match].jsonequip.slot;
  106. var name = g_items[match].name_enus;
  107.  
  108. if( name ){
  109. if( slot && table2[slot] ) $( fakeDiv ).append( table2[slot] );
  110. $( fakeDiv ).append( '[' + name + '](' + url + ')\n\n' );
  111. }
  112. }
  113. });
  114. text = fakeDiv.html();
  115. text = text + '[View on Wowhead](http://www.wowhead.com' + $('#su_link').attr('href') +')';
  116.  
  117. baseURI = document.baseURI;
  118. var uri = baseURI.match(/http:\/\/[a-z]+.wowhead.com\//)[0];
  119. if(uri) {
  120.  
  121. $('#autoitems').text(text).fadeIn() ;
  122. }
  123. else {
  124. $('#autoitems').text('Error :(').fadeIn() ;
  125. }
  126. }
  127.  
  128. function BBCode(){
  129. $( fakeDiv ).html( '' );
  130. $('div.summary-group-bottom .iconsmall a').each(function(){
  131. var href=$(this).attr('href');
  132. var match = href.match(/\/item=(\d+)/)[1];
  133. var url = 'http://www.wowhead.com/item='+ match;
  134. if(match) {
  135. //var a = $('<a>').attr('href','http://www.wowhead.com/item='+ match );
  136. //$( fakeDiv ).append( a );
  137. var slot = g_items[match].jsonequip.slot;
  138. var name = g_items[match].name_enus;
  139. if( slot && table2[slot] )
  140. //$( a ).before( table2[slot] );
  141. $(fakeDiv).append( table2[slot] )
  142.  
  143. if( name )
  144. $(fakeDiv).append( '[url=' + url + ']' + name + '[/url]');
  145. }
  146. });
  147. text = fakeDiv.html();
  148. text = text + '[url=http://www.wowhead.com' + $('#su_link').attr('href') +']View on Wowhead[/url]\n';
  149.  
  150. baseURI = document.baseURI;
  151. var uri = baseURI.match(/http:\/\/[a-z]+.wowhead.com\//)[0];
  152. if(uri) {
  153.  
  154. $('#autoitems').text(text).fadeIn() ;
  155. }
  156. else {
  157. $('#autoitems').text('Error :(').fadeIn() ;
  158. }
  159. }
  160.  
  161.  
  162.