畅想之星小助手

图片批量下载,解除复制保护,自动验证码

  1. // ==UserScript==
  2. // @name 畅想之星小助手
  3. // @namespace https://qinlili.bid
  4. // @version 0.4
  5. // @description 图片批量下载,解除复制保护,自动验证码
  6. // @author 琴梨梨
  7. // @match *://*/onlineepub?*
  8. // @match *://*/onlinebook?ruid=*&pinst=*
  9. // @match *://*/Account/Login?*
  10. // @match *://*/Account/UserLogin?*
  11. // @grant none
  12. // @run-at document-idle
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. //登陆页面
  18. if(document.location.pathname.indexOf("Account")>0){
  19. var vCode="114514";
  20. //拦截XHR
  21. (function(open) {
  22. XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
  23. console.log(vCode)
  24. if((url.indexOf("GetLoginRandomCode")>0)&&!(vCode=="114514")){
  25. url= "data:text/plain,"+vCode;
  26. }
  27. open.call(this, method, url, async, user, pass);
  28. };
  29. })(XMLHttpRequest.prototype.open);
  30. //读取验证码
  31. var xhr = new XMLHttpRequest();
  32. xhr.onload = event => {
  33. if (xhr.readyState === 4 && xhr.status === 200) {
  34. vCode= xhr.response;
  35. console.log("验证码是"+vCode)
  36. $("#codeCover").click();
  37. setTimeout(function(){document.getElementById("vcode").value=vCode;$('#showInfor').html("琴梨梨为你自动填写验证码");},250)
  38. }
  39. xhr.onerror = function (e) {
  40. logcat("验证码读取失败")
  41. }
  42. }
  43. xhr.open('GET',document.location.origin+"/Account/GetLoginRandomCode");
  44. xhr.send();
  45. }
  46. //EPUB
  47. if(document.location.pathname.indexOf("onlineepub")>0){
  48. //右键复制
  49. $(document).unbind("contextmenu", null);
  50. $("#page_container").unbind("mouseup",null);
  51. //按钮复制
  52. //var copyBtn=document.getElementsByClassName("marker-menu-item marker-menu-item-copy")[0];
  53. //copyBtn.addEventListener("click",function(e){
  54. // e.preventDefault();
  55. //})
  56. }
  57. //图片爬虫
  58. if(document.location.pathname.indexOf("onlinebook")>0){
  59. document.body.oncontextmenu = ""
  60. var pageTotal = 0;
  61. var picUrl = ""
  62. //从0开始,为实际页码减一
  63. var pageCurrent = 0;
  64. //下载指定页面图片
  65. function downloadPic(page) {
  66. picUrl = path + "&pageNo=" + page + "&" + getNonceStr();
  67. fetch(picUrl).then(res => res.blob().then(blob => {
  68. var a = document.createElement('a');
  69. var url = window.URL.createObjectURL(blob);
  70. var filename = page + '.jpg';
  71. a.href = url;
  72. a.download = filename;
  73. a.click();
  74. window.URL.revokeObjectURL(url);
  75. if(pageCurrent<pageTotal){
  76. pageCurrent++;
  77. downloadPic(pageCurrent);
  78. }
  79. }))
  80. }
  81. //批量下载
  82. function batchDownload() {
  83. pageTotal = document.getElementById("sumNumb").innerText - 1;
  84. downloadPic(pageCurrent)
  85. }
  86. //创建下载按钮
  87. var downloadBtn = document.createElement("a");
  88. downloadBtn.innerText = "批量下载全书";
  89. downloadBtn.onclick = function () { batchDownload() };
  90. document.querySelector("body > div.divcenter > div.bq > div.bqmiddle > div.ml").appendChild(downloadBtn);
  91. }
  92. })();