您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
最开始的三个开关autoPlay表示点进视频2秒后自动开始播放,keyboardControl表示点进视频后可用键盘控制视频(空格,↑,↓,←,→),listPlay表示视频结束后跳过5秒等待直接下一part
当前为
// ==UserScript== // @name bilibili 自动播放 // @namespace www.papercomment.tech // @version 0.6 // @description 最开始的三个开关autoPlay表示点进视频2秒后自动开始播放,keyboardControl表示点进视频后可用键盘控制视频(空格,↑,↓,←,→),listPlay表示视频结束后跳过5秒等待直接下一part // @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 // ==/UserScript== (function() { 'use strict'; // Your code here... let autoPlay = true let keyboardControl = true let listPlay = true function playPause(){ //console.warn('UI', 'playPause') let target = document.getElementsByTagName('video')[0] if (target.paused){ target.play() } else{ target.pause() } } let observePlayNow = new MutationObserver((list, obs)=>{ //console.log('UI', list) list.forEach((mutation, index)=>{ 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.log('UI',mutation) mutation.addedNodes[0].querySelector('.bilibili-player-video-toast-item-jump').click() } }) }) let observePlayer = new MutationObserver((list, obs)=>{ //console.warn('NUI', document.getElementById('bilibiliPlayer').querySelector('div.bilibili-player-video-wrap')) document.getElementById('bilibiliPlayer').querySelector('div.bilibili-player-video-wrap').click() obs.disconnect() }) let traceAnchor, bofqiAnchor, tracePlayer, bilibiliPlayerAnchor traceAnchor = setInterval(()=>{ // console.warn('UI', 'tik tok') if(bofqiAnchor = document.getElementById('bofqi')){ clearInterval(traceAnchor) // console.warn('UI', anchor) if(listPlay){ observePlayNow.observe(bofqiAnchor, {childList:true, subtree:true}) } if(autoPlay){ setTimeout(playPause, 2000); } } }, 200) tracePlayer = setInterval(()=>{ if(bilibiliPlayerAnchor = document.getElementById('bilibiliPlayer')){ clearInterval(tracePlayer) if(keyboardControl){ observePlayer.observe(bilibiliPlayerAnchor, {childList: true, subtree: true}) } } }, 200) })();