gaogaotiantian / biliscope

Bilibili chrome extension to show uploader's stats
MIT License
594 stars 46 forks source link

[bug report]搜索页搜索标签无法显示 #139

Closed ste1hi closed 7 months ago

ste1hi commented 8 months ago

搜索页显示有搜索结果但无法显示

1

经定位发现在searchpage.js文件中

if ([1, 2, 7, 9].includes(d["official"]["role"])) {
                        d["avatarIconClass"] = "bili-avatar-icon-personal";
                    } else if ([3, 4, 5, 6].includes(d["official"]["role"])) {
                        d["avatarIconClass"] = "bili-avatar-icon-business";
                    } else {
                        d["avatarIconClass"] = "";
                    }

该段代码报错,检查发现https://api.vc.bilibili.com/account/v1/user/cards该api的响应内容中没有["official"]这一项。详情

我能想到的解决方法是在请求一下https://api.bilibili.com/x/web-interface/card这个api

 biliGet("https://api.bilibili.com/x/web-interface/card", {"mid": d["mid"]})
                    .then(data0 => {
                        console.log(data0["data"]["card"]["Official"]["role"]);
                        if ([1, 2, 7, 9].includes(data0["data"]["card"]["Official"]["role"])) {
                            d["avatarIconClass"] = "bili-avatar-icon-personal";
                        } else if ([3, 4, 5, 6].includes(data0["data"]["card"]["Official"]["role"])) {
                            d["avatarIconClass"] = "bili-avatar-icon-business";
                        } else {
                            d["avatarIconClass"] = "";
                        }
                        d["title"] = data0["data"]["card"]["Official"]["title"];
                        container.innerHTML += getUserCard(d);
                    })

添加这段代码。但这个解决方案看起来很不优雅。

因为这个只影响up主认证的显示,或者可以干脆就不显示up主认证了。

Flow-sandyu commented 7 months ago

确实我也发现了这个问题,搜索标签不行了

gaogaotiantian commented 7 months ago

肯定不能每个用户都再额外多个request,否则太频繁了。这里应该是B站改API了,只能暂时拿掉了。