Greasy Fork

[包子漫畫]快速前往下一話

按下N鍵 直接前往下一話,不用滾到最底下

目前为 2022-06-15 提交的版本。查看 最新版本

// ==UserScript==
// @name        [包子漫畫]快速前往下一話
// @namespace    http://tampermonkey.net/
// @version      0.41
// @description  按下N鍵 直接前往下一話,不用滾到最底下
// @author       dpes5407
// @match        *://*.webmota.com/comic/chapter*
// @match        *://*.baozimanhua.net/chapter*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=phpied.com
// @grant        none
// @noframes
// @supportURL  https://home.gamer.com.tw/profile/index.php?owner=dpes5407
// @license MIT
// ==/UserScript==

  (function () {
    "use strict";
    var baseUrl = window.location.href;
    if (baseUrl.includes("baozimanhua")) {
      baozimanhua();
    }
    if (baseUrl.includes("webmota")) {
      webmota();
    }
    function baozimanhua() {
      var elms = document.querySelectorAll(".j-rd-next");
      if (!elms) return;
      else {
        var urlArr = elms[1].outerHTML.replaceAll('"', " ").split(" ");
        var url = urlArr
          .filter((el) => el.indexOf("chapter") > -1)
          .toString();
        document.onkeydown = function (e) {
          keyEvent(e, url);
        };
      }
    }
    function webmota() {
      var elm = document.querySelector(".next_chapter");
      if (!elm) return;
      else {
        var link = elm.children[0].href;
        document.onkeydown = function (e) {
          keyEvent(e, link);
        };
      }
    }
    function keyEvent(e, link) {
      var keyNum = window.event ? e.keyCode : e.which;
      if (keyNum == 78) {
        if (link) {
          window.location.href = link;
        } else {
          alert("已經是最後一話了!");
        }
      }
    }
  })();