Mangaelo declutter and shortcuts

Removes shit from mangaelo

当前为 2018-09-17 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

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