You can quickly access the previous and next episodes, perform smooth scrolling up or down, and even enable or disable full-screen mode. This script is designed to enhance the reading experience of web content such as manga and comics in a more convenient and efficient way.
目前為
// ==UserScript==
// @name SmoothScroll & Navigation Enhancer
// @namespace http://tampermonkey.net/
// @version 1.1
// @description You can quickly access the previous and next episodes, perform smooth scrolling up or down, and even enable or disable full-screen mode. This script is designed to enhance the reading experience of web content such as manga and comics in a more convenient and efficient way.
// @match https://westmanga.info/*
// @match https://komikcast.vip/*
// @match https://aquamanga.com/read/*
// @match https://www.webtoons.com/*
// @match https://kiryuu.id/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
var scrollInterval = null;
var isScrolling = false
var isFullscreen = false;
var activeElement;
var smoothScrollSpeed = 9; // Kecepatan pengguliran yang mulus
var smoothScrollDelay = 10; // Penundaan di antara setiap langkah pengguliran yang mulus
function smoothScrollStep(direction) {
var scrollDistance = direction === 'up' ? -smoothScrollSpeed : smoothScrollSpeed;
window.scrollBy(0, scrollDistance);
}
function startSmoothScrolling(direction) {
if (!isScrolling) {
isScrolling = true;
smoothScrollStep(direction);
scrollInterval = setInterval(function() {
smoothScrollStep(direction);
}, smoothScrollDelay);
}
}
function stopSmoothScrolling() {
if (isScrolling) {
isScrolling = false;
clearInterval(scrollInterval);
}
}
document.addEventListener('keydown', function(event) {
if (event.key === 'a' || event.key === 'A' || event.key === 'ArrowLeft') {
var prevButton;
if (window.location.host === 'westmanga.info') {
prevButton = document.querySelector('.ch-prev-btn');
} else if (window.location.host === 'komikcast.vip') {
prevButton = document.querySelector('.nextprev a[rel="prev"]');
} else if (window.location.host === 'aquamanga.com') {
prevButton = document.querySelector('a.btn.prev_page');
} else if (window.location.host === 'kiryuu.id') {
prevButton = document.querySelector('a.ch-prev-btn');
} else if (window.location.host === 'www.webtoons.com') {
prevButton = document.querySelector('a[title="Episode sebelumnya"]');
}
if (prevButton) {
// Periksa elemen yang sedang dalam fokus
activeElement = document.activeElement;
if (!(activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA'))) {
// Pengguna tidak sedang mengetik
prevButton.click();
}
}
} else if (event.key === 'd' || event.key === 'D' || event.key === 'ArrowRight') {
var nextButton;
if (window.location.host === 'westmanga.info') {
nextButton = document.querySelector('.ch-next-btn');
} else if (window.location.host === 'komikcast.vip') {
nextButton = document.querySelector('.nextprev a[rel="next"]');
} else if (window.location.host === 'aquamanga.com') {
nextButton = document.querySelector('a.btn.next_page');
} else if (window.location.host === 'kiryuu.id') {
nextButton = document.querySelector('a.ch-next-btn');
} else if (window.location.host === 'www.webtoons.com') {
nextButton = document.querySelector('a[title="Episode selanjutnya"]');
}
if (nextButton) {
// Periksa elemen yang sedang dalam fokus
activeElement = document.activeElement;
if (!(activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA'))) {
// Pengguna tidak sedang mengetik
nextButton.click();
}
}
} else if (event.key === 's' || event.key === 'S') {
// Periksa elemen yang sedang dalam fokus
activeElement = document.activeElement;
if (!(activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA'))) {
// Pengguna tidak sedang mengetik
startSmoothScrolling('down');
}
} else if (event.key === 'w' || event.key === 'W') {
// Periksa elemen yang sedang dalam fokus
activeElement = document.activeElement;
if (!(activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA'))) {
// Pengguna tidak sedang mengetik
startSmoothScrolling('up');
}
} else if (event.key === 'f' || event.key === 'F') {
// Periksa elemen yang sedang dalam fokus
activeElement = document.activeElement;
if (!(activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA'))) {
// Pengguna tidak sedang mengetik, masuk ke mode fullscreen
event.preventDefault();
toggleFullscreen(); // Fungsi Anda untuk masuk/keluar dari mode fullscreen
}
} else if (event.key === 'q' || event.key === 'Q') {
var allChapterButton;
if (window.location.host === 'westmanga.info') {
allChapterButton = document.querySelector('.allc a');
} else if (window.location.host === 'www.webtoons.com') {
allChapterButton = document.querySelector('a[class="subj NPI=a:end,g:in_id"]');
} else if (window.location.host === 'kiryuu.id') {
allChapterButton = document.evaluate("//div[contains(text(), 'Semua chapter ada di')]/a", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
} else if (window.location.host === 'komikcast.vip') {
allChapterButton = document.querySelector('div.allc a');
} else if (window.location.host === 'aquamanga.com') {
// Ambil URL saat ini
var currentUrl = window.location.href;
// Gunakan ekspresi reguler untuk menghapus segmen URL setelah judul komik
var newUrl = currentUrl.replace(/\/read\/([^/]+)\/.*/, '/read/$1/');
// Periksa elemen yang sedang dalam fokus
activeElement = document.activeElement;
if (!(activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA'))) {
// Pengguna tidak sedang mengetik memindahkan pengguna ke URL yang telah diubah
window.location.href = newUrl;
}
}
if (allChapterButton) {
// Periksa elemen yang sedang dalam fokus
activeElement = document.activeElement;
if (!(activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA'))) {
// Pengguna tidak sedang mengetik
allChapterButton.click();
}
}
}
});
function toggleFullscreen() {
if (!isFullscreen) {
enterFullscreen();
} else {
exitFullscreen();
}
isFullscreen = !isFullscreen;
}
function enterFullscreen() {
const elem = document.documentElement;
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) {
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
}
}
function exitFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
document.addEventListener('keyup', function(event) {
if (event.key === 's' || event.key === 'S' || event.key === 'w' || event.key === 'W') {
stopSmoothScrolling();
window.scrollTo(window.pageXOffset, window.pageYOffset); // Menghentikan scroll secara instan
}
});
})();