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 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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;
}