Mangaelo declutter and shortcuts

Removes shit from mangaelo

目前為 2018-09-17 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Mangaelo declutter and shortcuts
// @namespace    https://github.com/Bobocato/Userscripts
// @version      1.0
// @description  Removes shit from mangaelo
// @author       Bobocato
// @match        https://manganelo.com/chapter/*
// @grant        none
// ==/UserScript==

var autoload = true;

(function() {
    'use strict';
    //Remove Header and footer stuff
    //Header
    document.getElementsByClassName("logo_chapter")[0].remove();
    document.getElementsByClassName("breadcrumb")[0].remove();
    document.getElementsByClassName("option_wrap")[0].remove();
    document.getElementsByClassName("info-top-chapter")[0].remove();
    //Footer
    document.getElementsByClassName("breadcrumb")[0].remove();
    document.getElementsByTagName("footer")[0].remove();
    document.getElementsByClassName("comments")[0].remove();
    let as = document.getElementsByTagName("A")
    for(let i = 0; i < as.length; i++){
        if(as[i].href == "https://manganelo.com/home"){
            as[i].remove();
            i = 500;
        }
    }

    if(autoload){
        var timer = null;
        window.addEventListener("scroll", function(event) {
            var e = document.documentElement;
            if (e.scrollHeight - e.scrollTop === e.clientHeight)
            {
                console.log("Bomb has been planted");
                timer = setTimeout(nextChapter, 1500);
            } else {
                if (timer != null){
                    console.log("Bomb has been defused");
                    clearTimeout(timer);
                    timer = null;
                }
            }
        });
    }
    document.addEventListener("keydown", keyDownTextField, false);

    function keyDownTextField(e) {
        var search = document.getElementsByClassName("searchinput")[0];
        if (document.activeElement !== search) {
            switch (e.which) {
                case 37: // "Arrow Left"
                    document.getElementsByClassName("next")[0].click();
                    break;
                case 39: // "Arrow Right"
                    nextChapter();
                    break
                default:
                    return; // exit this handler for other keys
            }
            e.preventDefault(); // prevent the default action
        } else if (e.which == 32) {
            search.value += " ";
            e.preventDefault();
        }
        return;
    }

    function nextChapter(){
        document.getElementsByClassName("back")[0].click();
    }

    function getDocHeight() {
        var D = document;
        return Math.max(
            D.body.scrollHeight, D.documentElement.scrollHeight,
            D.body.offsetHeight, D.documentElement.offsetHeight,
            D.body.clientHeight, D.documentElement.clientHeight
        );
    }
})();