🏠 返回首頁 

B站(bilibili)自动续播因未登录而暂停的视频 (Bilibili: Continue playing without logging-in)

解决B站(bilibili)因未登录而自动暂停视频并弹出登录窗口的问题,需要配合ublock origin屏蔽弹窗 / Solve the problem of Bilibili automatically pausing video and popping up a login window because it is not logged in, need ublock origin rules to block popup window

< Feedback on B站(bilibili)自动续播因未登录而暂停的视频 (Bilibili: Continue playing without logging-in)

Question/comment

(function () {
'use strict';

// Function to monitor changes in the specified element
function monitorPlayerState() {
const targetNode = document.querySelector('.bpx-player-container');
if (!targetNode) return;

const config = { attributes: true, attributeFilter: ['class'] };

const callback = function (mutationsList) {
for (let mutation of mutationsList) {
if (
mutation.type === 'attributes' &&
mutation.target.classList.contains('bpx-state-paused') &&
mutation.target.classList.contains('bpx-state-no-cursor')
) {
// Click the play button
const playButton = document.querySelector(
'.bpx-player-ctrl-btn.bpx-player-ctrl-play'
);
if (playButton) {
playButton.click();
console.log('Video r###med automatically.');
}
}
}
};

const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
}

// Wait for the page to load completely before initializing the script
window.addEventListener('load', function () {
monitorPlayerState();
});
})();

脚本代码失效了,根据原理修改了下,目前鼠标暂停且鼠标不消失情况下可以暂停,否则无论是被暂停还是主动暂停都会被取消

增加了空格监控后不知道为何没奏效,作者可以改进一下
另外网络中监控到一个
api.bilibili.com/x/click-interface/* 的请求,过几秒会上报
类似
https://api.bilibili.com/x/click-interface/web/heartbeat?w_start_ts=1733434114&w_aid=113242215023792&w_dt=2&w_realtime=217&w_played_time=228&w_real_played_time=225&w_video_duration=1064&w_last_play_progress_time=228&web_location=1315873&w_rid=1e0cb1c05cd04d65425d2d4ea7086f0a&wts=1733434357
这种心跳函数,如图,其会记录视频播放后真实时间中60和60的倍数秒时状态,感觉这个函数和暂停有关,但是我拦截阻止后仍然无法阻止视频暂停

Post reply

Sign in to post a reply.