// ==UserScript== // @name bilibili关灯及快捷操作 // @namespace hhh2000 // @version 0.9.5.5 // @description bilibili关灯及快捷操作(把被新版B站藏起来的关灯按钮揪出来,在关闭弹幕按钮左边,还可以用快捷键,默认'A')、非全屏滚轮音量控制、弹幕控制快捷操作等 // @author hhh2000 // @include http*://www.bilibili.com/video/av* // @include http*://www.bilibili.com/video/BV* // @include http*://www.bilibili.com/watchlater/* // @include http*://www.bilibili.com/medialist/play/* // @include http*://www.bilibili.com/bangumi/play/ep* // @include http*://www.bilibili.com/bangumi/play/ss* // @include http*://bangumi.bilibili.com/anime/*/play* // @include http*://bangumi.bilibili.com/movie/* // @include http*://www.bilibili.com/blackboard/* //// @include http*://t.bilibili.com/* // @require https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js /* globals jQuery, $, waitForkeyElements */ /* eslint-disable no-multi-spaces, dot-notation */ // @run-at document-end // @grant GM_setValue // @grant GM_getValue // @grant GM_listValues // @grant none // @downloadURL none // ==/UserScript== 'use strict'; var hhh_lightoff_main = { init() { var // ver, fps, h5Player, //bili_player, is_in_biliplayer, is_show_hint, $tip, frame_time; const [BILI_2_X, BILI_3_X, ALL] = ['bili_2.x', 'bili_3.x', 'all']; var //切换番剧和一般视频class bb = {}, bb_type = '', bb_config = { bb_class_data: { //其实这样不方便调试 //'player':{BILI_2_X:'.player', [BILI_3_X]:'.bpx-player'}, //main //$('meta[property="og:image"]').attr('content') 'coverImg':{[ALL]:'meta[property="og:image"]'}, //封面 'playTipWrap':{[BILI_2_X] :'.bilibili-player-dm-tip-wrap', [BILI_3_X]:'.bpx-player-video-perch'}, //paly/pause 'fullScreen':{[BILI_2_X] :'.bilibili-player-video-btn-fullscreen', [BILI_3_X]:'.squirtle-video-fullscreen.squirtle-video-item'}, //全屏 'webFullScreen':{[BILI_2_X]:'.bilibili-player-video-web-fullscreen', [BILI_3_X]:'.squirtle-video-pagefullscreen.squirtle-video-item'}, //网页全屏 'wideScreen':{[BILI_2_X] :'.bilibili-player-video-btn-widescreen', [BILI_3_X]:'.squirtle-video-widescreen.squirtle-video-item'}, //宽屏 //一健三联 'like' :{[BILI_2_X]:'.ops .like' , [BILI_3_X]:'.like-info'}, //点赞 'likeon' :{[BILI_2_X]:'.ops .like.on', [BILI_3_X]:'.like-info.active'}, //已点赞 'coin' :{[BILI_2_X]:'.ops .coin' , [BILI_3_X]:'.coin-info'}, //硬币 'collect':{[BILI_2_X]:'.ops .collect', [BILI_3_X]:''}, //收藏 //弹幕 'danmukuTopClose':{[BILI_2_X]:'.bilibili-player-block-filter-type[data-name=ctlbar_danmuku_top_close]', [BILI_3_X]:'.bpx-player-block-filter-type.bpx-player-block-typeTop.bpx-player-active'}, //顶部弹幕 'danmukuTop' :{[BILI_2_X]:'.bilibili-player-block-filter-type[ftype=top]', [BILI_3_X]:'.bpx-player-block-filter-type.bpx-player-block-typeTop'}, //顶部弹幕 'danmukuBottomClose':{[BILI_2_X]:'.bilibili-player-block-filter-type[data-name=ctlbar_danmuku_bottom_close]', [BILI_3_X]:'.bpx-player-block-filter-type.bpx-player-block-typeBottom.bpx-player-active'}, //底部弹幕 'danmukuBottom' :{[BILI_2_X]:'.bilibili-player-block-filter-type[ftype=bottom]', [BILI_3_X]:'.bpx-player-block-filter-type.bpx-player-block-typeBottom'}, //底部弹幕 'progressVal' :{[ALL]:'.bui-progress-val'}, //弹幕透明度读数 'progressWrap' :{[ALL]:'.bui-progress-wrap'}, //弹幕透明度进度条 'settingOpacity':{[BILI_2_X]:'.bilibili-player-setting-opacity', [BILI_3_X]:'.bpx-player-dm-setting-ui-opacity'}, //弹幕透明度 'settingArea' :{[BILI_2_X]:'.bilibili-player-setting-area', [BILI_3_X]:'.bpx-player-dm-setting-ui-area'}, //显示区域 'settingFs' :{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-left-fs input', [BILI_3_X]:'.bpx-player-dm-setting-left-fs input'}, //弹幕随屏幕缩放 //音量 'volumeHint' :{[BILI_2_X]:'.bilibili-player-volumeHint', [BILI_3_X]:'.bpx-player-volume-hint'}, //音量显示 'volumeHintText':{[BILI_2_X]:'.bilibili-player-volumeHint-text', [BILI_3_X]:'.bpx-player-volume-hint-text'}, //音量显示百分比读数 'volumeHintIcon':{[BILI_2_X]:'.bilibili-player-volumeHint-icon', [BILI_3_X]:'.bpx-player-volume-hint-icon'}, //音量显示图标 'volumebarWrp' :{[BILI_2_X]:'.bilibili-player-video-volumebar-wrp', [BILI_3_X]:'.squirtle-volume-bar-wrap'}, //音量条 'volumeNum' :{[BILI_2_X]:'.bilibili-player-video-volume-num', [BILI_3_X]:'.squirtle-volume-num'}, //音量读数 //视频速度 'videoSpeedActive':{[BILI_2_X]:'.bilibili-player-video-btn-speed-menu-list.bilibili-player-active', [BILI_3_X]:'.squirtle-speed-select-list .squirtle-select-item.active'}, //视频速度 'videoSpeed':{[BILI_2_X]:'.bilibili-player-video-btn-speed-menu-list', [BILI_3_X]:'.squirtle-speed-select-list .squirtle-select-item'}, //视频速度 'videoSpeedName':{[BILI_2_X]:'.bilibili-player-video-btn-speed-name', [BILI_3_X]:'.squirtle-select-result.squirtle-speed-select-result'}, //视频速度 //弹幕设置等 'switchBody':{[ALL]:'.bui-switch-body'}, //系统关灯css设置 'switchDot':{[ALL]:'.bui-switch-dot'}, //系统弹幕设置按钮wrap进度条拖动点 'switchInput':{[ALL]:'.bui-switch-input'}, //弹幕设置switch按钮 'danmaku':{[BILI_2_X]:'.bilibili-player-video-danmaku'}, //弹幕 'danmakuRoot':{[BILI_2_X]:'.bilibili-player-video-danmaku-root', [BILI_3_X]:'.bpx-player-dm-root'}, //系统弹幕设置条 'danmakuSwitch':{[BILI_2_X]:'.bilibili-player-video-danmaku-switch', [BILI_3_X]:'.bpx-player-dm-switch'}, //关闭弹幕按钮 'dm':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting', [BILI_3_X]:'.bpx-player-dm-setting'}, //系统弹幕设置按钮 'dmWrap':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-wrap', [BILI_3_X]:'.bpx-player-dm-setting-wrap'}, //系统弹幕设置wrap 'dmBox':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-box', [BILI_3_X]:'.bpx-player-dm-setting-box'}, //系统弹幕设置box 'dmLeft':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-left', [BILI_3_X]:'.bpx-player-dm-setting-left'}, 'dmLeftMore':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-left-more', [BILI_3_X]:'.bpx-player-dm-setting-left-more'}, 'dmLeftMoreText':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-left-more-text', [BILI_3_X]:'.bpx-player-dm-setting-left-more-text'}, 'dmLeftBlock':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-left-block', [BILI_3_X]:'.bpx-player-dm-setting-left-block'}, 'dmLeftBlockTitle':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-left-block-title', [BILI_3_X]:'.bpx-player-dm-setting-left-block-title'}, 'dmRightMore':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-right-more', [BILI_3_X]:'.bpx-player-dm-setting-right-more'}, 'dmRightMoreText':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-right-more-text', [BILI_3_X]:'.bpx-player-dm-setting-right-more-text'}, 'dmRightSeparator':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-right-separator', [BILI_3_X]:'.bpx-player-dm-setting-right-separator'}, 'dmRightDensity':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-right-density', [BILI_3_X]:'.bpx-player-dm-setting-right-density'}, 'dmRightReset':{[BILI_2_X]:'.bilibili-player-video-danmaku-setting-right-reset', [BILI_3_X]:'.bpx-player-dm-setting-right-reset'}, 'videoWrap':{[BILI_2_X]:'.bilibili-player-video-wrap', [BILI_3_X]:'.bpx-player-video-area'}, //播放wrap 'videoContextMenu':{[BILI_2_X]:'.bilibili-player-video-wrap', [BILI_3_X]:'.bpx-player-video-perch'}, //播放contextmenu 'video':{[BILI_2_X]:'.bilibili-player-video', [BILI_3_X]:'.bpx-player-video-wrap'}, //播放 'videoTopMask':{[BILI_2_X]:'.bilibili-player-video-top-mask', [BILI_3_X]:'.bpx-player-top-mask'}, //全屏时鼠标悬停时产生的顶端mask //系统设置等 'playArea':{[ALL]:'.bilibili-player-area'}, //哔哩哔哩播放器 'playVideo':{[BILI_2_X]:'.bilibili-player-video-btn'}, //系统设置 'playVideoControlWrap':{[BILI_2_X]:'.bilibili-player-video-control-wrap'}, //系统控制面板 'playSetting':{[BILI_2_X]:'.bilibili-player-video-btn-setting'}, //系统播放设置 'playSettingWrap':{[BILI_2_X]:'.bilibili-player-video-btn-setting-wrap'}, //系统播放设置wrap 'playSettingAutoplay':{[BILI_2_X]:'.bilibili-player-video-btn-setting-left-autoplay input', [BILI_3_X]: '.squirtle-setting-autoplay'}, //自动播放 'playSettingRepeatInput':{[BILI_2_X]:'.bilibili-player-video-btn-setting-left-repeat input', [BILI_3_X]:'.squirtle-setting-loop'}, //洗脑循环按钮 'playSettingLightoff':{[BILI_2_X]:'.bilibili-player-video-btn-setting-right-others-content-lightoff input', [BILI_3_X]:'.squirtle-single-setting-other-choice.squirtle-lightoff'}, //关灯按钮 'bpxStateLightOff':{[BILI_3_X]:'.bpx-state-light-off'}, //关灯bpx 'playJumpElectric':{[BILI_2_X]:'.bilibili-player-electric-panel-jump'}, //2.69.4版本B站取消充电鸣谢,2.72又加回来了 //右键菜单 'playerContextMenu':{[BILI_2_X]:'.bilibili-player-context-menu-container.black.bilibili-player-context-menu-origin', [BILI_3_X]:'.bpx-player-contextmenu.bpx-player-black'}, //右键菜单 'hotkeyPanel':{[BILI_2_X]:'.bilibili-player-hotkey-panel', [BILI_3_X]:'.bpx-player-hotkey-area'}, //快捷键说明面板 'hotkeyPanelClose':{[BILI_2_X]:'.bilibili-player-hotkey-panel-close', [BILI_3_X]:'.bpx-player-hotkey-close'}, //快捷键说明面板关闭按钮 'videoInfo':{[BILI_2_X]:'.bilibili-player-video-info', [BILI_3_X]:'.bpx-player-info'}, //视频统计信息 'videoInfoClose':{[BILI_2_X]:'.bilibili-player-video-info-close', [BILI_3_X]:'.bpx-player-info-close'}, //视频统计信息关闭按钮 'videoInfoContainer':{[BILI_2_X]:'.bilibili-player-video-info-container', [BILI_3_X]:'.bpx-player-info-container'}, //视频统计信息 'videoInfoShow':{[BILI_2_X]:'.bilibili-player-video-info-container active', [BILI_3_X]:'.bpx-player-info-container'}, //视频统计信息面板显示 'DOMNodeInsertedVideoInfoShow':{[BILI_2_X]:'.bilibili-player-video-info-container active', [BILI_3_X]:'.info-line'}, // }, set_bb(_bb_type) { bb_type = _bb_type; for(var k in this.bb_class_data){ var class_str = this.bb_class_data[k][bb_type] || this.bb_class_data[k][[ALL]]; bb[k] = class_str; } } }; const [ON, OFF] = [true, false]; var //config keycode = { 'left': 37, 'right': 39, 'up': 38, 'down': 40, 'space': 32, 'enter': 13, '/': 191, }, config = { //一些主要开关设置 sets: {}, getCheckboxSettingStatus(key) { return this.sets[key]['status']; }, getCheckboxSettingFn(key) { return this.sets[key]['fn']; }, getCheckboxSettingArgs(key) { return this.sets[key]['args']; }, setCheckboxSettingStatus(key, status) { this.sets[key]['status'] = status; }, setCheckboxSettingTips(key, tips) { this.sets[key]['tips'] = tips; }, saveCheckboxSetting() { for(var o in this){ if(o.indexOf('b_') === 0){ this.sets = JSON.parse(JSON.stringify(this[o]['options'])); } } }, b_playerCheckbox: { options: { autoPlay: { text: '自动播放', status: OFF, tips: '' }, lightOff: { text: '自动关灯', status: OFF, tips: '' }, autoFullScreen: { text: '自动全屏', status: OFF, tips: '' }, autoWebFullScreen: { text: '自动网页全屏', status: OFF, tips: '' }, videoRepeat: { text: '自动洗脑循环', status: OFF, tips: '' }, lightOffWhenPlaying: { text: '播放时自动关灯', status: OFF, fn: 'lightOffWhenPlaying' }, lightOnWhenPause: { text: '暂停时自动开灯', status: OFF, fn: 'lightOnWhenPause' }, rememberVideoRepeat: { text: '记忆洗脑循环', status: ON, tips: '优先级低于【自动洗脑循环】', show: OFF }, //优先级低于videoRepeat dblclickFullScreen: { text: '双击或中键全屏', status: ON, tips: '', fn: 'dblclickFullScreen' }, volumeControlWhenNonFullScreen: { text: '非全屏滚轮音量调节', status: ON, tips: '', fn: 'wheel_volumeHint', args:{screenLeft: 0.3, screenRight: 0.7, delta: 1} }, volumeControlWhenPause: { text: '非全屏暂停时滚轮音量调节', status: ON, tips: '' }, danmuOpacityControl: { text: '滚轮弹幕透明度控制', status: ON, tips: 'Ctrl + 滚轮', fn: 'wheel_opacity', args:{delta: 5} }, //ctrl+滚轮 keyVideoSpeed: { text: '键盘调节视频速度', status: ON, tips: 'Ctrl + ↑↓' }, removeVideoTopMask: { text: '去掉顶部mask', status: ON, tips: '', fn: 'removeVideoTopMask' }, jumpElectric: { text: '跳过充电鸣谢', status: ON, fn: 'jumpElectric' }, //2.69.4版本B站取消充电鸣谢,2.72又加回来了 reloadDanmuku: { text: '快进快退恢复重载弹幕效果', status: ON }, //快进快退恢复重载弹幕效果 //removeMostViewedListener: { text: '删除动态首页UP主动态提示', status: ON }, //不显示有明显变化的提示,关灯、关弹幕等,因为对有些人来说这些操作变化明显可见,提示反而多余且遮挡屏幕 hotKeyHint: { text: '快捷键屏幕提示', status: OFF, tips: '不显示有明显变化的提示,关灯、关弹幕等' }, openHotKey: { text: '开启自定义快捷键', status: ON, tips: '', 'fn': 'set_hotkey' }, }, btn: '设置' }, //快捷键 QDs: {}, //未使用 getQD(key) { return this.QDs[key]; }, //未使用 saveQD() { for (let [key, { value, text }] of Object.entries(this.hotKeyMenu)) { this.QDs[key] = {value: value, keyCode: value.charCodeAt(), text: text}; } }, //未使用 hotKeyMenu: { //只是右键菜单的数据,如需改动快捷键改run函数 'volumeControl': { value: '滚轮', text: '音量调节', }, 'lightOff': { value: 'A', text: '关灯/开灯', }, 'webFullscreen': { value: 'W', text: '网页全屏', }, 'widescreen': { value: 'Q', text: '宽屏模式', }, 'danmu': { value: 'D', text: '弹幕/关闭弹幕', }, 'danmuTopBottom': { value: 'T/B', text: '顶部/底部弹幕', }, 'videoRepeat': { value: 'R', text: '洗脑循环', }, 'addsubDanmuOpacity': { value: 'Z/C', text: '减增弹幕透明度10%', }, 'danmuArea': { value: '1、2、3、4、5', text: '弹幕显示区域 1/4屏~不限', }, // 'quarterArea': { value: '1', text: '1/4屏', }, // 'halfArea': { value: '2', text: '半屏', }, // 'threeQuarterArea': { value: '3', text: '3/4屏', }, // 'nonOverArea': { value: '4', text: '不重叠', }, // 'fullArea': { value: '5', text: '不限', }, 'wheelDanmuOpacity': { value: 'Ctrl + 滚轮', text: '增减弹幕透明度5%', }, 'fastForwardBackward30s': { value: 'Ctrl + ←/→', text: '快进/快退30s', }, '1/FPS': { value: 'Shift + ←/→', text: '逐帧操作', }, 'keyVideoSpeed': { value: 'Ctrl + ↑/↓', text: '调节视频播放速度', }, 'dblclickFullScreen': { value: '双击/中键/功能键', text: '双击或功能键全屏', }, 'ctrl_enterFullScreen': { value: 'Ctrl+Enter', text: '全屏', }, 'danmuZoomWithScreen': { value: 'S', text: '弹幕是否随屏幕缩放', }, 'like': { value: 'Y、U、I、O', text: '点赞、投币、收藏、长按一键三连', }, }, }; const assert = function(condition, message) { if (!condition) throw Error('Assert failed: ' + (message || 'Assertion failed')); } function log(e) {console.log(e)} function dir(e) {console.dir(e)} function set_value(key, value){ localStorage.setItem(key, value) } function get_value(key, default_value){ return localStorage.getItem(key) || default_value } function waitForNode(nodeSelector, callback, times) { if(times < 0) return; var node = nodeSelector(); if (node) { callback(node); } else { times-=1; setTimeout(function() { waitForNode(nodeSelector, callback, times); }, 50); } } function waitForTrue(ifTrue, callback) { if (ifTrue()) { callback(); } else { setTimeout(function() { waitForTrue(ifTrue, callback); }, 50); } } function is_fullscreen() { //if(bb_type === BILI_2_X){ return bili_player.isFullScreen() } if(bb_type === BILI_2_X){ return $('#bilibiliPlayer').hasClass('mode-webfullscreen') || $('#bilibiliPlayer').hasClass('mode-fullscreen') } else if(bb_type === BILI_3_X){ return $('.bpx-player-container').attr('data-screen') === 'web' || $('.bpx-player-container').attr('data-screen') === 'full' } //normal wide web full } function fullscreen() { $(bb['fullScreen']).click() } function web_fullscreen() { $(bb['webFullScreen']).click() } function wide_screen() { $(bb['wideScreen']).click() } function is_lightoff() { //if (bb_type === BILI_2_X) { return !bili_player.getPlayerState().lightOn } if (bb_type === BILI_2_X) { return $('#bilibiliPlayer').hasClass('mode-light-off') } else if(bb_type === BILI_3_X) { return $(bb['playSettingLightoff']).hasClass('active') } } function is_danmaku_show(){ return $(bb['danmakuSwitch']+' '+bb['switchInput']+':last')[0].checked; } function lightoff() { $(bb['playSettingLightoff']).click() } function add_tip($tip, $node, args){ $node.mouseover(function(){ var e = this; var op = {}; let t = setTimeout(function() { $tip.appendTo(e); let $this = $(e); let $new_tip = $('.player-tooltips.tip.top-center.animation').css({top:0,left:0}); true === !!$this.data('tip') ? $.extend(true, op, $this.data('tip')) : $.extend(true, op, args); $new_tip.find('.tooltip').text(op['text']); let tip_new_top = $this.offset().top - $new_tip.offset().top - $new_tip.height(); //console.log('top:'+$this.offset().top+' tiptop: '+$new_tip.offset().top +' height: '+ $new_tip.height()); //console.log('left:'+$this.offset().left+' tipleft: '+$new_tip.offset().left +' width: '+ $this.width()+' tipwidth: '+ $new_tip.width()); //console.log('top:'+$this.css('top')+'left:'+$this.css('left')) let tip_new_left = $this.offset().left - $new_tip.offset().left + ($this.width() - $new_tip.width())/2; //console.log(tip_new_top+' '+tip_new_left); tip_new_left = tip_new_left <= 0 ? 0 : tip_new_left; let diff_full_top = is_fullscreen() ? (op['diff_full_top'] || 0) : 0; //全屏时位置不同 $new_tip.css({'top':tip_new_top + op['top'] + diff_full_top, 'left':tip_new_left + op['left']}).addClass('active'); }, op['millisec']); $(this).data('timeout', t); }). mouseout(function(e){ clearTimeout($(this).data('timeout')); $('.player-tooltips.tip.top-center.animation').removeClass('active'); $('.player-tooltips.tip.top-center.animation').remove(); }) } //关灯按钮样式 function lightoff_btn_css() { var body_brgb = 'rgb(160, 130, 110)'; var dot_crgb = 'rgb(230, 200, 180)'; var dot_brgb = 'rgb(50, 50, 50)'; var dark_rgb = 'rgb(77, 77, 77)'; if ($('#hhh_lightoff '+bb['switchInput'])[0].checked === false) { //关灯 $('#hhh_lightoff '+bb['switchBody']+':first').css('background-color', dark_rgb); $('#hhh_lightoff '+bb['switchBody']+':first>'+bb['switchDot']).css('color', dark_rgb); } else { $('#hhh_lightoff '+bb['switchBody']+':first').css('background-color', body_brgb); $('#hhh_lightoff '+bb['switchBody']+':first>'+bb['switchDot']).css({'color': dot_crgb, 'background-color': dot_brgb}); } } //关灯按钮 function lightoff_btn() { lightoff(); let $light_input = $('#hhh_lightoff '+bb['switchInput']); if(is_lightoff() === $light_input[0].checked) { //checked==true开灯 false关灯 $light_input[0].checked = !$light_input[0].checked; } lightoff_btn_css(); let light_tip_text = $light_input[0].checked === true? '关灯': '开灯'; $('#hhh_lightoff .tooltip').text(light_tip_text); $('#hhh_lightoff').data('tip')['text'] = light_tip_text; } //关灯按钮初始化 function lightoff_init() { lightoff_btn_css(); //add tips waitForTrue(()=> ($tip !== undefined && $('#hhh_lightoff').length === 1), () => { if(bb_type === BILI_3_X) $('.squirtle-controller-wrap').css({"display":"flex"}); $(bb['dmWrap']).css({"display":"block"}); $('#hhh_lightoff').data('tip', {'text': '关灯', 'millisec':1, 'top':2, 'left':0, 'diff_full_top':-20}); add_tip($tip, $('#hhh_lightoff'), {}); $(bb['dmWrap']).css({"display":"none"}); if(bb_type === BILI_3_X) $('.squirtle-controller-wrap').css({"display":"none"}); }) } //模拟B站音量调节 //2.X版本可以直接调用系统函数window.player.volume(),但不能直接使用H5Player.volume //3.X版本去掉了window.player.volume(),但H5Player.volume功能发生变动,基本等价于window.player.volume() function volume(v, is_show_hint=true){ function volume_bar(v){ //未使用 if(v === undefined) return; v = v<0? 0: v>1? 1: v; $('.bilibili-player-video-volume-num').text(Math.round(v*100)); $('.bilibili-player-video-volumebar-wrp .bui-bar.bui-bar-normal')[0].style.transform = `scaleY(${v})`; $('.bilibili-player-video-volumebar-wrp .bui-thumb')[0].style.transform = `translateY(${-48*v}px)`; v === 0? $('.bilibili-player-video-btn.bilibili-player-video-btn-volume').addClass('video-state-volume-min'): $('.bilibili-player-video-btn.bilibili-player-video-btn-volume').removeClass('video-state-volume-min') } function volume_hint_bar(v){ if(v === undefined) return; assert(typeof v === "number", '| volume err: v is not number') //debug //v = v<0? 0: v>1? 1: v; v = +Math.max(Math.min(v,1),0).toFixed(3); var $volumeHintIcon = $(`#hhh_volumeHint ${bb['volumeHintIcon']}`); var volumeHintIconClassName = bb['volumeHintIcon'].substr(1); if(bb_type === BILI_2_X){ if(v <= 0) $volumeHintIcon.attr('class', `${volumeHintIconClassName} video-state-volume-min`); else if(v >= 1) $volumeHintIcon.attr('class', `${volumeHintIconClassName} video-state-volume-max`); else $volumeHintIcon.attr('class', volumeHintIconClassName); } else{ if(v <= 0){ $volumeHintIcon.find('.bpx-common-svg-icon:last').css('display','block'); $volumeHintIcon.find('.bpx-common-svg-icon:first').css('display','none'); } else{ $volumeHintIcon.find('.bpx-common-svg-icon:last').css('display','none'); $volumeHintIcon.find('.bpx-common-svg-icon:first').css('display','block'); } } if(v <= 0) showHint(this, '#hhh_volumeHint', '静音'); else showHint(this, '#hhh_volumeHint', Math.round(v*100)+'%'); } h5Player = ($(`${bb['video']} video`)[0] || $(`${bb['video']} bwp-video`)[0]); // bug:调节清晰度会影响 h5Player 和window.player,需要重新赋值 assert(typeof h5Player.volume === "number", '| volume err: h5Player.volume is not number') //debug if(v === undefined) { /*log('v: '+h5Player.volume);*/ return +h5Player.volume;} v = +Math.max(Math.min(v,1),0).toFixed(3); assert(typeof v === "number", '| volume err: v is not number') //debug //log('volume: '+v+' '+h5Player); //v = v<0.01? 0: v>1? 1: v; //0.01防止误差 bb_type === BILI_2_X? window.player.volume(v): h5Player.volume = v; //h5Player.volume = v; if(is_show_hint === true) volume_hint_bar(+h5Player.volume); return +h5Player.volume; } //显示提示 function showHint(parent, selector_str, text){ $(bb['volumeHint']).css({"visibility":"visible"}) $(bb['volumeHint']).css('display', 'none'); //隐藏所有提示,避免提示重叠 $(`${selector_str}>${bb['volumeHintText']}`).text(text); //百分比显示 var Hint = $(selector_str); //显示及渐隐效果(抄bilibili^^) clearTimeout(parent.showHintTimer), Hint.stop().css("opacity", 1).show(), parent.showHintTimer = window.setTimeout((function() { Hint.animate({ opacity: 0 }, 300, (function() { $(this).hide() })) } ), 1e3) } //非全屏滚轮音量调节 0~1 (b站默认滚轮操作某些情况会失效,一并处理全屏情况) //两个参数指定屏幕范围(按百分比),第三个参数表示滚动一下增加的音量百分比,参数四表示暂停时是否调节 function wheel_volumeHint(isWheelVolume=ON, screenLeft=0.3, screenRight=0.7, delta=1, isPauseVolume=ON){ $(bb['videoWrap']).off('mousewheel.hhh_volumeHint'); if(!isWheelVolume) return; $(bb['videoWrap']).on('mousewheel.hhh_volumeHint', function(e){ if(e.ctrlKey || e.altKey || e.shiftKey) return; //缺省屏幕百分比参数,默认0.3~0.7 screenLeft = (screenLeft<0 || screenLeft>1)? 0.3: screenLeft; screenRight = (screenRight<0 || screenRight>1)? 0.7: screenRight; //缺省音量百分比,默认1 delta = (delta<1 || delta>100)? 1: delta; //非暂停(可选) && 鼠标在屏幕指定位置时处理 var pauseState = isPauseVolume || h5Player.paused === false; var Rect = $(bb['videoWrap'])[0].getBoundingClientRect(); var offsetX = e.originalEvent.x - Rect.x; var inLimit = offsetX > Rect.width*screenLeft && offsetX < Rect.width*screenRight; if(is_fullscreen() || (pauseState && inLimit)) { //阻止页面滚动 && 阻止冒泡 e.preventDefault(); e.stopPropagation(); var wheelDelta = e.originalEvent.wheelDelta; var v = volume(); if(wheelDelta >= 120) { //向上滚动,减少音量 volume(+(v+(delta/100)).toFixed(3)); //+ string to number } else if(wheelDelta <= -120) { //向下滚动,增大音量 volume(+(v-(delta/100)).toFixed(3)); } } }); } /* * 控制进度条 * .bilibili-player-setting-opacity 透明度 * .bilibili-player-setting-area 显示区域 * .bilibili-player-setting-speedplus 弹幕速度 等 * 利用系统mousedown事件 * 0 ~ 100 */ function set_progress(selector_str, percent){ var selector = document.querySelector(selector_str); var e1 = new MouseEvent('mousedown'); var e2 = new MouseEvent('mouseup'); function calc_bar_len(percent, bar_width){ var p = percent - 10; p = p<0? 0: p>90? 90: p; return p*bar_width/90; //进度条对应百分比的系统算法 } if(bb_type === BILI_3_X) $('.squirtle-controller-wrap').css({"display":"flex"}); $(bb['dmWrap']).css({"display":"block"}); var selector_rect = selector.getClientRects(); var clientX = selector_rect[0].left + calc_bar_len(percent, $(`${selector_str} ${bb['progressWrap']}`).innerWidth()); e1.initMouseEvent('mousedown',1,1,window,1,0,0,clientX,0,0,0,0,0,0,null); e2.initMouseEvent('mouseup' ,1,1,window,1,0,0,clientX,0,0,0,0,0,0,null); selector.dispatchEvent(e1); selector.dispatchEvent(e2); $(bb['dmWrap']).css({"display":"none"}); if(bb_type === BILI_3_X) $('.squirtle-controller-wrap').css({"display":"none"}); $(bb['dm']).mouseleave(); //激活设置,记忆进度条位置 return $(`${selector_str} ${bb['progressVal']}`).text(); } /* * 调节透明度 * 利用系统mousedown事件 * '正数': right, '负数': left, -100 ~ +100 */ function adjust_progress(selector_str, inc_percent){ var curr_percent = Number($(`${selector_str} ${bb['progressVal']}`).text().slice(0,-1)); return set_progress(selector_str, curr_percent + inc_percent); } //滚轮调节弹幕透明度(ctrl),参数表示滚动一下增加的透明度百分比 function wheel_opacity(status, delta=5){ $(bb['videoWrap']).off('mousewheel.hhh_opacity'); if(status === OFF) return; $(bb['videoWrap']).on('mousewheel.hhh_opacity', function(e){ if(e.ctrlKey === true) { //阻止页面滚动 && 阻止冒泡 e.preventDefault(); e.stopPropagation(); //缺省透明度百分比,默认5 delta = (delta<1 || delta>100)? 5: delta; var wheelDelta = e.originalEvent.wheelDelta; var opacity; if(wheelDelta >= 120) { //向上滚动,增大透明度 opacity = adjust_progress(bb['settingOpacity'], delta); } else if(wheelDelta <= -120) { //向下滚动,减少透明度 opacity = adjust_progress(bb['settingOpacity'], -delta); } if(opacity !== undefined) showHint(document, '#hhh_opacityHint', '透 '+opacity); } }); } //自定义快捷键说明页面 function set_custom_hotkey($hotkey, sub_class, hotkey, is_append) { var $hotkey_panel = bb_type === BILI_2_X ? $hotkey.find(`.${sub_class}:first`) : $hotkey.find(`.${sub_class}-list:first`); var $hotkey_item = $hotkey.find(`.${sub_class}-item:first`); if(is_append === false) $hotkey_panel.empty(); for (let [key, { value, text }] of Object.entries(hotkey)) { $hotkey_item.clone().appendTo($hotkey_panel); var $hotkey_key = $hotkey_panel.find(`.${sub_class}-key:last`); $hotkey_key.text(value);; $hotkey_key.next().text(text).width(180); // 3.X 默认宽度窄了 } } //添加右键菜单自定义快捷键说明2.X function add_custom_hotkey_menu_2_X(custom_hotkey) { //主class名,去掉"." var hotkey_panel_class_wrap = 'bilibili-player-hotkey-panel-wrap'; var hotkey_panel_class = 'bilibili-player-hotkey-panel'; //监听右键菜单,生成自定义快捷键说明页面,只执行一次 (function add_custom_hotkey(){ $(bb['videoWrap'])[0].addEventListener('DOMNodeInserted', function(e) { let $target = $(e.target); if($target.hasClass(`${hotkey_panel_class}-container active`)) { this.removeEventListener('DOMNodeInserted', arguments.callee); var $hotkey = $target.attr('class', `${hotkey_panel_class}-container`); //去掉active,隐藏 //复制系统快捷键说明页面,需要时复制 $hotkey.clone(true,true).insertBefore($hotkey).attr({'class': '','id': 'sys_hotkey_panel'}).css('display', 'none') .find(`.${hotkey_panel_class_wrap}`).css('max-height', '600px'); //bilibili自己的BUG,由于max-height限制,显示不全,已 //复制系统快捷键说明页面,并修改为自定义快捷键说明页面,需要时复制 $hotkey.clone(true,true).insertBefore($hotkey).attr({'class': '','id': 'hhh_hotkey_panel'}).css('display', 'none') .find(`.${hotkey_panel_class_wrap}`).css('max-height', '600px'); //自定义快捷键说明页面 set_custom_hotkey($('#hhh_hotkey_panel'), hotkey_panel_class, custom_hotkey, false); } }); })(); //右键菜单弹出时添加项 (function add_menu(){ $('#bilibiliPlayer')[0].addEventListener('DOMSubtreeModified', function(e) { let $target = $(e.target); if($target.hasClass('bilibili-player-context-menu-container black bilibili-player-context-menu-origin') && $target[0].id === '') { //还有一个id = __sizzle__ this.removeEventListener('DOMSubtreeModified', arguments.callee); let $li_sys_hotkey = $target.find('a:contains("快捷键说明"):first').parent(); //返回li,XXX: 此时contains("快捷键说明")多于一个 let $a_hhh_hotkey = $target.find('a:contains("快捷键说明(bilibili关灯)")'); var $li_hhh_hotkey = ($a_hhh_hotkey.length && $a_hhh_hotkey.parent()) || $li_sys_hotkey.clone(false, false).insertAfter($li_sys_hotkey).css('display', '').find('a').text('快捷键说明(bilibili关灯)'); //插入自定义快捷键 $li_sys_hotkey.find('a').one('click', function(){ $('#sys_hotkey_panel').clone(true,true).replaceAll($(`.${hotkey_panel_class}-container:last`)).attr({'id': '', 'class': `${hotkey_panel_class}-container`, 'style': ''}); }); $li_hhh_hotkey.one('click', function(){ $('#hhh_hotkey_panel').clone(true,true).replaceAll($(`.${hotkey_panel_class}-container:last`)).attr({'id': '', 'class': `${hotkey_panel_class}-container`, 'style': ''}); }); add_menu(); } }); })(); //模拟右键菜单消息,激活菜单DOM let evt = new MouseEvent('contextmenu', { clientX:-9999, clientY:-9999 }); $(bb['videoWrap'])[0].dispatchEvent(evt); //模拟点击菜单,激活热键菜单DOM evt = new MouseEvent('click',{ bubbles:true }); $('.bilibili-player-context-menu-container.black.bilibili-player-context-menu-origin a:contains("快捷键说明")')[0].dispatchEvent(evt); } //添加右键菜单自定义快捷键说明3.X function add_custom_hotkey_menu_3_X(custom_hotkey) { //主class名,去掉"." var player_hotkey_class = 'bpx-player-hotkey'; //监听右键菜单,生成自定义快捷键说明页面 (function add_custom_hotkey(){ $(bb['videoWrap'])[0].addEventListener('DOMNodeInserted', function(e) { let $target = $(e.target); if($target.hasClass(`${player_hotkey_class}-area`)) { this.removeEventListener('DOMNodeInserted', arguments.callee); //var $hotkey = $target.css('display', 'none'); var $hotkey = $target; $hotkey.clone(true,true).insertBefore($hotkey).attr({'class': '','id': 'sys_hotkey_panel'}).css('display', 'none'); $hotkey.clone(true,true).insertBefore($hotkey).attr({'class': '','id': 'hhh_hotkey_panel'}).css('display', 'none'); $hotkey.css('visibility', 'hidden'); $('#sys_hotkey_panel .bpx-player-hotkey-close').click(function(){ $(this).parent().css('display', 'none') }); //jquery问题,clone失败,自定义关闭按钮事件 $('#hhh_hotkey_panel .bpx-player-hotkey-close').click(function(){ $(this).parent().css('display', 'none') }); //jquery问题,clone失败,自定义关闭按钮事件 //自定义快捷键说明页面 set_custom_hotkey($('#hhh_hotkey_panel'), player_hotkey_class, custom_hotkey, false); } }); })(); //右键菜单弹出时添加项 (function add_menu(){ $('#bilibili-player')[0].addEventListener('DOMSubtreeModified', function(e) { let $target = $(e.target); if($target.hasClass('bpx-player-contextmenu bpx-player-black') && $target[0].id === '') { //还有一个id = __sizzle__ this.removeEventListener('DOMSubtreeModified', arguments.callee); if($target.find('li:contains("快捷键说明"):first').length === 1) { var $li_sys_hotkey = $target.find('li:contains("快捷键说明"):first'); //XXX: 此时contains("快捷键说明")多于一个 var $li_hhh_hotkey = $li_sys_hotkey.clone(false, false).insertAfter($li_sys_hotkey).css('display', '').text('快捷键说明(bilibili关灯)'); $li_sys_hotkey.mousedown(function(){ $('#sys_hotkey_panel').clone(true,true).replaceAll($(`.${player_hotkey_class}-area:last`)).attr({'id': '', 'class': `${player_hotkey_class}-area`, 'style': ''}); }); $li_hhh_hotkey.mousedown(function(){ $('#hhh_hotkey_panel').clone(true,true).replaceAll($(`.${player_hotkey_class}-area:last`)).attr({'id': '', 'class': `${player_hotkey_class}-area`, 'style': ''}); }); } add_menu(); } }); })(); //模拟右键菜单消息,激活菜单DOM let evt = new MouseEvent('contextmenu', { clientX:-9999, clientY:-9999 }); $(bb['videoWrap'])[0].dispatchEvent(evt); //模拟点击菜单,激活热键菜单DOM evt = new MouseEvent('mousedown',{ bubbles:true }); $(`.bpx-player-contextmenu.bpx-player-black li:contains("快捷键说明")`)[0].dispatchEvent(evt); //隐藏自定义快捷键说明菜单 $(`.${player_hotkey_class}-area`).css('display', 'none'); } //添加右键菜单自定义快捷键说明 function add_custom_hotkey_menu(hotKeyMenu) { if(bb_type === BILI_2_X) add_custom_hotkey_menu_2_X(hotKeyMenu); else add_custom_hotkey_menu_3_X(hotKeyMenu); } //取得版本号-未使用 //function get_ver() { // if(bb_type === BILI_2_X) ver = bili_player.getVersion().version; // else ver = $('.bpx-common-opacity-60').text().split('-')[0]; //} //取得视频FPS(Frames Per Second) function get_video_fps_ver() { $(bb['videoWrap'])[0].addEventListener('DOMNodeInserted', function(e) { //插入info面板时截取fps值 if($(e.target).hasClass(bb['DOMNodeInsertedVideoInfoShow'].substr(1))) { this.removeEventListener('DOMNodeInserted', arguments.callee); let $video_info_close = $(bb['videoInfoClose']); $video_info_close.click(); //模拟关闭统计信息面板,2.X版本一次即可关掉 $video_info_close.click(); //3.X版本执行两次才能关掉面板,保险起见3次 $video_info_close.click(); //估计是点击事件开始太快,系统未能处理,也可能3.X测试版自己的问题 //text中取得fps值 var get_title_text = function(title) { return $(bb['videoInfoContainer']).find(`.info-title:contains("${title}")`).next().text(); } fps = Number(get_title_text('Resolution').match(/\d+\.\d+/)) || Number(get_title_text('FPS')) || 30; } }) //模拟右键菜单消息,激活菜单DOM let evt = new MouseEvent('contextmenu', { clientX:-9999, clientY:-9999 }); $(bb['videoContextMenu'])[0].dispatchEvent(evt); //模拟点击菜单,激活热键菜单DOM,版本号 if(bb_type === BILI_2_X){ let evt = new MouseEvent('click',{ bubbles:true }); $(`${bb['playerContextMenu']} a:contains("视频统计信息")`)[0].dispatchEvent(evt); ver = $(`${bb['playerContextMenu']} a:contains("更新历史")`).text().split(' ')[1].split('-')[0]; } else if(bb_type === BILI_3_X) { let evt = new MouseEvent('mousedown',{ bubbles:true }); $(`${bb['playerContextMenu']} li:contains("视频统计信息")`)[0].dispatchEvent(evt); ver = $(`${bb['playerContextMenu']} li:contains("更新历史")`).text().match(/\S+/g)[1].split('-')[0]; } } //笨办法,激活系统音量设置,复制volumeHint DOM function pick_volume_hint(){ var original_volume = h5Player.volume; //监视提取提示DOM $(bb['videoWrap'])[0].addEventListener('DOMNodeInserted', function(e) { if($(e.target).hasClass(bb['volumeHint'].substr(1))) { this.removeEventListener('DOMNodeInserted', arguments.callee); volume(original_volume); //模拟鼠标拖动无法按1%精确控制音量,系统自身限制或者说bug //添加 volumeHint wordsHint opacityHint DOM $(bb['volumeHint']).clone().appendTo(bb['videoWrap']).attr('id','hhh_volumeHint'); $('#hhh_volumeHint').clone().appendTo(bb['videoWrap']).attr('id','hhh_wordsHint').css({'opacity': 0, 'display': 'none'}).find(bb['volumeHintIcon']).remove(); $('#hhh_wordsHint').clone().appendTo(bb['videoWrap']).attr('id','hhh_opacityHint'); if(bb_type === BILI_2_X){ $('#hhh_wordsHint').css({'width':'auto','margin-left':'0px','padding-left':'8px','padding-right':'15px','transform':'translate(-50%)'}) .find(bb['volumeHintText']).css({'width': 'auto', 'padding-left': '10px'}); $('#hhh_opacityHint').find(bb['volumeHintText']).css({'padding-right': '6px'}); } else{ $('#hhh_wordsHint, #hhh_opacityHint').find(bb['volumeHintText']).css({'padding': '0 10px'}); } //隐藏提示 $(bb['volumeHint']).css({"visibility":"hidden"}); } }); //激活系统音量设置,复制volumeHint DOM let evt = new KeyboardEvent('keydown', { keyCode:keycode['up'] }); window.dispatchEvent(evt); } //快进时显示醒目进度条 function dynamicProgress(dynamicHeight, staticHeight){ if(bb_type === BILI_2_X) { if ($('.bilibili-player-area').hasClass('progress-shadow-show') === true) { $('.bilibili-player-video-progress-shadow .bui-track-video-progress').css('cssText', `height:${dynamicHeight}px !important`); clearTimeout(document.showVideoProgress); document.showVideoProgress = window.setTimeout((function() { $('.bilibili-player-video-progress-shadow .bui-track-video-progress').css('cssText', `height:${staticHeight}px !important`); }), 2000); } } else { if($('.bpx-player-container').hasClass('bpx-state-no-cursor') === true) { $('.squirtle-progress-buffer').css({'height': `${dynamicHeight/2}px`}); $('.squirtle-progress-timeline').css({'height': `${dynamicHeight/2}px`}); $('.squirtle-progress-totalline').css({'height': `${dynamicHeight/2}px`}); clearTimeout(document.showVideoProgress); document.showVideoProgress = window.setTimeout((function() { $('.squirtle-progress-buffer').css({'height': `${staticHeight}px`}); $('.squirtle-progress-timeline').css({'height': `${staticHeight}px`}); $('.squirtle-progress-totalline').css({'height': `${staticHeight}px`}); }), 2000); } } } //视频倍速 function video_select_speed(level) { let data_x = ['0.5x', '0.75x', '1.0x', '1.25x', '1.5x', '2.0x']; let curr_x = $(bb['videoSpeedActive']).text(); let x = data_x[data_x.indexOf(curr_x) + level]; if(x !== undefined) $(`${bb["videoSpeed"]}:contains("${x}")`).click(); showHint(parent, '#hhh_wordsHint', $(bb['videoSpeedName']).text()); } //初始化自定义设置 节点 事件 tips //setting - wrap - box | wrap - move - item function init_setting(run_default_setting_flag){ var $DSet = $(bb['dm']); var $wrap = $DSet.find('.bui-panel-wrap'); var $move = $DSet.find('.bui-panel-move'); var $item_0 = $DSet.find('.bui-panel-item:eq(0)'); var $item_1 = $DSet.find('.bui-panel-item:eq(1)'); var $item_2; var old_width = $item_0.width() + $item_1.width(); var item_0_height = $item_0.height() + 36; var item_2_width = $item_0.width() + 20; var item_2_height = 452+22*2; /*----------------------------------- * 初始化 *----------------------------------*/ //初始化【$item_0】高度 $item_0.css('height', item_0_height); //初始化【$move】宽度 $DSet.find('.bui-panel-move').css('width', old_width + item_2_width); /*----------------------------------- * 复制所需节点 *----------------------------------*/ //复制【item_0】【高级设置】To【自定义设置】 $(bb['dmLeftMore']).clone().appendTo(bb['dmLeft']).attr('id', 'hhh_more') .css('top', '20px') .find(bb['dmLeftMoreText']).text('自定义设置'); //复制【item_1】 To 【item_2】 $item_2 = $item_1.clone().appendTo($move).attr('id', 'hhh_item') .css({'width':item_2_width, 'height':item_2_height}) .removeClass('bui-panel-item-active') .find('div *').remove().end(); //复制【分割线】模板 var $separator = $item_1.find(`${bb['dmRightSeparator']}:first`).clone(); //复制【$title $hotkey父节点】模板 var $title_div = $item_0.find(bb['dmLeftBlock']).clone().attr('id', 'hhh_title_div') //.css({'display': 'flex', 'flex-direction': 'column'}) .empty().css({'margin-top': 6, 'margin-bottom': 2, 'height': 32+0}); //复制【title】模板 var $title = $item_0.find(bb['dmLeftBlockTitle']).clone().css({'color': '#12b3e8'}) .css({'display': 'inline-flex', 'line-height': '32px'}) .text('bilibili关灯自定义设置'); //复制【快捷键说明】模板 var $hotkey = $item_1.find(bb['dmRightMore']).clone().attr('id', 'hhh_item_2_hotkey') .css({'display': 'inline-flex', 'float': 'right'}) .find('span:first').remove().end() .find(bb['dmRightMoreText']).text('快捷键说明(点击切换)').end(); // var $div = $('
'); var $middle_div = $div.clone().css({'display':'flex', 'justify-content':'space-between'}); //复制【封面】模板 var $cover = $item_1.find(bb['dmRightMore']).clone().attr('id', 'hhh_item_2_cover') //.css({'display': 'inline-flex', 'float': 'right', 'flex-direction': 'row-reverse'}) //.css({'float': 'right'}) .find('span:first').remove().end() .find(bb['dmRightMoreText']).text('显示封面').end(); //复制【input-checkbox父节点】模板 var $input_div = $item_0.find(bb['dmLeftBlock']).clone().attr('id', 'hhh_input_div') .empty().css({'margin-top': 4, 'margin-bottom': 2}) //.css('background', 'blue') //.css('width', 200) ; //复制【更多其他】模板 var $more_div = $item_0.find(bb['dmLeftBlock']).clone().attr('id', 'hhh_input_div2') .empty().css({'margin-top': 4, 'margin-bottom': 2}) //.css('background', 'red') //.css('width', 100).css('height', 100) ; //复制【input-checkbox】模板 var $input = $item_1.find(bb['dmRightDensity']).clone().css({'display': 'flex', 'margin-top': '6px'}) //inline-flex .find('input').removeAttr('aria-label').prop('checked', false).end() .find('.bui-checkbox-name').text('bilibili关灯').end(); //复制【恢复默认设置】模板 var $reset = $item_1.find(bb['dmRightReset']).clone().css({'margin-top': 2, 'margin-bottom': 6}); //复制【返回】模板 var $reback = $item_1.find(bb['dmRightMore']).clone().attr('id', 'hhh_item_2_more') .css({'margin-top': 2}) .find(bb['dmRightMoreText']) .text('返回').end(); /*----------------------------------- * 添加节点 *----------------------------------*/ let $item_2_div = $item_2.children(':first'); /*----------------------------------- * 上部div *----------------------------------*/ //添加title hotkey $title_div.appendTo($item_2_div); $title.clone().appendTo($title_div); $hotkey.clone().appendTo($($title_div)); //添加分割线 $separator.clone().appendTo($item_2_div); /*----------------------------------- * 中部div *----------------------------------*/ $middle_div.appendTo($item_2_div); $input_div.appendTo($middle_div); $more_div.appendTo($middle_div); //添加 & 初始化【checkbox】 for (let [key, { text, status, args, show }] of Object.entries(config.sets)) { if(show === OFF) continue; $input.clone().appendTo($input_div).attr('id', key) .find('input').prop('checked', status).end() .find('.bui-checkbox-name').text(text); if(key === 'volumeControlWhenNonFullScreen') config.setCheckboxSettingTips('volumeControlWhenNonFullScreen', `在屏幕中间${Math.round((args.screenRight-args.screenLeft)*100)}%范围内调节,步幅${args.delta}%`); } //添加恢复默认设置 $reset.clone().appendTo($input_div); //添加封面 $cover.appendTo($more_div); /*----------------------------------- * 下部div *----------------------------------*/ //添加分割线 $separator.clone().appendTo($item_2_div); //添加返回 $reback.clone().appendTo($item_2_div); /*----------------------------------- * 添加事件等 *----------------------------------*/ //重设置【设置按钮】 // $DSet.mouseenter(function(){ // $wrap.css('height', $DSet.find('.bui-panel-item-active').css('height')); // }) //重设置【item_0 - 自定义设置】 $('#hhh_more').click(function(){ $wrap.css({'height': $item_2.css('height'), 'width': $item_2.css('width')}); $move.css('transform', `translateX(-${old_width}px)`); $DSet.find('.bui-panel-item-active').removeClass('bui-panel-item-active'); $item_2.addClass('bui-panel-item-active'); }) //重设置【item_1 - 更多弹幕设置】 $item_1.find(bb['dmRightMore']).click(function(){ $wrap.css({'height': $item_0.css('height'), 'width': $item_0.css('width')}); }) //重设置【item_2 - 返回】 $item_2.find('#hhh_item_2_more').click(function(){ $wrap.css({'height': $item_0.css('height'), 'width': $item_0.css('width')}); $move.css('transform', 'translateX(0px)'); $DSet.find('.bui-panel-item-active').removeClass('bui-panel-item-active'); $item_0.addClass('bui-panel-item-active'); }) //重设置【item_2 - 封面】 $item_2.find('#hhh_item_2_cover').click(function(){ if($('#hhh_img').length === 1){ // //let width = $(bb['video']).width()*0.9; //$('#hhh_img').css('width', width); $('#hhh_img').css('display') === 'none'? $('#hhh_img').css('display', 'flex'): $('#hhh_img').css('display', 'none'); } else { let $img = $(`