B站跳OP OD
作者:互联网
function skip (start_length, end_length) {
if (!start_length || !end_length) {
return console.error('请设置片头和片尾时长')
}
let total_time = player.getDuration();
let skip_point_start = start_length;
let skip_point_end = total_time - end_length;
let has_listener = false;
const interval = 5000;
window.timer = 0;
function start () {
console.log('开搞');
if (timer) {
clearInterval(timer);
}
timer = setInterval(handler, interval)
}
function handler () {
let current_time = player.getCurrentTime();
if (current_time < skip_point_start) {
console.log('跳过片头')
return window.player.seek(start_length);
}
if (current_time >= skip_point_end) {
console.log('跳过片尾,下一集')
if (!has_listener) {
has_listener = true;
window.player.addEventListener('video_media_loaded', start);
}
return window.player.next();
}
}
start();
}
skip(90, 68);
参考:https://github.com/aqiongbei/scripts/tree/master/bilibili_skip
标签:end,start,skip,OD,player,length,let,OP 来源: https://www.cnblogs.com/unixcs/p/16473451.html