Greasy Fork

Greasy Fork is available in English.

yande.re 历史最大页数记录

按日期记录主页最大页数,用于查看下次收图时的页数增长

当前为 2024-05-08 提交的版本,查看 最新版本

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         yande.re 历史最大页数记录
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  按日期记录主页最大页数,用于查看下次收图时的页数增长
// @author       rowink
// @match        https://yande.re/post
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// @grant        GM_listValues
// ==/UserScript==
// @note         0.1.1 修复意外的@grant丢失错误
// @note         0.1.0 转移作者
// @note         0.9 修复日期错误排序的问题
// @note         0.8 修复错误删除了前一天记录的问题
// @note         0.7 规范化部分代码
// @note         0.6 启用严格模式
// @note         0.5 修改正确页数的正向跳转
// @note         0.4 增加历史页数差值的正向跳转
// @note         0.3 代码优化
// @note         0.2 优化显示布局,增加当前页数与历史页数的差值显示
// @note         0.1 页数记录

(function () {
    "use strict";
    //设置最大记录数
    let max = 5;
    //获取最大页数
    let pagination = document.getElementById("paginator").getElementsByClassName("pagination")[0];
    let lastPage = pagination.getElementsByTagName("a")[5].textContent;
    /**
     * 记录最大页数
     * key:年份日期
     * value:当前最大页数
     */
    let date = new Date();
    let fullDate = date.getFullYear() + "-" + (parseInt(date.getMonth()) + 1) + "-" + date.getDate();
    GM_setValue(fullDate, lastPage);
    //绘制容器
    let panel = document.createElement("div");
    panel.setAttribute("id", "panel");
    let paginator = document.getElementById("paginator");
    paginator.appendChild(panel);
    /**
     * 容器item
     * div:容器
     * a:子链接容器
     * *_span:记录项 (t日期,p页数,d差值)
     */
    let show = (date, page) => {
        let d_value = lastPage - page;
        let panel = document.getElementById("panel");
        panel.innerHTML += "<br>";
        let div = document.createElement("div");
        let a = document.createElement("a");
        let t_span = document.createElement("span");
        let p_span = document.createElement("span");
        let d_span = document.createElement("span");
        t_span.style.float = "left";
        d_span.style.float = "right";
        t_span.innerText = "日期 : " + date;
        p_span.innerText = "页数 ♡" + page;
        d_span.innerText = "差值 +" + d_value;
        a.style.border = "none";
        if (d_value != 0) {
            a.setAttribute("href", "https://yande.re/post/?page=" + (d_value + 1));
        }
        a.appendChild(t_span);
        a.appendChild(p_span);
        a.appendChild(d_span);
        div.style.border = "1px white solid";
        div.style.color = "#ee8887";
        div.style.textAlign = "none";
        div.appendChild(a);
        panel.appendChild(div);
    }
    //取出所有记录,并且根据日期降序排序
    let date_k = GM_listValues();

    let sortByValue = (a, b) => {
        var valueA = GM_getValue(a);
        var valueB = GM_getValue(b);
        return valueA - valueB;
    }
    date_k.sort(sortByValue);


    //找到最小项
    let min = new Date(date_k[0]);
    let index = 0;
    for (let i = 0; i < date_k.length; i++) {
        let date_new = new Date(date_k[i]);
        if (date_new < min) {
            min = date_new;
            index = i;
        }
    }
    //根据最小项位置进行删除
    if (date_k.length > max) {
        GM_deleteValue(date_k[index]);
    }
    //显示全部页数记录
    console.log(date_k);
    for (const date of date_k) {
        let value = GM_getValue(date);
        if (value != null) {
            show(date, value);
        }
    }
})();