BatchOpenBilibiliComicWeb

批量打开bilibili漫画工具。使用键盘x打开隐藏工具,在输入框输入需要打开的网页数量后点击按钮

  1. // ==UserScript==
  2. // @name BatchOpenBilibiliComicWeb
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description 批量打开bilibili漫画工具。使用键盘x打开隐藏工具,在输入框输入需要打开的网页数量后点击按钮
  6. // @author HalfRain
  7. // @match https://manga.bilibili.com/detail/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant GM_addStyle
  10. // @require http://code.jquery.com/jquery-1.11.0.min.js
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14.  
  15. //--- Use jQuery to add the form in a "popup" dialog.
  16. $("body").append ( ' \
  17. <div id="gmPopupContainer"> \
  18. <form> <!-- For true form use method="POST" action="YOUR_DESIRED_URL" --> \
  19. <input type="text" id="needOpenCount" value="10"> \
  20. \
  21. <button id="openMultiWeb" type="button">批量打开未购买漫画</button> \
  22. <button id="gmCloseDlgBtn" type="button">隐藏界面</button> \
  23. </form> \
  24. </div> \
  25. ' );
  26.  
  27.  
  28. //--- Use jQuery to activate the dialog buttons.
  29. $("#openMultiWeb").click ( function () {
  30. var needOpenCount = $("#needOpenCount").val ();
  31. console.log(needOpenCount);
  32.  
  33. let list = document.querySelector("body > div.app-layout > div.size-ruler.p-relative.border-box > div.manga-detail > div.section > div.section-list.layout > div.episode-list-component.episode-list > div.episode-list")
  34. if (list == null) {
  35. return;
  36. }
  37.  
  38. let buttons = $(list).find("button");
  39.  
  40. let count = 0;
  41. for (var i = 0; i < buttons.length; i++) {
  42. let button = buttons[i];
  43. if (button != null) {
  44. if ($(button).find("div[class='tag lock-icon locked']").length != 0) {
  45. buttons[i].click();
  46. count++;
  47. }
  48.  
  49. if(count >= needOpenCount){
  50. return;
  51. }
  52. }
  53. }
  54. } );
  55.  
  56. $("#gmCloseDlgBtn").click ( function () {
  57. $("#gmPopupContainer").hide ();
  58. } );
  59.  
  60.  
  61. //--- CSS styles make it work...
  62. GM_addStyle ( " \
  63. #gmPopupContainer { \
  64. position: fixed; \
  65. top: 30%; \
  66. left: 50%; \
  67. padding: 1em; \
  68. background: #66ccff; \
  69. } \
  70. #gmPopupContainer button{ \
  71. cursor: pointer; \
  72. margin: 1em 1em 0; \
  73. border: 1px outset buttonface; \
  74. } \
  75. " );
  76.  
  77. (function () {
  78. 'use strict';
  79.  
  80. //使用
  81. window.document.addEventListener("keydown", function(event) {
  82. const keyName = event.key;
  83. if (keyName == 'x' || keyName == 'X') {
  84. if($("#gmPopupContainer").is(":hidden")){
  85. $("#gmPopupContainer").show ();
  86. }
  87. else
  88. {
  89. $("#gmPopupContainer").hide ();
  90. }
  91. }
  92. } )
  93. })();