Greasy Fork

Greasy Fork is available in English.

B站共同关注查询

查成分!

当前为 2021-06-26 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         B站共同关注查询
// @namespace    https://github.com/XiaoMiku01
// @version      0.2
// @description  查成分!
// @author       晓轩
// @match        https://*.bilibili.com/*
// @icon         https://www.google.com/s2/favicons?domain=bilibili.com
// @grant        none
// ==/UserScript==
(function () {
    async function readJSON(uid) {
        return new Promise((resolve, reject) => {
            fetch('https://api.bilibili.com/x/relation/same/followings?vmid=' + uid, {
                credentials: 'include'
            }).then(function (data) { resolve(data.json()) })
        })
    }
    var handler = function () {
        setTimeout(async function addP() {
            let a = document.getElementsByClassName("user-card")[0].getElementsByClassName("info");
            let p = document.createElement("p");
            let uid = a[0].getElementsByClassName("user")[0].getElementsByClassName("name")[0].getAttribute("href").split("/").slice(-1);
            let names = '共同关注:</br>';
            try {
                let data = await readJSON(uid);
                for (let i of data.data.list) {
                    names += i.uname + '</br>'
                }
            } catch (error) {
                names = "关注列表未开放";
            }
            p.innerHTML = names;
            a[0].appendChild(p);
        }, 1000);
    }
    var myVar = setInterval(function () { myTimer() }, 1000);
    function myTimer() {
        if (document.getElementsByClassName("user-face").length < 2) {}
        else {
            for (let i of document.querySelectorAll('.user-face, .reply-face')) {
                i.removeEventListener("mouseenter", handler)
                i.addEventListener("mouseenter", handler)
            }
        }
    }
})();