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 ].

目前为 2025-03-31 提交的版本。查看 最新版本

  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.2
  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'];
  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. document.querySelectorAll(chapterButtons[0]).length > 0 ? document.location = document.querySelectorAll(chapterButtons[0])[0].href : console.error('Already on first chapter.');
  89. break;
  90. case "ArrowRight":
  91. document.querySelectorAll(chapterButtons[1]).length > 0 ? document.location = document.querySelectorAll(chapterButtons[1])[0].href : console.error('Already on last chapter');
  92. break;
  93. case "ArrowUp":
  94. resize();
  95. break;
  96. case "]":
  97. userAddManga();
  98. break;
  99. default:
  100. break;
  101. }
  102. }
  103.  
  104. if (document.readyState !== 'loading') {
  105. setTimeout(checkMangaIds, 0);
  106. } else {
  107. document.addEventListener("DOMContentLoaded", function() {
  108. setTimeout(checkMangaIds, 0);
  109. });
  110. }

QingJ © 2025

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