吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2281|回复: 9
收起左侧

[其他原创] 【JS】哔哩哔哩 播放进度条

[复制链接]
梦汐 发表于 2022-11-4 10:55
本帖最后由 梦汐 于 2022-11-4 11:01 编辑

哔哩哔哩的云端播放记录有猫饼,得改本地保存才能正常使用
[JavaScript] 纯文本查看 复制代码
(function videoList() {
    $('.small-item.fakeDanmu-item').each(
        function () {
            setTimeoutW(Progress_Indicators, 10, this, $(this).attr('data-aid'))
        }
    )
}())
function Progress_Indicators(node, id) {
    var json = getInfo(id)
    var progress = Math.trunc(GetPercent(json.response.data.last_play_time / 1000, json.duration))
    //----------------------------------------------------------------------------------------------------
    var progress_ui = document.createElement('div');
    $(progress_ui).attr('class', 'progress').attr('style', 'top: 0px;position: absolute;width: 100%;height: 4px;background-color: #909090;').html(`<div id="content" style="width: ${progress}%;height: 100%;background-color: #f00;"></div>`);
    var node = $(node).find('.cover').append(progress_ui);
    //----------------------------------------------------------------------------------------------------
    function getInfo(bvid) {
        this.httpRequest = new XMLHttpRequest();
        httpRequest.open('GET', `[url=https://api.bilibili.com/x/web-interface/view?bvid=]https://api.bilibili.com/x/web-interface/view?bvid=[/url]${bvid}`, false)//改bvid为avid就是支持avid了
        httpRequest.send(null);
        var json = JSON.parse(httpRequest.responseText);
        this.aid = json.data.aid
        this.cid = json.data.cid
        this.duration = json.data.duration
        //--------------------------------------------------------------------------------------------------------
        httpRequest.abort();
        httpRequest.open('GET', `[url=https://api.bilibili.com/x/player/v2?aid=]https://api.bilibili.com/x/player/v2?aid=[/url]${aid}&cid=${cid}`, false);
        httpRequest.withCredentials = true;//必须附加cookie信息,否则返回的是匿名数据
        httpRequest.send(null);
        var json = JSON.parse(httpRequest.responseText);
        //--------------------------------------------------------------------------------------------------------
        return { response: json, duration: duration }
    }
    function GetPercent(num, total) {
        num = parseFloat(num);
        total = parseFloat(total);
        if (isNaN(num) || isNaN(total)) {
            return 0;
        }
        return total <= 0 ? "0%" : (Math.round(num / total * 10000) / 100.00);
    }
}
function setTimeoutW(func, time, ...parameters) {
    setTimeout(
        (function (func, ...parameters) {
            return function () {
                func(...parameters)
            }
        }(func, ...parameters)
        ), time)
}

免费评分

参与人数 6吾爱币 +12 热心值 +4 收起 理由
guo8zhi + 1 我很赞同!
ToTVoV + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
pinkfloyddddd + 1 + 1 热心回复!
wushaominkk + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
lxhyjr + 1 + 1 谢谢@Thanks!
麦子1995 + 1 + 1 热心回复!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

qk4wq 发表于 2022-11-4 11:05
赞!!!!!
三滑稽甲苯 发表于 2022-11-4 11:22
代码的url格式貌似有点问题,建议禁用链接识别后再保存
czldbc 发表于 2022-11-4 11:24
空白处、 发表于 2022-11-4 11:38
学习了!!!
wan456 发表于 2022-11-4 12:42
有了这和工具,从此b站任我飞
chinalihao 发表于 2022-11-4 13:18
厉害了!!
lsy832 发表于 2022-11-4 16:04
谢谢分享,又学到了
cyan617 发表于 2022-11-5 10:50
感谢楼主,收藏了
jamessteed 发表于 2022-11-5 18:56
感谢楼主分享!
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-1 10:17

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表