Madokami navigation controls + auto scroll to top on next page

Adds navigation controls that allow you to go to the previous or next page. By clicking the current page number you can specify the desired page (go to page). When clicking on the image to proceed to the next page, this script will automatically scroll up to the top, so you won't have to.

目前為 2018-07-26 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Madokami navigation controls + auto scroll to top on next page
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds navigation controls that allow you to go to the previous or next page. By clicking the current page number you can specify the desired page (go to page). When clicking on the image to proceed to the next page, this script will automatically scroll up to the top, so you won't have to.
// @author       Zarnaik
// @match        https://manga.madokami.al/reader/*
// @grant        none
// ==/UserScript==

window.onLoad = start();

function start(){
    document.addEventListener("click",() => {
        window.scroll({top: 0, left: 0, behavior: 'smooth' });//scroll(0,200);
        addPageNumber();
    });
    addPageNumber();
}

function addPageNumber() {
    var page = document.location.href.split('index=')[1];
    var controls = document.createElement('p');
    controls.style = 'position:absolute;top: 5px;right:5px;background-color:black;cursor:pointer;'
    var page_element = document.createElement('a');
    page_element.innerHTML = 'p. ' + page;
    page_element.onclick = goToPage;
    page_element.title = 'Go to page';
    var previous = document.createElement('a');
    previous.innerHTML = '<';
    previous.href = document.location.href.split('index=')[0] + 'index=' + (page - 1);
    previous.style = 'padding-right: 15px';
    var next = document.createElement('a');
    next.innerHTML = '>';
    next.href = document.location.href.split('index=')[0] + 'index=' + (parseInt(page) + 1);
    next.style = 'padding-left: 15px';
    controls.appendChild(previous);
    controls.appendChild(page_element);
    controls.appendChild(next);
    document.body.appendChild(controls);

}

function goToPage() {
    var page = prompt('Go to page');
    document.location.href = document.location.href.split('index=')[0] + 'index=' + page;
}