Sleazy Fork is available in English.

Webcomic Reader

Allows you to scroll through comics, rather than clicking.

  1. // ==UserScript==
  2. // @name Webcomic Reader
  3. // @description Allows you to scroll through comics, rather than clicking.
  4. // @author HIDDEN-lo
  5. // @version 1.0
  6. // @match *://akuma.moe/*
  7. // @license MIT
  8. // @run-at document-start
  9. // @namespace https://greasyfork.org/users/1206627
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Used to get the last page # for generating the URL
  16. function findHighestOptionValue() {
  17. var options = document.querySelectorAll('option[value]');
  18. var highestValue = -Infinity;
  19. options.forEach(function(option) {
  20. var value = parseInt(option.getAttribute('value'), 10);
  21. if (!isNaN(value) && value > highestValue) {
  22. highestValue = value;
  23. }
  24. });
  25. return highestValue;
  26. }
  27.  
  28. // Function to check if the current page is in reading mode
  29. function isReadingMode() {
  30. var url = window.location.href;
  31. return /\/\d+$/.test(url); // Check if the URL ends with a number
  32. }
  33.  
  34. // Function to extract the current page number from the URL
  35. function getCurrentPageNumber() {
  36. var url = window.location.href;
  37. var matches = url.match(/\/(\d+)$/);
  38. if (matches && matches[1]) {
  39. return parseInt(matches[1], 10);
  40. }
  41. return 0;
  42. }
  43.  
  44. // Function to add an image to the parent element with id "image-container"
  45. function addImageToParentContainer(imgLink) {
  46. var parentContainer = document.getElementById('image-container'); // Parent container
  47. if (parentContainer) {
  48. var imgElement = document.createElement('img');
  49. imgElement.setAttribute('src', imgLink);
  50. parentContainer.appendChild(imgElement);
  51. }
  52. }
  53.  
  54. // Function to load and add images from subsequent pages
  55. function loadAndAddImagesFromPage(pageNumber) {
  56. var pageUrl = window.location.href.replace(/\/\d+$/, '/' + pageNumber);
  57. var xhr = new XMLHttpRequest();
  58. xhr.open('GET', pageUrl, true);
  59. xhr.onreadystatechange = function() {
  60. if (xhr.readyState === 4 && xhr.status === 200) {
  61. console.log('Loaded images from page:', pageUrl);
  62. var html = xhr.responseText;
  63. var matches = html.match(/<img[^>]+src=["']([^"']+)/gi);
  64. if (matches) {
  65. matches.forEach(function(match, index) {
  66. var srcMatch = match.match(/src=["']([^"']+)/i);
  67. if (srcMatch && srcMatch[1]) {
  68. var imgLink = srcMatch[1];
  69. // Check if the imgLink matches the original page's src
  70. if (imgLink !== getOriginalPageSrc()) {
  71. addImageToParentContainer(imgLink); // Add the image to the parent container
  72. }
  73. }
  74. });
  75. }
  76.  
  77. // Continue loading and adding images from the next page
  78. loadAndAddImagesFromPage(pageNumber + 1);
  79. }
  80. };
  81. xhr.send();
  82. }
  83.  
  84. // Function to get the original page's src
  85. function getOriginalPageSrc() {
  86. var imgElement = document.querySelector('img'); // Get the first image on the page
  87. if (imgElement) {
  88. return imgElement.getAttribute('src');
  89. }
  90. return '';
  91. }
  92.  
  93. // Function to create and trigger the button
  94. function createButton() {
  95. // Create a button to trigger the script
  96. var button = document.createElement('button');
  97. button.textContent = 'Load Images';
  98. button.style.position = 'fixed';
  99. button.style.top = '10px';
  100. button.style.left = '10px';
  101. button.style.zIndex = '9999';
  102.  
  103. // Add an event listener to run the script on button click
  104. button.addEventListener('click', function() {
  105. button.style.display = 'none'; // Hide the button after clicking
  106. var currentPageNumber = getCurrentPageNumber();
  107. loadAndAddImagesFromPage(currentPageNumber); // Start loading and adding images from the current page
  108. checkURLChange();
  109. markRead();
  110. });
  111.  
  112. // Add the button to the page if in reading mode
  113. if (isReadingMode()) {
  114. document.body.appendChild(button);
  115. }
  116. }
  117. function gotoLastPage() {
  118. // Remove current page # from URL
  119. var currentURL = window.location.href;
  120.  
  121. // Use a regular expression to find the last "/" and any numbers that follow it
  122. var regex = /\/(\d+)+$/;
  123. var match = currentURL.match(regex);
  124.  
  125. if (match) {
  126. var numbersToRemove = match[0];
  127. var updatedURL = currentURL.replace(numbersToRemove, '');
  128. }
  129. updatedURL = updatedURL + "/" + findHighestOptionValue();
  130. console.log("Updated URL: ", updatedURL);
  131.  
  132. window.location.href = updatedURL;
  133. }
  134.  
  135. function markRead() {
  136. // Create a button to trigger the script
  137. var button = document.createElement('button');
  138. button.textContent = 'Mark as Read';
  139. button.style.position = 'relative';
  140. button.style.bottom = '40px';
  141. button.style.left = '43.4%';
  142. button.style.zIndex = '9999';
  143.  
  144. // Add an event listener to run the script on button click
  145. button.addEventListener('click', function() {
  146. gotoLastPage();
  147. });
  148.  
  149.  
  150. // Add the button to the page if in reading mode
  151. if (isReadingMode()) {
  152. document.body.appendChild(button);
  153. }
  154. }
  155.  
  156. function checkURLChange() {
  157. var currentURL = window.location.href;
  158.  
  159. setInterval(function() {
  160. console.log("Checking");
  161. var newURL = window.location.href;
  162. if (newURL !== currentURL) {
  163. // URL has changed, reload the page
  164. location.reload();
  165. }
  166. }, 500); // Check every second (1000 milliseconds)
  167. }
  168.  
  169. // Call the function to create and trigger the button
  170. createButton();
  171. })();