Greasy Fork

Greasy Fork is available in English.

枢-云端标记

这是一个用来标记一些B站中素质低下的人的脚本!

当前为 2021-08-16 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

"use strict";
// ==UserScript==
// @name         枢-云端标记
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  这是一个用来标记一些B站中素质低下的人的脚本!
// @author       Wow
// @include      /https?://www\.bilibili\.com/video/.+/
// @icon         https://www.google.com/s2/favicons?domain=bilibili.com
// @grant        none
// ==/UserScript==
var Mode;
(function (Mode) {
    Mode[Mode["QUERY"] = 0] = "QUERY";
    Mode[Mode["ALL"] = 1] = "ALL"; //[WIP]
})(Mode || (Mode = {}));
//API
const API = "https://api.fuckanti.com";
const API_QUERY = "/GetBadGuy";
const API_GET_ALL = "/GetBadGuys";
//WIP DO NOT CHANGE
const QUERY_MODE = Mode.QUERY;
class UStats {
    constructor() {
        this.mid = 0;
        this.tag = "";
        this.color = "";
        this.url = "";
        this.score = 0;
    }
}
class UStatsResponse {
    constructor() {
        this.ErrorCode = 0;
        this.Msg = "";
        this.Success = false;
        this.Data = [];
    }
}
function getStats(mids, callback) {
    if (mids.size == 0)
        return;
    let req = new XMLHttpRequest();
    req.open("GET", API + API_QUERY + "?mid=" + Array.from(mids).toString());
    req.onload = _ => {
        callback(req.response);
    };
    req.send();
}
function drawUsers(ue, us) {
    if (ue.length === 0 || us.length === 0)
        return;
    ue.forEach(u => {
        us.forEach(s => {
            try {
                if (Number(u.getAttribute("data-usercard-mid")) == s.mid) {
                    u.setAttribute("style", "color:" + s.color);
                    let str = u.textContent;
                    u.textContent = str + " |" + " <" + s.tag + ">" + " [" + s.score + "]";
                    if (s.url !== "") {
                        u.setAttribute("herf", s.url);
                    }
                }
            }
            catch (ignored) {
            }
        });
    });
}
function startObserve() {
    let observer = new MutationObserver(mutationRecords => {
        let mids = new Set();
        let elems = new Array();
        mutationRecords.forEach(rcd => {
            if (rcd.type == "childList") {
                try {
                    let users = Array.from(rcd.addedNodes);
                    users.forEach(user => {
                        try {
                            let lst = user.getElementsByTagName("a");
                            for (let i = 0; i < lst.length; ++i) {
                                try {
                                    let item = lst.item(i);
                                    if (item !== null && item.attributes[0].name === "data-usercard-mid") {
                                        let id = item.attributes[0].value;
                                        mids.add(Number(id));
                                        elems.push(item);
                                    }
                                }
                                catch (ignored) {
                                }
                            }
                        }
                        catch (ignored) {
                        }
                    });
                }
                catch (e) {
                    console.warn(e);
                }
            }
        });
        getStats(mids, res => {
            let usr = JSON.parse(res);
            if (usr.Success) {
                drawUsers(elems, usr.Data);
            }
            else {
                console.warn(usr.Msg + "错误代码:" + usr.ErrorCode);
            }
        });
    });
    let elem = document.getElementById("comment");
    if (elem !== null) {
        observer.observe(elem, {
            childList: true,
            subtree: true,
            characterDataOldValue: true
        });
    }
}
startObserve();