Lute: Current Page Statuses Alert Button

Adds a button to alert the current page term statuses

目前为 2024-04-24 提交的版本。查看 最新版本

// ==UserScript==
// @name         Lute: Current Page Statuses Alert Button
// @version      20240424.2
// @description  Adds a button to alert the current page term statuses
// @author       jamesdeluk
// @match        http://localhost:500*/read/*
// @grant        none
// @namespace https://greasyfork.dpdns.org/users/242246
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('load', function() {
        const btn_statuses = document.createElement('button');
        btn_statuses.textContent = "%";
        btn_statuses.style.position = "fixed";
        btn_statuses.style.left = "0";
        btn_statuses.style.top = "50%";
        btn_statuses.style.transform = "translateY(-50%)";
        btn_statuses.style.margin = "0.1em";
        btn_statuses.style.padding = "0.1em 0.1em";
        btn_statuses.style.zIndex = "1000";
        btn_statuses.onclick = function() {
            const statusNames = {
                'status0': '?',
                'status1': '1',
                'status2': '2',
                'status3': '3',
                'status4': '4',
                'status5': '5',
                'status98': 'X',
                'status99': '✓'
            };
            let totalStatusCount = 0;
            let statusCounts = Object.keys(statusNames).map(status => {
                let count = document.getElementsByClassName(status).length;
                totalStatusCount += count;
                return {status: statusNames[status], count};
            });
            let results = '';
            statusCounts.forEach(({status, count}) => {
                let percentage = (count / totalStatusCount) * 100;
                results += `${status.padEnd(2)} : ${String(count).padEnd(2)} (${percentage.toFixed(1)}%)\n`;
            });
            alert(results);
        };
      document.body.appendChild(btn_statuses);
    });
})();
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元