Greasy Fork is available in English.
bilibili关灯(把被新版B站藏起来的关灯按钮揪出来,在关闭弹幕按钮左边,还可以用快捷键,默认'a')
当前为
// ==UserScript==
// @name bilibili关灯
// @namespace hhh2000
// @version 0.1
// @description bilibili关灯(把被新版B站藏起来的关灯按钮揪出来,在关闭弹幕按钮左边,还可以用快捷键,默认'a')
// @author hhh2000
// @include *://*.bilibili.com/video/*
// @include *://*.bilibili.tv/video/*
// @include *://*.bilibili.com/bangumi/*
// @include *://*.bilibili.tv/bangumi/*
// @require https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js
// @run-at document-end
// @grant none
// ==/UserScript==
function waitForNode(nodeSelector, callback) {
var node = nodeSelector();
if (node) {
callback(node);
} else {
setTimeout(function() { waitForNode(nodeSelector, callback); }, 100);
}
}
function waitForTrue(ifTrue, callback) {
if (ifTrue()) {
callback();
} else {
setTimeout(function() { waitForTrue(ifTrue, callback); }, 10);
}
}
function abc(v){console.log(v);}
var j=0;
function run(){
waitForNode(() => document.querySelector('.bilibili-player-video-danmaku-switch>.bui-switch-label'),
(node) => {
if ($('.bilibili-player-video-danmaku-switch>.bui-switch-label').length !== 1) return;
//abc('1---: '+$('.bilibili-player-video-danmaku-switch>.bui-switch-label').length);
if ($('.bilibili-player-video-danmaku-switch>.bui-switch-label').length === 1) {
}
//插入按钮
$("div.bilibili-player-video-danmaku-switch:first").clone().prependTo("div.bilibili-player-video-danmaku-root:first");
$('span.bui-switch-body>.bui-switch-dot:first>span').remove();
$('span.bui-switch-body>.bui-switch-dot:first')[0].innerHTML = '灯';
abc('3: '+$('span.bui-switch-body>.bui-switch-dot').length);
//abc($('span.bui-switch-body>.bui-switch-dot:first')[0].innerHTML);
//abc('run:'+$('span.bui-switch-body>.bui-switch-dot').length);
//abc($('div.bilibili-player-video-danmaku-root:first')[0]);
//abc($('div.bilibili-player-video-danmaku-switch:first')[0]);
//abc($('div.bilibili-player-video-danmaku-switch:last')[0]);
//点击关灯
$('div.bilibili-player-video-danmaku-switch:first').click(function(){
$('.bilibili-player-video-btn-setting-right-others-content-lightoff>input').click();
});
//键盘关灯
$(document).off('keydown.lightoff');
$(document).on('keydown.lightoff',function(e){
if(e.keyCode === 'A'.charCodeAt()){
$('div.bilibili-player-video-danmaku-switch:first>input').click();
}
});
//激活系统关灯class
$('.bilibili-player-video-btn.bilibili-player-video-btn-setting').mouseover();
//解决因为激活关灯class,导致全屏时滚轮无法调节音量的问题
waitForTrue(()=>$('.bilibili-player-video-btn-setting-wrap').css('display') === 'block',
() => {
$('.bilibili-player-video-btn-setting-wrap').css('display', 'none');
});
//abc('2---: '+$('.bilibili-player-video-danmaku-switch>.bui-switch-label').length);
});
}
function init() {
waitForNode(() => document.querySelector('span.bui-switch-body>.bui-switch-dot'),
(node) => {
//if($('span.bui-switch-body>.bui-switch-dot').length >= 0) abc($('span.bui-switch-body>.bui-switch-dot:first')[0].innerHTML);
//abc($('span.bui-switch-body>.bui-switch-dot').length);
//if($('span.bui-switch-body>.bui-switch-dot').length) return;
//if ($('span.bui-switch-body>.bui-switch-dot').length === 1) {
//插入按钮
//$("div.bilibili-player-video-danmaku-switch:first").clone().prependTo("div.bilibili-player-video-danmaku-root:first");
//$('span.bui-switch-body>.bui-switch-dot:first>span').remove();
//$('span.bui-switch-body>.bui-switch-dot:first')[0].innerHTML = '灯';
//abc($('span.bui-switch-body>.bui-switch-dot:first')[0].innerHTML);
//}
//abc('run:'+$('span.bui-switch-body>.bui-switch-dot').length);
//abc($('div.bilibili-player-video-danmaku-root:first')[0]);
//abc($('div.bilibili-player-video-danmaku-switch:first')[0]);
//abc($('div.bilibili-player-video-danmaku-switch:last')[0]);
//点击关灯
// $('div.bilibili-player-video-danmaku-switch:first').click(function(){
// $('.bilibili-player-video-btn-setting-right-others-content-lightoff>input').click();
//});
//键盘关灯
/*$(document).on('keydown',function(e){
if(e.keyCode === 'A'.charCodeAt()){
$('div.bilibili-player-video-danmaku-switch:first>input').click();
}
});*/
//激活系统关灯class
//$('.bilibili-player-video-btn.bilibili-player-video-btn-setting').mouseover();
});
//解决因为激活关灯class,导致全屏时滚轮无法调节音量的问题
//waitForTrue(()=>$('.bilibili-player-video-btn-setting-wrap').css('display') === 'block',
// () => {
// $('.bilibili-player-video-btn-setting-wrap').css('display', 'none');
//});
//
waitForNode(() => document.querySelector('video'),
(node) => {
var oV = document.getElementsByTagName("video")[0];
oV.addEventListener('DOMNodeInserted', () => {
run();
//if($('span.bui-switch-body>.bui-switch-dot').length >= 0) {(run())}
//abc(oV);
//abc($('span.bui-switch-body>.bui-switch-dot').length);
//cacheFlag = false;
});
});
run();
}
window.onload = init();