// ==UserScript==
// @name 哔哩哔哩直播自动原画
// @version 1.0
// @license MIT
// @author joe
// @icon https://www.bilibili.com/favicon.ico
// @match *://live.bilibili.com/*
// ==/UserScript==
(function () {
'use strict';
// 创建一个鼠标移动事件
var event = new MouseEvent('mousemove', {
'view': unsafeWindow,
'bubbles': true,
'cancelable': true
});
// 创建一个鼠标进入事件
var mouseenterEvent = new MouseEvent('mouseenter', {
'view': unsafeWindow,
'bubbles': true,
'cancelable': true
});
// 创建一个鼠标移出事件
var mouseleaveEvent = new MouseEvent('mouseleave', {
'view': unsafeWindow,
'bubbles': true,
'cancelable': true
});
// 等待 "live-player" 元素加载完成
var checkPlayerExist = setInterval(function() {
var player = document.getElementById('live-player');
if (player !== null) {
clearInterval(checkPlayerExist);
// 视频 触发鼠标移动事件
player.dispatchEvent(event);
// 网页全屏
var webpageMode = document.querySelector('#web-player-controller-wrap-el > div > div > div.right-area.svelte-4rgwwa > div:nth-child(2)');
if (webpageMode !== null) {
// 触发鼠标移动事件
webpageMode.dispatchEvent(mouseenterEvent);
setTimeout(function() {
var qualityOption = Array.from(document.querySelectorAll('.list-it.svelte-s2ukfj')).find(el => el.textContent.trim() === '原画');
if (qualityOption !== undefined) {
var webpageModeIcon = document.querySelector('#web-player-controller-wrap-el > div > div > div.right-area.svelte-4rgwwa > div:nth-child(2) > div:nth-child(2) > span');
if (webpageModeIcon !== null) {
webpageModeIcon.click();
}
// webpageMode.dispatchEvent(mouseleaveEvent);
}
}, 500); // 等待 500 毫秒
}
player.dispatchEvent(event);
// 立即检查 "quality-wrap" 元素是否出现, 选择 ‘原画’
var qualityWrap = document.querySelector('.quality-wrap.svelte-s2ukfj');
if (qualityWrap !== null) {
// 触发鼠标移动事件
qualityWrap.dispatchEvent(mouseenterEvent);
setTimeout(function() {
var qualityOption = Array.from(document.querySelectorAll('.list-it.svelte-s2ukfj')).find(el => el.textContent.trim() === '原画');
if (qualityOption !== undefined) {
// 触发点击事件
qualityOption.click();
qualityWrap.dispatchEvent(mouseleaveEvent);
}
}, 500); // 等待 500 毫秒
}
}
}, 1000); // 每秒检查一次
})();