SH List All Chapters

Override the "Show All Chapters" button to list all chapters in the Table of Contents on ScribbleHub series pages instead of a pop-up.

当前为 2021-03-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name SH List All Chapters
  3. // @namespace ultrabenosaurus.ScribbleHub
  4. // @version 0.2
  5. // @description Override the "Show All Chapters" button to list all chapters in the Table of Contents on ScribbleHub series pages instead of a pop-up.
  6. // @author Ultrabenosaurus
  7. // @source https://greasyfork.org/en/users/437117-ultrabenosaurus?sort=name
  8. // @match https://www.scribblehub.com/series/*
  9. // @icon https://www.google.com/s2/favicons?domain=scribblehub.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. if( 0 != document.querySelectorAll('ul#pagination-mesh-toc li:nth-last-child(2)').length ){
  17. var top = parseInt( document.querySelectorAll('ul#pagination-mesh-toc li:nth-last-child(2)')[0].textContent );
  18. if( !isNaN( top ) && 1 < top ){
  19. //console.log(top);
  20. var btnElem = '<i class="fa fa-th-list chpnew" id="menu_icon_fic" aria-hidden="true" title="Show All Chapters"></i>';
  21. $('div.fic_toc_bar i#menu_icon_fic.fa-th-list').replaceWith(btnElem);
  22. var sacBtn = document.querySelectorAll('div.fic_toc_bar i#menu_icon_fic.fa-th-list')[0];
  23. if(sacBtn){
  24. sacBtn.addEventListener("click", function(){
  25. UBlistAllChaptersSH( top, 2 );
  26. }, false);
  27. }
  28. sacBtn = btnElem = null;
  29.  
  30. //UBlistAllChaptersSH( top, 2 );
  31. //top = null;
  32. }
  33. }
  34. })();
  35.  
  36. function UBlistAllChaptersSH(top, i){
  37. //console.log( top, i );
  38.  
  39. if( null != top && !isNaN( top ) && null != i && top >= i ){
  40. var e = $("#mypostid").attr("value");
  41. $.ajax({
  42. type: "POST",
  43. url: "https://www.scribblehub.com/wp-admin/admin-ajax.php",
  44. data: {
  45. action: "wi_getreleases_pagination",
  46. pagenum: i,
  47. mypostid: e
  48. },
  49. success: function(t) {
  50. //console.log(top, i);
  51. t = t.slice(0, -1);
  52. var ol = $(t).find('.toc_ol li');
  53. $('.toc_ol').append(ol);
  54. //console.log( ol );
  55. t = o = null;
  56. UBlistAllChaptersSH( top, i+1 );
  57. }
  58. });
  59. }
  60.  
  61. if( top <= i ){
  62. top = null;
  63. }
  64.  
  65. }