Wanikani Dashboard Active Topics Panel

Active Topics Panel for your dashboard

  1. // ==UserScript==
  2. // @name Wanikani Dashboard Active Topics Panel
  3. // @namespace mempo
  4. // @description Active Topics Panel for your dashboard
  5. // @include https://www.wanikani.com/dashboard
  6. // @include https://www.wanikani.com/
  7. // @run-at document-end
  8. // @version 1.6.1
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. console.log('started Wanikani Dashboard Active Topics Panel');
  13.  
  14. /////////////////////////////////
  15. //PREPARATION BEFORE LOADING
  16. /////////////////////////////////
  17.  
  18.  
  19.  
  20. var nonCleanDashboardCss = '.DATP-i-small { ' +
  21. 'left: 0px !important; '+
  22. 'top: 0px !important; '+
  23. 'line-height: 0px !important; '+
  24. 'margin: -20px 0px 0px 150px !important; '+
  25. 'width: 15px !important; '+
  26. 'height: 15px !important; '+
  27. '}';
  28.  
  29. addStyle(nonCleanDashboardCss);
  30.  
  31. var DATPcss = '.DATP-i-small { ' +
  32. 'font-size: 15px !important; '+
  33. 'position: relative; '+
  34. 'left: 70% !important; '+
  35. 'top: 20px !important; '+
  36. 'border: 0px !important; '+
  37. 'box-shadow: none !important;' +
  38. '}' +
  39. '.DATP-section { ' +
  40. 'width: inherit ;'+
  41. '}' +
  42. '.DATP-table-wrapper { ' +
  43. 'position: relative ;'+
  44. 'height: 400px ;'+ //TODO maybe replace hard coded value
  45. 'overflow: hidden ;'+
  46. // 'line-height: 15px ;'+
  47. '}' +
  48. '.DATP-table-wrapper table { ' +
  49. ' position: absolute; ' +
  50. '} ' +
  51. '.DATP-table-wrapper table tr td:last-child { ' +
  52. //' padding-right: 30px; ' +
  53. '} ' +
  54. '.DATP-table-left { ' +
  55. 'left: 0 ;'+
  56. 'top: 0 ;'+
  57. 'bottom: 0 ;'+
  58. '}' +
  59. '.DATP-table-right { ' +
  60. 'left: 1170px ;'+
  61. 'top: 0 ;'+
  62. 'bottom: 0 ;'+
  63. '}' +
  64. '.forum-topics-list table { ' +
  65. 'height: 400px ;'+
  66. '}';
  67. addStyle(DATPcss);
  68.  
  69.  
  70.  
  71. var blog = $(".blog");
  72. blog.removeClass();
  73. blog.addClass("forum-topics-list dashboard-sub-section DATP-section");
  74.  
  75. //MAKE THE FORUM LIST SPAN 6 AGAIN
  76. $(".forum-topics-list").parent().removeClass().addClass("span6");
  77.  
  78. //ADD 'LOADING' ROW
  79. $(".DATP-section h3").after("<table></table>");
  80. $(".DATP-section table").append('<tbody><tr><td>Panel is loading. Please be patient</td></tr></tbody>');
  81.  
  82.  
  83. $(".DATP-section").css('background-color', "#D5D5D5");
  84. a = $(".DATP-section .see-more a");
  85. a.html("Visit the user panel...");
  86. a.attr("href","https://www.wanikani.com/community/panel/");
  87. var i = $(".DATP-section .heading-symbol i");
  88. i.removeClass();
  89. i.addClass("icon-comments-alt");
  90. $( ".DATP-section h3" ).html(function(i,oldhtml){return oldhtml.slice(0, oldhtml.indexOf('WaniKani News')) + '<span class="DATP-title">Topics Active In</span>'; });
  91. $('.DATP-section h3').prepend('<div class="heading-symbol"><i class="icon-edit"></i></div>');
  92.  
  93. $(".DATP-section").addClass("DATP-section");
  94. $(".DATP-section>h3>div:last-child").addClass("DATP-i-big");
  95. $(".DATP-section>h3>div:first-child").addClass("DATP-i-small");
  96.  
  97. $(".DATP-section table").wrap('<div class="DATP-table-wrapper"></div>');
  98. $(".DATP-table-wrapper table").addClass('DATP-table-left');
  99. /*
  100. var forumHeight = document.defaultView.getComputedStyle($('.forum-topics-list')[0], null).height;
  101. console.log(forumHeight);
  102. $(".DATP-table-wrapper").css('min-height',forumHeight);
  103. */
  104.  
  105.  
  106. $(".DATP-table-wrapper").append('<table class="DATP-table-right DATP-loading"><tbody><tr><td>Panel is loading. Please be patient</td></tr></tbody></table>');
  107.  
  108. var panel = $(".DATP-section").parent().detach();
  109. $(".forum-topics-list").parent().after(panel);
  110.  
  111. /////////////////////////////
  112. //ADD FUNCTIONALITY TO ICON
  113. /////////////////////////////
  114.  
  115. $('.DATP-i-small').click(function(){
  116.  
  117. var icon = $( ".DATP-i-small>i" );
  118. if(icon.hasClass('icon-comments-alt')){
  119. icon.removeClass().addClass('icon-edit');
  120. }else{
  121. icon.removeClass().addClass('icon-comments-alt');
  122. }
  123. icon = $('.DATP-i-big>i');
  124. if(icon.hasClass('icon-comments-alt')){
  125. icon.removeClass().addClass('icon-edit');
  126. }else{
  127. icon.removeClass().addClass('icon-comments-alt');
  128. }
  129. var $table = $('.DATP-table-wrapper .DATP-table-left');
  130. $table.animate({
  131. left: parseInt($table.css('left'),10) == 0 ?
  132. -$table.outerWidth() :
  133. 0
  134. });
  135. var $tableRight = $('.DATP-table-wrapper .DATP-table-right');
  136. if($tableRight.hasClass('DATP-loading')){
  137. loadCreatedTopics();
  138. }
  139. $tableRight.animate({
  140. left: parseInt($tableRight.css('left'),10) == 0 ?
  141. $table.outerWidth() :
  142. 0
  143. });
  144. if($( ".DATP-title" )[0].innerHTML.indexOf('Created Topics') !== -1){
  145. $( ".DATP-title" )[0].innerHTML = $( ".DATP-title" )[0].innerHTML.replace('Created Topics','Topics Active In');
  146. }else{
  147. $( ".DATP-title" )[0].innerHTML = $( ".DATP-title" )[0].innerHTML.replace('Topics Active In','Created Topics');
  148. }
  149. });
  150.  
  151.  
  152.  
  153.  
  154. /////////////////////////////
  155. //LOAD PARTIAL USER PANEL
  156. /////////////////////////////
  157.  
  158. $( ".DATP-section .DATP-table-left" ).load( "https://www.wanikani.com/community/panel #active-topics table", function(){
  159. $( ".DATP-section .DATP-table-left>table" ).unwrap();
  160. $(".DATP-table-wrapper table:first-child").addClass('DATP-table-left');
  161. $( ".DATP-section .DATP-table-left thead" ).remove();
  162. $( ".DATP-section .DATP-table-left tbody tr" ).unwrap();
  163. $( ".DATP-section .DATP-table-left>tr>td:nth-child(2)" ).remove();
  164. $( ".DATP-section .DATP-table-left>tr>td:nth-child(2)" ).remove();
  165. $( ".DATP-section .DATP-table-left .description" ).html(function(i,oldhtml){return oldhtml.slice(0, oldhtml.indexOf('<br>')); });
  166. $(".DATP-section .DATP-table-left td").css('padding', '15px 30px 15px 15px').css('width','130px'); //PADDING AND WIDTH OF TIMESTAMP TD
  167. $(".DATP-section .DATP-table-left td:first-child").css('width','270px').css('padding','15px 0px 15px 30px');
  168. var a = $(".DATP-section .DATP-table-left a");
  169. a.css('display', 'inline');
  170. a.css('padding', '0');
  171. $(".dashboard section.DATP-section .DATP-table-left td:first-child a:first-child").after('<br>');
  172. $(".dashboard section.DATP-section .DATP-table-left tr").after('<tr><td colspan="2"><hr></td></tr>');
  173. $(".dashboard section.DATP-section .DATP-table-left tr:last-child").remove();
  174. });
  175.  
  176.  
  177. /////////////////////////////
  178.  
  179. function loadCreatedTopics(){
  180. $( ".DATP-section .DATP-table-right" ).load( "https://www.wanikani.com/community/panel #created-topics table", function(){
  181. $( ".DATP-section .DATP-table-right>table" ).unwrap();
  182. $(".DATP-table-wrapper table:last-child").addClass('DATP-table-right');
  183. $( ".DATP-section .DATP-table-right thead" ).remove();
  184. $( ".DATP-section .DATP-table-right tbody tr" ).unwrap();
  185. $( ".DATP-section .DATP-table-right>tr>td:nth-child(2)" ).remove();
  186. $( ".DATP-section .DATP-table-right>tr>td:nth-child(2)" ).remove();
  187. $( ".DATP-section .DATP-table-right .description" ).html(function(i,oldhtml){return oldhtml.slice(0, oldhtml.indexOf('<br>')); });
  188. $(".DATP-section .DATP-table-right td").css('padding', '15px 30px 15px 15px').css('width','130px'); //PADDING AND WIDTH OF TIMESTAMP TD
  189. $(".DATP-section .DATP-table-right td:first-child").css('width','270px').css('padding','15px 0px 15px 30px');
  190. var a = $(".DATP-section .DATP-table-right a");
  191. a.css('display', 'inline');
  192. a.css('padding', '0');
  193. $(".dashboard section.DATP-section .DATP-table-right td:first-child a:first-child").after('<br>');
  194. $(".dashboard section.DATP-section .DATP-table-right tr").after('<tr><td colspan="2"><hr></td></tr>');
  195. $(".dashboard section.DATP-section .DATP-table-right tr:last-child").remove();
  196. $( ".DATP-section .DATP-table-right").css('left', '0px');
  197. $('.DATP-table-wrapper .DATP-table-right').removeClass('DATP-loading');
  198. });
  199. }
  200.  
  201. function addStyle(aCss) {
  202. var head, style;
  203. head = document.getElementsByTagName('head')[0];
  204. if (head) {
  205. style = document.createElement('style');
  206. style.setAttribute('type', 'text/css');
  207. style.textContent = aCss;
  208. head.appendChild(style);
  209. return style;
  210. }
  211. return null;
  212. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址