newtoblock & downloader

try to take over the world!

当前为 2020-11-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name newtoblock & downloader
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @include http*://manatoki*
  8. // @grant GM_download
  9. // ==/UserScript==
  10. // adblock
  11. $('.hd_pops').remove()
  12. $('.board-tail-banner').remove()
  13. $('.basic-banner.row.row-10').remove()
  14. // append download button
  15. var sendBtn = document.createElement("button");
  16. sendBtn.className = "btn btn-warning";
  17. sendBtn.style.zIndex = "3";
  18. sendBtn.style.position = "fixed";
  19. sendBtn.style.bottom = "0";
  20. sendBtn.style.right = "0";
  21. sendBtn.innerText = "download";
  22. // check whether user is at viewpage
  23. if (document.URL.includes("board") == false) {
  24. document.getElementById("main-banner-view").appendChild(sendBtn);
  25. }
  26. var flen;
  27. var regex = /\d+/g;
  28. var mnum = document.URL.match(regex)[1];
  29. // get page title and manga number
  30. sendBtn.onclick = function() {
  31. // let canvas = $("img[src*='/data/file/comic'][src*="+mnum+"]").not("img[src*='thumb']")
  32. var title = document.getElementsByClassName('page-desc')[0].innerHTML
  33. let canvas = $("img[src*='/data/']").not("img[src*='thumb']")
  34. let loadimg = $('img[src$="/img/loading-image.gif"]')
  35. let countedword = {}
  36. // check if loading is completed
  37. if (loadimg.length <= 1) {
  38. // get every image which contains '/data/' and classify with parentNode inside the object
  39. for (let i = 0; i < canvas.length; i++) {
  40. var word = canvas[i].parentNode
  41. if (countedword[word.className] == undefined) {
  42. countedword[word.className] = 1;
  43. } else {
  44. countedword[word.className] += 1;
  45. }
  46. }
  47. //get the manga image from the object
  48. let a = 0;
  49. let viewdiv = Object.keys(countedword)[1]
  50. console.log(viewdiv);
  51. console.log(countedword)
  52. // download every manga images every 0.3 sec
  53. for (let i = 0; i < canvas.length; i++) {
  54. (function(x) {
  55. setTimeout(function() {
  56. let word = canvas[i].parentNode
  57. if (word.className == viewdiv) {
  58. a += 1
  59. var blob = canvas[i].currentSrc
  60. let arg = {
  61. url: blob,
  62. name: title + a
  63. };
  64. GM_download(arg)
  65. }
  66. }, 300 * x);
  67. })(i);
  68. }
  69. } else {
  70. alert("wait for loading...")
  71. }
  72. };