第一版主小说阅读

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

Versione datata 06/04/2024. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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();
    }
})();