Greasy Fork

Greasy Fork is available in English.

哔哩哔哩(bilibili.com)番剧跳过片头

片头开始播放时,按 J 键跳过片头

当前为 2020-03-05 提交的版本,查看 最新版本

// ==UserScript==
// @name         哔哩哔哩(bilibili.com)番剧跳过片头
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  片头开始播放时,按 J 键跳过片头
// @author       zhpjy
// @email        [email protected]
// @match        *://www.bilibili.com/*
// @icon         https://www.bilibili.com/favicon.ico
// @grant        none
// @license     WTFPL
// ==/UserScript==

//片头分为两种情况
//一种是一开头就是片头,按J就可以精确地让进度条前进90秒
//第二种是播放一段后然后才是90秒的片头,按J跳过片头时间长度减去反应时间的差
//第三种片头不是90秒的就没法了哈哈哈

var keyCode = 74; // 键码
var OPTime = 90; //片头长度
var RecTime = 1; //反应时间

//allowed用于防止按键一直按着进度条一直跳的情况
var allowed = true;
window.document.onkeydown=function(event) {
    if (event.repeat != undefined) {
        allowed = !event.repeat;
    }
    if (!allowed){
        return;
    }
    allowed = false;
    if(event.keyCode == keyCode){
        console.log(event.keyCode);
        var video = $('.bilibili-player-video video')[0];
        if(video.currentTime>0){
            video.currentTime += (OPTime-RecTime);
        }else{
            video.currentTime += OPTime;
            video.play();
        }
    }
};