VoidVerified

Display a verified sign next to user's name in AniList.

当前为 2023-09-30 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         VoidVerified
// @namespace    http://tampermonkey.net/
// @version      0.3.1
// @description  Display a verified sign next to user's name in AniList.
// @author       voidnyan
// @match        https://anilist.co/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    const version = "0.3.1";

    const verified = {
        username: {
            enabled: true,
            enabledForReplies: true,
            color: "white",
            sign: "✔",
        },
        highlight: {
            enabled: true,
            enabledForReplies: true,
            enabledForSmallCards: false,
            color: undefined,
            size: "5px",
        }
    };

    const verifiedUsers = [
        {
            username: "voidnyan",
            color: "#f8aade",
            sign: "💻",
        },
    ].map(u => typeof u === "string" ? {username: u} : u);

    let verifiedStyles = "";

    for (const user of verifiedUsers){
        if (verified.username.enabled) {
            createUsernameCSS(user);
        }

        if (verified.highlight.enabled) {
            createHighlightCSS(user, `div.wrap:has( div.header > a.name[href*="${user.username}"] )`);
            createHighlightCSS(user, `div.wrap:has( div.details > a.name[href*="${user.username}"] )`);
        }

        if (verified.highlight.enabledForReplies) {
            createHighlightCSS(user, `div.reply:has( a.name[href*="${user.username}"] )`);
        }
    }

    if (verified.highlight.enabled && !verified.highlight.enabledForSmallCards) {
        disableHighlightOnSmallCards();
    }

    function createUsernameCSS(user) {
        verifiedStyles += `
        a.name[href*="${user.username}"]::after {
            content: "${user.sign ?? verified.username.sign}";
            color: ${user.color ?? verified.username.color ?? "rgb(var(--color-blue))"}
        }
        `;
    };

    function createHighlightCSS(user, selector){
        verifiedStyles += `
        ${selector} {
            margin-right: -${verified.highlight.size};
            border-right: ${verified.highlight.size} solid ${user.color ?? verified.highlight.color ?? "rgb(var(--color-blue))"};
            border-radius: 5px;
        }
        `;
    }

    function disableHighlightOnSmallCards(){
        verifiedStyles += `
        div.wrap:has(div.small) {
        margin-right: 0px !important;
        border-right: 0px solid black !important;
        }
        `;
    }

    const linkElement = document.createElement('link');
    linkElement.setAttribute('rel', 'stylesheet');
    linkElement.setAttribute('type', 'text/css');
    linkElement.setAttribute('href', 'data:text/css;charset=UTF-8,' + encodeURIComponent(verifiedStyles));
    document.head?.append(linkElement);

    console.log(`VoidVerified ${version} loaded.`);
})();