连环画下载器

自动打包下载

  1. // ==UserScript==
  2. // @name 连环画下载器
  3. // @namespace https://qinlili.bid/
  4. // @version 0.2
  5. // @description 自动打包下载
  6. // @author 琴梨梨
  7. // @match http://wx.zhlhh.com/Reader/*?*
  8. // @match http://zy.zhlhh.com/Downloader?*
  9. // @grant none
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. var imgInfo;
  17. if (document.location.host == "wx.zhlhh.com") {
  18. $("#dibu").show();
  19. document.getElementById("xzing").lastElementChild.removeAttribute("href");
  20. document.getElementById("xzwc").lastElementChild.removeAttribute("href");
  21. document.getElementById("xzing").onclick = function () {
  22. window.open('http://zy.zhlhh.com/Downloader?title=' + document.title + "&json=" + btoa(JSON.stringify(gallery.items)), 'target', '');
  23. }
  24. }
  25. if (document.location.host == "zy.zhlhh.com") {
  26. document.querySelector("body").innerHTML="<H2>打包需要时间,请耐心等待</H2><H2>本页面仅用于CORS注入,分享网址没有用</H2>"
  27. var searchParams = new URLSearchParams(document.location.search);
  28. imgInfo = JSON.parse(atob(searchParams.get("json") ))
  29. document.title="下载:" + searchParams.get("title");
  30. var zip;
  31. function makeZIP(){
  32. SakiProgress.showDiv();
  33. SakiProgress.setText("准备下载...");
  34. downloadBtn.innerText="工作中...";
  35. downloadBtn.disabled=true;
  36. var i = 0;
  37. zip = new JSZip();
  38. function dlNext() {
  39. SakiProgress.setText("正在处理" + (i+1) + "页...");
  40. SakiProgress.setPercent(i/imgInfo.length*80);
  41. fetch(imgInfo[i].src).then(res => res.blob().then(blob => {
  42. zip.file((i + 1) + ".jpg", blob, { binary: true })
  43. i = i + 1;
  44. if (imgInfo[i]) { dlNext(); }else{
  45. SakiProgress.setText( "正在打包...");
  46. SakiProgress.setPercent(80);
  47. dlZIP();
  48. }
  49. }))
  50. }
  51. dlNext();
  52. }
  53. var downloadBtn = document.createElement("button");
  54. downloadBtn.innerText = "正在初始化...";
  55. downloadBtn.onclick = function () { makeZIP() }
  56. downloadBtn.disabled=true;
  57. document.querySelector("body").appendChild(downloadBtn);
  58. function dlZIP(){
  59. zip.generateAsync({ type: "blob" }).then(function (blob) {
  60. SakiProgress.setText( "正在导出...");
  61. SakiProgress.setPercent(90);
  62. var a = document.createElement('a');
  63. var url = window.URL.createObjectURL(blob);
  64. var filename = searchParams.get("title") + ".zip";
  65. a.href = url;
  66. a.download = filename;
  67. a.click();
  68. window.URL.revokeObjectURL(url);
  69. downloadBtn.innerText="保存成功!";
  70. setTimeout(function(){
  71. SakiProgress.setText( "下载成功!");
  72. SakiProgress.setPercent(100);
  73. SakiProgress.clearProgress();
  74. },1000)
  75. });
  76. }
  77. downloadBtn.innerText = "正在加载JSZip依赖...";
  78. var script = document.createElement("script");
  79. script.type = "text/javascript";
  80. script.src = "https://cdn.jsdelivr.net/npm/jszip@3.6.0/dist/jszip.min.js";
  81. document.body.appendChild(script);
  82. script.onload=function(){
  83. downloadBtn.innerText = "正在加载SakiProgress依赖...";
  84. var script = document.createElement("script");
  85. script.type = "text/javascript";
  86. script.src = "https://cdn.jsdelivr.net/gh/qinlili23333/SakiProgress@1.0.3/SakiProgress.min.js";
  87. document.body.appendChild(script);
  88. script.onload=function(){
  89. downloadBtn.innerText = "打包下载";
  90. SakiProgress.init();
  91. downloadBtn.disabled=false;
  92. }
  93. }
  94. }
  95. })();

QingJ © 2025

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