Warning: fopen(/www/sites/update.greasyfork.icu/index/store/forever/83eeddea9305f37e59610e39b673293a.js): failed to open stream: No space left on device in /www/sites/update.greasyfork.icu/index/scriptControl.php on line 65
// ==UserScript==
// @name bilibili 自动播放
// @namespace www.papercomment.tech
// @version 1.0
// @description 共有4个功能。自动播放,键盘控制,跳过5秒,滚动居中。可由开头的4个变量控制功能的开关
// autoPlay 表示点进视频1秒后自动开始播放,
// keyboardControl 表示点进视频后可用键盘控制视频(空格,↑,↓,←,→),
// listPlay 表示视频结束后跳过5秒等待直接下一part,
// center 表示自动滚动到播放器居中显示
// @author c4r
// @match https://www.bilibili.com/bangumi/*
// @match https://www.bilibili.com/video/*
// @match https://www.bilibili.com/watchlater/*
// @grant none
// @license MPL-2.0
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
// 这是4个开关
let autoPlay = true
let keyboardControl = true
let listPlay = true
let center = true
////////////////-以下是神秘代码-///////////////////
let timerVideo
let previousURL = ''
let videoAnchor
function play(target){
//console.warn('Play', target.readyState)
if(target.readyState > 2){
setTimeout(()=>{target.play()}, 1000)
}
target.addEventListener('canplay', function() {
//console.warn('canplay')
setTimeout(()=>{target.play()}, 1000)
})
}
let observePlayNow = new MutationObserver((list, obs)=>{
//console.warn('c4r', list)
for(let mutation of list){
if(mutation.target.matches('div.bilibili-player-video-toast-bottom')&&
mutation.addedNodes.length!==0&&
mutation.addedNodes[0].querySelector('.bilibili-player-video-toast-item-jump').textContent=='立即播放'){
//console.warn('c4r', '点击“立即播放”')
mutation.addedNodes[0].querySelector('.bilibili-player-video-toast-item-jump').click()
break
}
}
})
let observeHead = new MutationObserver((list, obs)=>{
if(previousURL != window.location.href){
//console.warn('walker: URL has changed', 'from: ' + previousURL + ' to: ' + window.location.href)
previousURL = window.location.href
clearInterval(timerVideo)//防止ajax跳转遗留timer
timerVideo = setInterval(()=>{
if(videoAnchor = document.getElementsByTagName('video')[0]){
//console.warn('got