删除b站已出奖的官方抽奖动态,保留非官抽动态

删除b站已出奖的官方抽奖动态&多余的重复官抽&保留所有非官抽和互动动态

< Feedback on 删除b站已出奖的官方抽奖动态,保留非官抽动态

Review: OK - script works, but has bugs

§
Posted: 2023-08-15
Edited: 2023-08-15

原代码中 77、78行获取iframe中跨域报错,所以脚本执行失败了。 给个临时解决办法,用以下代码替换,通过直接访问api获取开奖时间然后删除

var judge = false;
var count = false;

var bussinessId = document.getElementsByClassName('bili-dyn-list__items')[0].getElementsByClassName('bili-dyn-list__item')[i].getElementsByClassName('bili-album')[0].getAttribute('dyn-id');
console.log('bussinessId=' + bussinessId);

const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://api.vc.bilibili.com/lottery_svr/v1/lottery_svr/lottery_notice?business_type=4&business_id=' + bussinessId, false);
xhr.onreadystatechange = function() {
    if (xhr.readyState === XMLHttpRequest.DONE) {
        if (xhr.status === 200) {
            // 请求成功
            var obj = JSON.parse(xhr.responseText);

            //获取lottery_time属性的值,即抽奖时间的Unix时间戳
            var lottery_time = obj.data.lottery_time;

            //将Unix时间戳转换为Date对象
            var lottery_date = new Date(lottery_time * 1000);

            //获取当前时间的Date对象
            var current_date = new Date();

            //比较两个Date对象,如果抽奖时间小于当前时间,返回true,否则返回false
            judge = lottery_date <= current_date;

            //打印结果
            console.log(judge);

        } else {
            // 请求失败
            console.log('请求失败');
        }
    }
};
xhr.send();

§
Posted: 2023-08-28

用这一大段替换掉原本的77和78行对吗?

Post reply

Sign in to post a reply.