第一版主小说阅读

阅读小说时增强功能:1. 预加载下一页;2. 自动填充人机验证;

目前為 2024-04-06 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         第一版主小说阅读
// @namespace    https://diyibanzhu.org/
// @version      0.2
// @description  阅读小说时增强功能:1. 预加载下一页;2. 自动填充人机验证;
// @author       Essence
// @match        https://*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=diyibanzhu.org
// @run-at       document-end
// @license MIT
// ==/UserScript==

// 站点名。域名经常变动,没有更好的判断方法
const SITE_NAME = "歪歪蒂艾斯";

// 脚本页面:预加载下一页
const nextPage = ()=>{
    // 依次找到"下一页"的元素:优先“下一页”,其次“下一章”
    const nextLink = document.querySelector("a.curr")?.nextElementSibling || document.querySelector("a.next");

    console.log("脚本将预加载下一页", nextLink, nextLink?.href);

    // If we found a matching link
    if (nextLink && nextLink.href) {
        // 通过"link prefetching"实现预加载下一页
        const link = document.createElement("link");

        // 注意:最后第一版主网站的章中最后的一页的 URL 的 href 是以"javascript:"开头,其它页是正常的 URL
        let href = nextLink.href;
        if(href.startsWith("javascript:")){
            const params = href.match(/\d+/g)
            href = "/" + params.slice(0, -1).join("/") + "_" + params.slice(-1) + ".html";
        }

        link.href = href;
        link.rel = "prefetch";
        document.head.appendChild(link);
    }
}

// 脚本页面:自动填充人机验证
const verifyPage = ()=>{
    document.querySelector("input#password").value="1234";
    document.querySelector("div.login a").click();
}


(function() {
    'use strict';

    // Your code here...
    // 不是目标网站
    if(!document.title.includes(SITE_NAME)){
        return;
    }

    // 脚本页面:预加载下一页
    if(document.querySelector("h1.page-title")?.textContent?.trim()){
        console.log("预加载下一页");
        nextPage();
    }

    // 脚本页面:自动填充人机验证
    if(document.querySelector("div.title")?.textContent?.includes("为防止恶意访问")){
        console.log("自动填充人机验证");
        verifyPage();
    }
})();