MangaNato (Formerly Manganelo) Scripts (Next/Prev Chapter & Image Resize)

Allows L/R arrow key navigation between chapters, reize chapter images using / key & allows for adding manga to be automatically resize with ].

  1. // ==UserScript==
  2. // @name MangaNato (Formerly Manganelo) Scripts (Next/Prev Chapter & Image Resize)
  3. // @namespace ew0345
  4. // @match *://*manganato.*/*/*
  5. // @match *://*manganelo.*/*/*
  6. // @match *://*natomanga.*/*/*
  7. // @grant none
  8. // @version 1.5.4
  9. // @author ew0345, Qther
  10. // @description Allows L/R arrow key navigation between chapters, reize chapter images using / key & allows for adding manga to be automatically resize with ].
  11. // @icon https://manganato.com/favicon-96x96.png
  12. // ==/UserScript==
  13.  
  14. var chapterImages = ['.container-chapter-reader img'];
  15. var chapterButtons = ['.navi-change-chapter-btn-prev', '.navi-change-chapter-btn-next', '.btn-navigation-chap .next', '.btn-navigation-chap .back'];
  16. var widthPercent = 100;
  17. var mangaId = {};
  18. var mangaIdMatch = false;
  19.  
  20.  
  21. function checkMangaIds() {
  22. mangaId = JSON.parse(localStorage.getItem("__mangas")) || {};
  23.  
  24. if (Object.keys(mangaId).length === 0) {
  25. Object.assign(mangaId, {mangas: {}});
  26. localStorage.setItem("__mangas", JSON.stringify(mangaId));
  27. }
  28.  
  29. for (var i = 0; i < Object.keys(mangaId["mangas"]).length; i++) {
  30. if (document.location.toString().indexOf(Object.keys(mangaId["mangas"])[i]) >= 0) {
  31. console.log("%cFound match for manga with id: "+Object.keys(mangaId["mangas"])[i], "color:#00FF00");
  32. widthPercent = parseInt(Object.values(mangaId["mangas"])[i]);
  33. } else {
  34. console.log("%cFailed match for: "+Object.keys(mangaId["mangas"])[i], "color:#ff0000");
  35. }
  36. }
  37. if (widthPercent != 100) {
  38. resize();
  39.  
  40. }
  41. }
  42.  
  43. function userAddManga() {
  44. var mangaName = prompt("Copy and paste 'manga-######' or the manga name (with dashes) from webpage URL");
  45. var mangaSize = prompt("Percent to resize to");
  46. mangaName = mangaName.valueOf().toLowerCase();
  47. mangaSize = parseInt(mangaSize);
  48.  
  49. Object.assign(mangaId.mangas, {[mangaName]: mangaSize});
  50. localStorage.setItem("__mangas", JSON.stringify(mangaId));
  51.  
  52. checkMangaIds();
  53. }
  54.  
  55. function resize() {
  56. if (widthPercent == 0 || widthPercent == 100) {
  57. var inp = prompt('Image Width / %\n\'autoh\' to fit images to page height,\n\'autow\' to fit images to page width.');
  58. widthPercent = inp.valueOf().toLowerCase();
  59. }
  60.  
  61. if (widthPercent === "autow" || widthPercent === "w" || widthPercent === "fitw") {
  62. var pageWidth = document.body.clientWidth;
  63.  
  64. for (var i = 0; i < document.querySelectorAll(chapterImages).length; i++) {
  65. document.querySelectorAll(chapterImages)[i].style.width = pageWidth / document.querySelectorAll(chapterImages)[i].width * 100 + '%';
  66. }
  67. } else if (widthPercent === "autoh" || widthPercent === "h" || widthPercent === "fith" || widthPercent === "4koma") {
  68. var pageWidth = document.body.clientWidth;
  69. var pageHeight = window.height;
  70.  
  71. for (var i = 0; i < document.querySelectorAll(chapterImages).length; i++) {
  72. document.querySelectorAll(chapterImages)[i].style.width = pageWidth / document.querySelectorAll(chapterImages)[i].width * 100 + '%';
  73. document.querySelectorAll(chapterImages)[i].style.width = pageHeight / document.querySelectorAll(chapterImages)[i].height * 100 + '%';
  74. }
  75. } else if (widthPercent === 0) {
  76. return;
  77. } else {
  78. for (var i = 0; i < document.querySelectorAll(chapterImages).length; i++) {
  79. document.querySelectorAll(chapterImages)[i].style.width = widthPercent + '%';
  80. }
  81. }
  82. widthPercent = 100;
  83. }
  84.  
  85. window.onkeydown = function(e) {
  86. switch (e.key) {
  87. case "ArrowLeft":
  88. if (document.location.toString().indexOf("natomanga") || document.location.toString().indexOf("manganato.gg") >= 0) {
  89. document.querySelectorAll(chapterButtons[2]).length > 0 ? document.location = document.querySelectorAll(chapterButtons[2])[0].href : console.error('Already on first chapter.');
  90. } else {
  91. document.querySelectorAll(chapterButtons[0]).length > 0 ? document.location = document.querySelectorAll(chapterButtons[0])[0].href : console.error('Already on first chapter.');
  92. }
  93. break;
  94. case "ArrowRight":
  95. if (document.location.toString().indexOf("natomanga") || document.location.toString().indexOf("manganato.gg") >= 0) {
  96. document.querySelectorAll(chapterButtons[3]).length > 0 ? document.location = document.querySelectorAll(chapterButtons[3])[0].href : console.error('Already on last chapter');
  97. } else {
  98. document.querySelectorAll(chapterButtons[1]).length > 0 ? document.location = document.querySelectorAll(chapterButtons[1])[0].href : console.error('Already on last chapter');
  99. }
  100. break;
  101. case "ArrowUp":
  102. resize();
  103. break;
  104. case "]":
  105. userAddManga();
  106. break;
  107. default:
  108. break;
  109. }
  110. }
  111.  
  112. if (document.readyState !== 'loading') {
  113. setTimeout(checkMangaIds, 0);
  114. } else {
  115. document.addEventListener("DOMContentLoaded", function() {
  116. setTimeout(checkMangaIds, 0);
  117. });
  118. }

QingJ © 2025

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