Greasy Fork is available in English.

Bilibili直播间助手

提供同传弹幕过滤,快速切换牌子,自动切换直播清晰度等功能

< Обсуждения Bilibili直播间助手

Вопрос/комментарий

§
Создано: 10.05.2022
Отредактировано: 10.05.2022

第810行左右,medalInfo.medal_id !== this.medalConfig.wore,是否该为medalInfo.medal_name !== this.medalConfig.wore?貌似即使带的牌子是当前直播间的,依然会走进if发送佩戴请求

这样,去掉else?

if (medalInfo && medalInfo.medal_name !== this.medalConfig.wore) {
    this.wear(medalInfo.medal_id).catch(e => {
        setTimeout(() => {
            if (this.medalConfig.autoWear.remember !== 0) {
                this.wear(this.medalConfig.autoWear.remember).catch(e => { });
            } else {
                this.takeOff();
            }
        }, 1500);
    });
}

只赋值一次medalConfig

autoWear() {
    this.getWore().then(res => {
        return res.length == 0 ? ("", "c0c0c0") : (res.medal_name, res.medal_color_start.toString(16));
    }).then((wore, color) => {
        if (window.__NEPTUNE_IS_MY_WAIFU__ && this.medalConfig.autoWear.enable) {
            let medalInfo = window.__NEPTUNE_IS_MY_WAIFU__.roomInfoRes.data.anchor_info.medal_info;
            if (medalInfo && medalInfo.medal_name !== wore) {
                this.wear(medalInfo.medal_id).catch(e => {
                    setTimeout(() => {
                        if (this.medalConfig.autoWear.remember !== 0) {
                            this.wear(this.medalConfig.autoWear.remember).catch(e => { });
                        } else {
                            this.takeOff();
                        }
                    }, 1500);
                });
                return;
            }
        }
        this.medalConfig.wore = wore;
        this.medalConfig.color = color;
    })
},

只赋值一次medalConfig

autoWear() {
    this.getWore().then(res => {
        return res.length == 0 ? ("", "c0c0c0") : (res.medal_name, res.medal_color_start.toString(16));
    }).then((wore, color) => {
        if (window.__NEPTUNE_IS_MY_WAIFU__ && this.medalConfig.autoWear.enable) {
            let medalInfo = window.__NEPTUNE_IS_MY_WAIFU__.roomInfoRes.data.anchor_info.medal_info;
            if (medalInfo && medalInfo.medal_name !== wore) {
                this.wear(medalInfo.medal_id).catch(e => {
                    setTimeout(() => {
                        if (this.medalConfig.autoWear.remember !== 0) {
                            this.wear(this.medalConfig.autoWear.remember).catch(e => { });
                        } else {
                            this.takeOff();
                        }
                    }, 1500);
                });
                return;
            }
        }
        this.medalConfig.wore = wore;
        this.medalConfig.color = color;
    })
},

javascript苦手……写错了两行。

autoWear() {
    this.getWore().then(res => {
        return res.length == 0 ? ["", "c0c0c0"] : [res.medal_name, res.medal_color_start.toString(16)];
    }).then(([wore, color]) => {
        if (window.__NEPTUNE_IS_MY_WAIFU__ && this.medalConfig.autoWear.enable) {
            let medalInfo = window.__NEPTUNE_IS_MY_WAIFU__.roomInfoRes.data.anchor_info.medal_info;
            if (medalInfo && medalInfo.medal_name !== wore) {
                this.wear(medalInfo.medal_id).catch(e => {
                    setTimeout(() => {
                        if (this.medalConfig.autoWear.remember !== 0) {
                            this.wear(this.medalConfig.autoWear.remember).catch(e => { });
                        } else {
                            this.takeOff();
                        }
                    }, 1500);
                });
                return;
            }
        }
        this.medalConfig.wore = wore;
        this.medalConfig.color = color;
    })
},

Ответить

Войдите, чтобы ответить.