// ==UserScript== // @name MR哔哩哔哩助手-自动宽屏模式|自定义布局|智能连播|打造属于自己的B站 // @namespace https://github.com/iMortRex // @version 1.0.6 // @description 自动宽屏模式|自定义布局|智能连播...更多功能等你体验, 打造属于自己的B站~ // @author Mort Rex // @run-at document-start // @match *.bilibili.com/* // @match http*://*.bilibili.com/ // @require https://code.jquery.com/jquery-3.6.0.min.js // @icon https://www.bilibili.com/favicon.ico // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @license MIT // @downloadURL none // ==/UserScript== // 初始化全局变量 var notificationScriptName = 'MR哔哩哔哩助手'; var notificationNotification = '通知'; var notificationCheck = '检测'; var notificationWarning = '警告'; var notificationError = '错误'; var etime = 8000; // 计时器通用超时时间 var loadReady = false; // 判断页面是否加载完毕, 等加载完毕再进行网页全屏操作 var isMRMenuMoving = false; // 判断是否拖拽MR菜单 var isMRMenuMovingX = 0; var isMRMenuMovingY = 0; // 播放模式 // 自动宽屏模式变量 var autoWidescreenEtime = 0; // 用来记录执行时间的变量 // btn是宽屏模式的按钮, isWidescreenClass是用来判断是否已经是宽屏模式的字符串, 如果已经是宽屏模式class name中会有相关字符串 var autoWidescreenBtn = ''; var autoWidescreenisWidescreenClass = ''; // 网页全屏变量 var fullscreenEtime = 0; var playerWrapInnerHTML = ''; // 自定义布局 // 移动导航栏到视频下方 var moveNavigationBarEtime = 0; // 隐藏新版反馈和回到旧版按钮 var hideFeedbackBtnEtime = 0; // 调整下方左右边距 var downLayoutPaddingEtime = 0; // 导航栏搜索框长度占满 var searchBarFullEtime = 0; // 将弹幕栏整合到播放器内 var putSendingBarInPlayerEtime = 0; // 隐藏观看人数和弹幕装填信息 var hideVideoInfoEtime = 0; // 播放器内显示选集按钮 var displayEplistEtime = 0; // 播放器内显示标题 var displayTitleEtime = 0; // 隐藏播放器内关注按钮 var hideFollowBtnEtime = 0; // 把标题和头像移到视频下方 var moveTitleAndUpinfoEtime = 0; // 隐藏导航栏标签 var hideNavigationBarTagEtime = 0; // 实用功能与工具 // 智能连播 (多集/分P连播, 单集不连播) var smartNextPlayEtime = 0; // 去除宽屏模式左右黑边 var removeWidescreenBlackEtime = 0; // 总是开启或关闭弹幕 var alwaysDisableDnmakuEtime = 0; // 其他 // 判断页面加载完毕 var loadReadyEtime = 0; // 判断当前页面 // 0.视频, 1.影视, 2.列表, 3.空间, 4.搜索, 5.主页, 6.信息, 7.个人中心, 999.未知, 999999.不显示通知 var webStatus = 0; var webStatusUnknowPage = 999; var webStatusNotShow = 999999; var webStatusLog = ''; if (window.location.href.match('bilibili.com/video/')) { webStatusLog = '视频'; webStatus = 0; } else if (window.location.href.match('bilibili.com/bangumi/')) { webStatusLog = '影视'; webStatus = 1; } else if (window.location.href.match('bilibili.com/medialist/')) { webStatusLog = '列表'; webStatus = 2; } else if (window.location.href.match('space.bilibili.com')) { webStatusLog = '空间'; webStatus = 3; } else if (window.location.href.match('search.bilibili.com')) { webStatusLog = '搜索'; webStatus = 4; } else if (window.location.href.match('www.bilibili.com')) { webStatusLog = '主页'; webStatus = 5; } else if (window.location.href.match('message.bilibili.com') && !window.location.href.match('message.bilibili.com/pages/nav')) { webStatusLog = '信息' + window.location.href; webStatus = 6; } else if (window.location.href.match('account.bilibili.com')) { webStatusLog = '个人中心'; webStatus = 7; } else if (window.location.href.match('member.bilibili.com')) { webStatusLog = '创作中心, 不执行脚本'; webStatus = 999; } else if (window.location.href.match('message.bilibili.com/pages/nav')) { webStatusLog = '页面内信息'; webStatus = 999999; } else { webStatusLog = '未知页面, 不执行脚本 (' + window.location.href + ')'; webStatus = 999; } if (webStatus == webStatusUnknowPage) { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + webStatusLog); } else if (webStatus != webStatusNotShow) { console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '当前是 [' + webStatusLog + '] 页面'); } if (GM_getValue('MRMenuSwitch') == null) { // 菜单是否已打开, 0.不打开, 1.打开 GM_setValue('MRMenuSwitch', 1); } if (GM_getValue('MRMenuReadme') == null) { // 是否显示自述, 0.隐藏, 1.显示 GM_setValue('MRMenuReadme', 1); } // 播放模式 if (GM_getValue('MRPlayerMode') == null) { // 默认打开自动宽屏模式, 0.默认模式, 1.自动宽屏模式, 2.网页全屏模式 GM_setValue('MRPlayerMode', 2); } // 自定义布局 if (GM_getValue('MRMenuMoveNavigationBar') == null) { // 移动导航栏到视频下方, 0.不移动, 1.移动 GM_setValue('MRMenuMoveNavigationBar', 1); } if (GM_getValue('MRMenuHideFeedbackBtn') == null) { // 隐藏新版反馈和回到旧版按钮, 0.显示, 1.隐藏 GM_setValue('MRMenuHideFeedbackBtn', 1); } if (GM_getValue('MRMenuDownLayoutPadding') == null) { // 调整下方左右边距, 0.不调整, 1.调整 GM_setValue('MRMenuDownLayoutPadding', 1); } if (GM_getValue('MRMenuDownLayoutSearchBarFull') == null) { // 导航栏搜索框长度占满, 0.默认, 1.占满 GM_setValue('MRMenuDownLayoutSearchBarFull', 1); } if (GM_getValue('MRMenuPutSendingBarInPlayer') == null) { // 将弹幕栏整合到播放器内, 0.不整合, 1.整合 GM_setValue('MRMenuPutSendingBarInPlayer', 1); } if (GM_getValue('MRMenuHideVideoInfo') == null) { // 隐藏观看人数和弹幕装填信息, 0.显示, 1.隐藏 GM_setValue('MRMenuHideVideoInfo', 1); } if (GM_getValue('MRMenuDisplayEplist') == null) { // 播放器内显示选集按钮, 0.隐藏, 1.显示 GM_setValue('MRMenuDisplayEplist', 1); } if (GM_getValue('MRMenuDisplayTitle') == null) { // 播放器内显示标题, 0.隐藏, 1.显示 GM_setValue('MRMenuDisplayTitle', 1); } if (GM_getValue('MRMenuHideFollowBtn') == null) { // 隐藏播放器内关注按钮, 0.显示, 1.隐藏 GM_setValue('MRMenuHideFollowBtn', 0); } if (GM_getValue('MRMenuMoveTitleAndUpinfo') == null) { // 把标题和头像移到视频下方, 0.不移动, 1.移动 GM_setValue('MRMenuMoveTitleAndUpinfo', 1); } //// 隐藏导航栏标签 if (GM_getValue('MRMenuHideNavigationBarTag') == null) { // 标签顺序: 0.图标, 1.首页, 2.番剧, 3.直播, 4.游戏中心, 5.会员购, 6.漫画, 7.赛事, 8.活动广告, 9.下载客户端, 数字意义: 0.显示, 1.隐藏 GM_setValue('MRMenuHideNavigationBarTag', '0011111111'); } // 实用功能与工具 if (GM_getValue('MRMenuTransparent') == null) { // MR菜单是否半透明, 1.不透明, *.半透明 GM_setValue('MRMenuTransparent', 1); } if (GM_getValue('MRMenuSmartNextPlay') == null) { // 智能连播, 0.关闭, 1.开启 GM_setValue('MRMenuSmartNextPlay', 1); } if (GM_getValue('MRMenuMoveWindowToTop') == null) { // 播放器加载完毕后移动窗口到顶部, 0.不移动, 1.移动 GM_setValue('MRMenuMoveWindowToTop', 0); } if (GM_getValue('MRMenuRemoveWidescreenBlack') == null) { // 去除宽屏模式左右黑边 (竖版视频不生效), 0.不去除, 1.去除 GM_setValue('MRMenuRemoveWidescreenBlack', 0); } //// 总是开启或关闭弹幕 if (GM_getValue('MRMenuAlwaysDisableDnmaku') == null) { // 标签顺序: 0.开启功能, 1.总是开启, 2.总是关闭, 数字意义: 0.关闭, 1.开启 GM_setValue('MRMenuAlwaysDisableDnmaku', '001'); } // 未知网页不执行 if (webStatus != webStatusUnknowPage && webStatus != webStatusNotShow) { // 油猴菜单 GM_registerMenuCommand('菜单', function () { menuClick(); }); // 油猴菜单点击事件 function menuClick() { if (GM_getValue('MRMenuSwitch') == 0) { GM_setValue('MRMenuSwitch', 1); if (loadReady) { MRMenuElement.style.cssText += 'pointer-events: all; opacity: ' + GM_getValue('MRMenuTransparent') + ';'; } else { MRMenuElement.style.cssText += 'opacity: ' + GM_getValue('MRMenuTransparent') + ';'; } } else { GM_setValue('MRMenuSwitch', 0); MRMenuElement.style.cssText += 'pointer-events: none; opacity: 0;'; } } // MR菜单样式 // 创建菜单父类容器 var MRMenuElement = document.createElement('div'); MRMenuElement.setAttribute('id', 'MRMenu'); if (GM_getValue('MRMenuSwitch') == 0) { MRMenuElement.style.cssText += 'transition: .2s; z-index: 99999; position: fixed; pointer-events: none; opacity: 0;'; } else { MRMenuElement.style.cssText += 'transition: .2s; z-index: 99999; position: fixed; pointer-events: none; opacity: ' + GM_getValue('MRMenuTransparent') + ';'; } // 创建菜单背景和所有按钮 var MRMenuBackground = document.createElement('div'); MRMenuBackground.setAttribute('id', 'MRMenuBackground'); MRMenuBackground.style.cssText = '\ display: flex;\ overflow: auto;\ flex-wrap: wrap;\ position: fixed;\ box-shadow: var(--border) 0px 0px 0px 1.2px !important;\ width: 600px;\ height: auto;\ background-color: var(--bg) !important;\ z-index: 9999999;\ border-radius: 8px;\ left: 50%;\ top: 50%;\ transform:translate(-50%, -50%);\ padding: 0px 0px 8px 0px;\ max-height: 592px;\ max-width: 600px;\ box-sizing: unset;\ '; MRMenuBackground.innerHTML = '\
\ \
\
\ \ \
\ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\
\ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\ \
\
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\
\
\ \
\
\ \ \
\
\ \ \
\
\ \ \
\
\ \ \
\ \
\
\
\ \ \
\
\ \ \
\
\ \ \
\
\
\ '; // 创建菜单样式 var MRMenuStyle = document.createElement('style'); MRMenuStyle.innerHTML = '\r\n\ /* 深色模式样式 */\r\n\ @media(prefers-color-scheme: dark) {\r\n\ :root {\r\n\ --bg: rgba(30, 30, 30, 1);\r\n\ --bg2: rgba(45, 45, 45, 1);\r\n\ --textColor: rgba(255, 255, 255, 1);\r\n\ --closeBtnActiveTextColor: rgba(205, 205, 205, 1);\r\n\ --closeBtnHoverBg: rgba(230, 50, 50, 1);\r\n\ --closeBtnActiveBg: rgba(130, 30, 30, 1);\r\n\ --sliderBg: rgba(25, 25, 25, 1);\r\n\ --sliderBgChecked: rgba(30, 150, 245, 1);\r\n\ --sliderBtn: rgba(255, 255, 255, 1);\r\n\ --border: rgba(0, 0, 0, 0.3);\r\n\ --border2: rgba(40, 40, 40, 1);\r\n\ --split: rgba(30, 30, 30, 1);\r\n\ --darkreader-bg--sliderBtn: var(--sliderBtn)\r\n\ }\r\n\ }\r\n\ \r\n\ /* 浅色模式样式 */\r\n\ @media(prefers-color-scheme: light) {\r\n\ :root {\r\n\ --bg: rgba(240, 240, 240, 1);\r\n\ --bg2: rgba(250, 250, 250, 1);\r\n\ --textColor: rgba(0, 0, 0, 1);\r\n\ --closeBtnActiveTextColor: rgba(60, 60, 60, 1);\r\n\ --closeBtnHoverBg: rgba(230, 50, 50, 1);\r\n\ --closeBtnActiveBg: rgba(230, 150, 150, 1);\r\n\ --sliderBg: rgba(205, 205, 205, 1);\r\n\ --sliderBgChecked: rgba(30, 150, 245, 1);\r\n\ --sliderBtn: rgba(255, 255, 255, 1);\r\n\ --border: rgba(0, 0, 0, 0.3);\r\n\ --border2: rgba(220, 220, 220, 1);\r\n\ --split: rgba(230, 230, 230, 1);\r\n\ }\r\n\ }\r\n\ \r\n\ /* 全局样式 */\r\n\ :root {\r\n\ --defaultMargin: 8px 8px 0px 8px;\r\n\ --defaultMargin2: 0px 0px 0px 8px;\r\n\ }\r\n\ \r\n\ /* 开关样式 */\r\n\ .MRMenuSwitch {\r\n\ position: relative;\r\n\ display: inline-block;\r\n\ width: 50px;\r\n\ height: 28px;\r\n\ }\r\n\ \r\n\ /* 隐藏复选框 */\r\n\ .MRMenuSwitch input {\r\n\ display: none;\r\n\ }\r\n\ \r\n\ /* 开关按钮背景样式 */\r\n\ .MRMenuSlider {\r\n\ border-radius: 26px;\r\n\ position: absolute;\r\n\ cursor: pointer;\r\n\ top: 0;\r\n\ left: 0;\r\n\ right: 0;\r\n\ bottom: 0;\r\n\ background-color: var(--sliderBg) !important;\r\n\ transition: .2s;\r\n\ }\r\n\ \r\n\ /* 开关按钮样式 */\r\n\ .MRMenuSlider:before {\r\n\ border-radius: 50%;\r\n\ position: absolute;\r\n\ content: "";\r\n\ height: 24px;\r\n\ width: 24px;\r\n\ left: 2px;\r\n\ bottom: 2px;\r\n\ background-color: var(--sliderBtn) !important;\r\n\ transition: .2s;\r\n\ }\r\n\ \r\n\ /* 开关不可点击时的样式 */\r\n\ input:checked+.MRMenuSlider[mr_disable=true] {\r\n\ background-color: var(--sliderBg) !important;\r\n\ }\r\n\ .MRMenuSlider[mr_disable=true]:before {\r\n\ opacity: 0.4;\r\n\ }\r\n\ \r\n\ /* 开关开启样式 */\r\n\ input:checked+.MRMenuSlider {\r\n\ background-color: var(--sliderBgChecked) !important;\r\n\ }\r\n\ \r\n\ /* 开关开启时样式, 移动按钮到右侧 */\r\n\ input:checked+.MRMenuSlider:before {\r\n\ transform: translateX(22px);\r\n\ }\r\n\ \r\n\ /* 文本样式 */\r\n\ .MRMenuText {\r\n\ font-size: 16px;\r\n\ text-align: center;\r\n\ user-select: none;\r\n\ width: auto;\r\n\ height: auto;\r\n\ line-height: 28px;\r\n\ color: var(--textColor) !important;\r\n\ }\r\n\ \r\n\ /* 分割线样式 */\r\n\ .MRMenuSplit {\r\n\ margin: 8px 8px 0px 16px;\r\n\ background-color: var(--split) !important;\r\n\ border-radius: 2px;\r\n\ width: 100%;\r\n\ height: 2px;\r\n\ }\r\n\ \r\n\ /* 选项父类容器样式 */\r\n\ .MRMenuOption {\r\n\ display: flex;\r\n\ flex-wrap: wrap;\r\n\ user-select: none;\r\n\ }\r\n\ /* 菜单关闭按钮样式 */\r\n\ #MRMenuCloseBtn {\r\n\ width: 52px;\r\n\ height: 30px;\r\n\ margin: -30px 0px 0px calc(100% - 60px);\r\n\ font-size: 16px;\r\n\ text-align: center;\r\n\ line-height: 30px;\r\n\ word-spacing: 0px;\r\n\ box-sizing: border-box;\r\n\ border: 0;\r\n\ border-radius: 6px;\r\n\ background-color: var(--bg2);\r\n\ color: var(--textColor);\r\n\ outline: none;\r\n\ user-select: none;\r\n\ box-shadow: rgb(0 0 0 / 10%) 0px 0px 0px 1px !important;\r\n\ transition: .1s;\r\n\ padding: 0px 0px 0px 1px;\r\n\ }\r\n\ \r\n\ /* 菜单关闭按钮鼠标悬浮时样式 */\r\n\ #MRMenuCloseBtn:hover {\r\n\ color: rgba(255, 255, 255, 1);\r\n\ background-color: var(--closeBtnHoverBg);\r\n\ }\r\n\ \r\n\ /* 菜单关闭按钮被点击时样式 */\r\n\ #MRMenuCloseBtn:active {\r\n\ color: rgba(255, 255, 255, 1);\r\n\ background-color: var(--closeBtnActiveBg);\r\n\ }\r\n\ \r\n\ /* 弹幕栏禁用隐藏 */\r\n\ [mr_always_display=true] {\r\n\ display: block !important;\r\n\ }\r\n\ \r\n\ /* 弹幕栏整合到播放器时隐藏白线 */\r\n\ .bpx-player-sending-area[mr_inside_player=true]:before {\r\n\ display: none !important;\r\n\ }\r\n\ .bilibili-player-video-bottom-area[mr_inside_player=true]:before {\r\n\ display: none !important;\r\n\ }\r\n\ \r\n\ /* 弹幕栏发送提示字体颜色 */\r\n\ [mr_inside_player=true]::-webkit-input-placeholder {\r\n\ color: hsla(0,0%,100%,0.6) !important;\r\n\ }\r\n\ \r\n\ /* 显示选集按钮样式 */\r\n\ [mr_show_eplist=true] {\r\n\ width: 36px;\r\n\ visibility: visible;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方标题样式 */\r\n\ #viewbox_report[mr_layout=true] {\r\n\ height: 86px;\r\n\ border-bottom: 1px solid var(--line_regular);\r\n\ padding: 16px 0px 12px 0px;\r\n\ }\r\n\ #viewbox_report[mr_layout_list=true] {\r\n\ height: 86px;\r\n\ border-bottom: 1px solid #e5e9f0;\r\n\ padding: 16px 0px 12px 0px;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方头像栏样式 */\r\n\ #v_upinfo[mr_layout=true] {\r\n\ border-bottom: 1px solid var(--line_regular);\r\n\ padding: 16px 0px 10px 0px;\r\n\ margin: 0px;\r\n\ }\r\n\ #v_upinfo[mr_layout_list=true] {\r\n\ border-bottom: 1px solid #e5e9f0;\r\n\ padding: 16px 0px 10px 0px;\r\n\ margin: 0px;\r\n\ height: 81px;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方头像栏右侧样式 */\r\n\ .up-info_right[mr_layout_list=true] {\r\n\ display: flex;\r\n\ width: 100%;\r\n\ height: auto;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方播放器样式 */\r\n\ #playerWrap[mr_layout=true] {\r\n\ margin: 15px 0px 0px 0px;\r\n\ }\r\n\ #video-player[mr_layout=true] {\r\n\ margin: 15px 0px 0px 0px;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方弹幕列表样式 */\r\n\ #danmukuBox[mr_layout=true] {\r\n\ margin: 15px 0px 0px 0px;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方充电关注面板样式 */\r\n\ .btn-panel[mr_layout=true] {\r\n\ float: right;\r\n\ margin: -52px 10px 0px 0px;\r\n\ }\r\n\ .btn-panel[mr_layout_list=true] {\r\n\ margin: 0px 6px 0px 0px;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方旧充电按钮样式 */\r\n\ .old-charge-btn[mr_layout=true] {\r\n\ height: 48px !important;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方新充电按钮样式 */\r\n\ .new-charge-btn[mr_layout=true] {\r\n\ height: 50px !important;\r\n\ margin: 0px 12px 0px 0px;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方关注按钮样式 */\r\n\ .follow-btn[mr_layout=true] {\r\n\ height: 48px !important;\r\n\ width: 130px !important;\r\n\ padding: 0px 8px !important;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方未关注按钮样式 */\r\n\ .not-follow[mr_layout=true] {\r\n\ height: 48px !important;\r\n\ width: 130px !important;\r\n\ padding: 0px 8px !important;\r\n\ margin: 0px 0px 0px 0px;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方名称样式 */\r\n\ .name[mr_layout=true] {\r\n\ margin: 4px 0px 0px 0px;\r\n\ }\r\n\ .name[mr_layout_list=true] {\r\n\ margin: 4px 0px 0px 0px;\r\n\ width: 100% !important;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方头像装饰样式 */\r\n\ .u-face.has-pendant[mr_layout=true] {\r\n\ member-containermargin: -16px 0px -10px -8px;\r\n\ }\r\n\ \r\n\ /* 把标题和头像移到视频下方联合投稿 */\r\n\ .members-info-v1[mr_layout=true] {\r\n\ border-bottom: 1px solid var(--line_regular);\r\n\ }\r\n\ .members-info[mr_layout_list=true] {\r\n\ border-bottom: 1px solid #e5e9f0;\r\n\ }\r\n\ \r\n\ /* 隐藏滚动条 */\r\n\ body *::-webkit-scrollbar {\r\n\ width: 0px !important;\r\n\ height: 0px !important;\r\n\ }\r\n\ \r\n\ /* 影视页网页全屏播放器高度修正 */\r\n\ #player_module[mr_fullscreen=true] {\r\n\ width: auto !important;\r\n\ height: auto !important;\r\n\ z-index: 50 !important;\r\n\ position: relative !important;\r\n\ }\r\n\ \r\n\ /* 影视页网页全屏下方整体修正 */\r\n\ #app[mr_fullscreen=true] {\r\n\ margin: 20px auto !important;\r\n\ }\r\n\ /* 影视页网页全屏下方整体修正 */\r\n\ #app[mr_margin_fix=true] {\r\n\ margin-left: 20px !important;\r\n\ margin-right: 20px !important;\r\n\ width: auto !important;\r\n\ }\r\n\ \r\n\ /* 影视页网页全屏左下方修正 */\r\n\ .plp-l[mr_fullscreen=true] {\r\n\ padding-top: 0 !important;\r\n\ }\r\n\ \r\n\ /* 影视页网页全屏右下方修正 */\r\n\ .plp-r[mr_fullscreen=true] {\r\n\ margin-top: 0 !important;\r\n\ }\r\n\ \r\n\ /* 影视页网页全屏观看人数和弹幕装填宽度修正 */\r\n\ .bpx-player-video-info[mr_fullscreen=true] {\r\n\ width: auto !important;\r\n\ }\r\n\ '; // 把菜单背景移到菜单父类容器里 MRMenuElement.appendChild(MRMenuBackground); // 把菜单样式移到菜单父类容器 MRMenuElement.appendChild(MRMenuStyle); } (function () { 'use strict'; // 未知网页不执行 if (webStatus != webStatusUnknowPage && webStatus != webStatusNotShow) { // 直接执行 // 判断页面是否加载完毕 loadReadyFunction(); // 播放模式 if (GM_getValue('MRPlayerMode') == 0) { autoWidescreen(); } else if (GM_getValue('MRPlayerMode') == 1) { autoWidescreen(); } else if (GM_getValue('MRPlayerMode') == 2) { fullscreen(); } // 自定义布局 // 隐藏新版反馈和回到旧版按钮 if (GM_getValue('MRMenuHideFeedbackBtn') == 1) { hideFeedbackBtn(); } // 隐藏观看人数和弹幕装填信息 if (GM_getValue('MRMenuHideVideoInfo') == 1) { hideVideoInfo(); } // 播放器内显示选集按钮 if (GM_getValue('MRMenuDisplayEplist') == 1) { displayEplist(); } // 隐藏播放器内关注按钮 if (GM_getValue('MRMenuHideFollowBtn') == 1) { hideFollowBtn(); } // 把标题和头像移到视频下方 if (GM_getValue('MRMenuMoveTitleAndUpinfo') == 1) { moveTitleAndUpinfo(); } // 实用功能与工具 // 智能连播 if (GM_getValue('MRMenuSmartNextPlay') == 1) { smartNextPlay(); } // 给宽屏模式按钮注册点击事件 var widescreenBtnCheckEtime = 0; if (webStatus == 0 || webStatus == 1 || webStatus == 2) { widescreenBtnCheck(); function widescreenBtnCheck() { if (document.getElementsByClassName('bpx-player-ctrl-wide')[0]) { document.getElementsByClassName('bpx-player-ctrl-wide')[0].addEventListener('click', function () { if (GM_getValue('MRMenuMoveWindowToTop') == 1) { // 判断"播放器加载完毕后移动窗口到顶部"是否开启 moveWindowToTop(); // 宽屏模式开启后移动窗口到顶部 } }) } else if (widescreenBtnCheckEtime < etime) { widescreenBtnCheckEtime += 200; setTimeout(widescreenBtnCheck, 200); } } } // body加载完毕后运行 console.log('[' + notificationScriptName + '-' + notificationCheck + '] ' + '正在持续检测body元素是否加载完成'); afterBody(); function afterBody() { if (document.body) { console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + 'body元素加载完成'); afterBodyFunction(); btnFunction(); } else { setTimeout(afterBody, 20); } } // body加载后执行的杂项 function afterBodyFunction() { // 把菜单父类容器移到body的最上方, 这里已经运行在body加载完毕, 再判定一遍body是为了以后可能会迁移到其他位置让代码看起来更规范, 性能几乎不会有影响 if (document.body) { document.body.insertBefore(MRMenuElement, document.body.children[0]); if (loadReady) { document.getElementById('MRMenuStatus').textContent = ''; } console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + 'MR菜单创建完毕'); } // 鼠标拖拽MR菜单事件, 鼠标抬起和拖拽动作挂载到window上是为了防止鼠标移动过快脱离MR菜单元素 document.getElementById('MRMenuBackground').onmousedown = function (e) { // 这里的e是触发事件的目标, 这里也就是鼠标 isMRMenuMovingX = e.pageX - document.getElementById('MRMenuBackground').offsetLeft; isMRMenuMovingY = e.pageY - document.getElementById('MRMenuBackground').offsetTop; isMRMenuMoving = true; } window.onmouseup = function () { isMRMenuMoving = false; } window.onblur = function () { // 失焦后阻止菜单继续跟随鼠标 isMRMenuMoving = false; } window.onmousemove = function (e) { if (isMRMenuMoving) { document.getElementById('MRMenuBackground').style.left = e.pageX - isMRMenuMovingX + 'px'; document.getElementById('MRMenuBackground').style.top = e.pageY - isMRMenuMovingY + 'px'; } } // 自述 if (GM_getValue('MRMenuReadme') == 1) { GM_setValue('MRMenuReadme', 0); document.getElementById('MRMenuReadme').style.display = 'flex'; } // 修正按钮开关状态 // 播放模式 if (GM_getValue('MRPlayerMode') == 0) { document.getElementById('MRMenuNormalCheckbox').checked = true; document.getElementById('MRMenuNormalSwitch').style.pointerEvents = 'none'; document.getElementById('MRMenuAutoWidescreenSwitch').style.pointerEvents = ''; document.getElementById('MRMenuFullscreenSwitch').style.pointerEvents = ''; } else if (GM_getValue('MRPlayerMode') == 1) { document.getElementById('MRMenuAutoWidescreenCheckbox').checked = true; document.getElementById('MRMenuNormalSwitch').style.pointerEvents = ''; document.getElementById('MRMenuAutoWidescreenSwitch').style.pointerEvents = 'none'; document.getElementById('MRMenuFullscreenSwitch').style.pointerEvents = ''; } else if (GM_getValue('MRPlayerMode') == 2) { document.getElementById('MRMenuFullscreenCheckbox').checked = true; document.getElementById('MRMenuNormalSwitch').style.pointerEvents = ''; document.getElementById('MRMenuAutoWidescreenSwitch').style.pointerEvents = ''; document.getElementById('MRMenuFullscreenSwitch').style.pointerEvents = 'none'; } // 非网页全屏模式下禁用按钮 if (GM_getValue('MRPlayerMode') != 2) { // 移动导航栏到视频下方 disableBtn(document.getElementById('MRMenuMoveNavigationBarSwitch')); // 调整下方左右边距 disableBtn(document.getElementById('MRMenuDownLayoutPaddingSwitch')); // 将弹幕栏整合到播放器内 disableBtn(document.getElementById('MRMenuPutSendingBarInPlayerSwitch')); } // 自定义布局 // 移动导航栏到视频下方 if (GM_getValue('MRMenuMoveNavigationBar') == 1) { document.getElementById('MRMenuMoveNavigationBarCheckbox').checked = true; } // 隐藏新版反馈和旧版按钮 if (GM_getValue('MRMenuHideFeedbackBtn') == 1) { document.getElementById('MRMenuHideFeedbackBtnCheckbox').checked = true; } // 调整下方左右边距 if (GM_getValue('MRMenuDownLayoutPadding') == 1) { document.getElementById('MRMenuDownLayoutPaddingCheckbox').checked = true; } // 导航栏搜索框长度占满 if (GM_getValue('MRMenuDownLayoutSearchBarFull') == 1) { document.getElementById('MRMenuSearchBarFullCheckbox').checked = true; searchBarFull(); } // 将弹幕栏整合到播放器内 if (GM_getValue('MRMenuPutSendingBarInPlayer') == 1) { document.getElementById('MRMenuPutSendingBarInPlayerCheckbox').checked = true; } // 隐藏观看人数和弹幕装填信息 if (GM_getValue('MRMenuHideVideoInfo') == 1) { document.getElementById('MRMenuHideVideoInfoCheckbox').checked = true; } // 播放器内显示选集按钮 if (GM_getValue('MRMenuDisplayEplist') == 1) { document.getElementById('MRMenuDisplayEplistCheckbox').checked = true; } // 播放器内显示标题 if (GM_getValue('MRMenuDisplayTitle') == 1) { document.getElementById('MRMenuDisplayTitleCheckbox').checked = true; displayTitle(); } // 隐藏播放器内关注按钮 if (GM_getValue('MRMenuHideFollowBtn') == 1) { document.getElementById('MRMenuHideFollowBtnCheckbox').checked = true; } // 把标题和头像移到视频下方 if (GM_getValue('MRMenuMoveTitleAndUpinfo') == 1) { document.getElementById('MRMenuMoveTitleAndUpinfoCheckbox').checked = true; } // 隐藏导航栏标签 for (let i = 0; i < GM_getValue('MRMenuHideNavigationBarTag').split('').length; i++) { if (GM_getValue('MRMenuHideNavigationBarTag').split('')[i] == 1) { document.getElementById('MRMenuHideNavigationBarTag' + i + 'Checkbox').checked = true; } } hideNavigationBarTag(); // 实用功能与工具 // 菜单半透明 if (GM_getValue('MRMenuTransparent') != 1) { document.getElementById('MRMenuTransparentCheckbox').checked = true; } // 智能连播 if (GM_getValue('MRMenuSmartNextPlay') == 1) { document.getElementById('MRMenuSmartNextPlayCheckbox').checked = true; } // 播放器加载完毕后移动窗口到顶部 if (GM_getValue('MRMenuMoveWindowToTop') == 1) { document.getElementById('MRMenuMoveWindowToTopCheckbox').checked = true; // 刷新&重载网页后会记录当前位置, 例如网页全屏模式下没加载完成前可能会处于网页中部, 先移动一次窗口到顶部提升观感, 反正最后都要移到顶部, 多移动一次也无所谓啦 moveWindowToTop(); } // 去除宽屏模式左右黑边 if (GM_getValue('MRMenuRemoveWidescreenBlack') == 1) { document.getElementById('MRMenuRemoveWidescreenBlackCheckbox').checked = true; removeWidescreenBlack(); } // 总是开启或关闭弹幕 for (let i = 0; i < GM_getValue('MRMenuAlwaysDisableDnmaku').split('').length; i++) { if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[i] == 1) { document.getElementById('MRMenuAlwaysDisableDnmaku' + i + 'Checkbox').checked = true; } if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[0] == 0 && i != 0) { disableBtn(document.getElementById('MRMenuAlwaysDisableDnmaku' + i + 'Switch')); } } alwaysDisableDnmaku(); } // 注册MR菜单按钮/开关事件 function btnFunction() { // 关闭按钮 document.getElementById('MRMenuCloseBtn').addEventListener('click', function () { GM_setValue('MRMenuSwitch', 0); MRMenuElement.style.cssText += 'pointer-events: none; opacity: 0;'; if (document.getElementById('MRMenuReadme').style.display == 'flex') { document.getElementById('MRMenuReadme').style.display = 'none'; } }) // 播放器模式 // 默认模式 document.getElementById('MRMenuNormalSlider').addEventListener('click', function () { if (GM_getValue('MRPlayerMode') != 0) { if (GM_getValue('MRPlayerMode') == 1) { GM_setValue('MRPlayerMode', 0); autoWidescreen(); } else if (GM_getValue('MRPlayerMode') == 2) { GM_setValue('MRPlayerMode', 0); fullscreen(); autoWidescreen(); } //关闭其他按钮 document.getElementById('MRMenuAutoWidescreenCheckbox').checked = false; document.getElementById('MRMenuFullscreenCheckbox').checked = false; // 点击过后把当前按钮设为不可点击状态, 把其他按钮设成可点击状态 document.getElementById('MRMenuNormalSwitch').style.pointerEvents = 'none'; document.getElementById('MRMenuAutoWidescreenSwitch').style.pointerEvents = ''; document.getElementById('MRMenuFullscreenSwitch').style.pointerEvents = ''; // 移动导航栏到视频下方 disableBtn(document.getElementById('MRMenuMoveNavigationBarSwitch')); // 调整下方左右边距 disableBtn(document.getElementById('MRMenuDownLayoutPaddingSwitch')); // 将弹幕栏整合到播放器内 disableBtn(document.getElementById('MRMenuPutSendingBarInPlayerSwitch')); // 移动窗口到顶部 if (GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } // 把标题和头像移到视频下方 moveTitleAndUpinfo(); // 去除宽屏模式左右黑边 if (GM_getValue('MRMenuRemoveWidescreenBlack') == 1) { removeWidescreenBlack(); } } }) // 自动宽屏模式 document.getElementById('MRMenuAutoWidescreenSlider').addEventListener('click', function () { if (GM_getValue('MRPlayerMode') != 1) { if (GM_getValue('MRPlayerMode') == 2) { GM_setValue('MRPlayerMode', 1); fullscreen(); } else if (GM_getValue('MRPlayerMode') == 0) { GM_setValue('MRPlayerMode', 1); } //关闭其他按钮 document.getElementById('MRMenuNormalCheckbox').checked = false; document.getElementById('MRMenuFullscreenCheckbox').checked = false; autoWidescreen(); // 点击过后把当前按钮设为不可点击状态, 把其他按钮设成可点击状态 document.getElementById('MRMenuNormalSwitch').style.pointerEvents = ''; document.getElementById('MRMenuAutoWidescreenSwitch').style.pointerEvents = 'none'; document.getElementById('MRMenuFullscreenSwitch').style.pointerEvents = ''; // 移动导航栏到视频下方 disableBtn(document.getElementById('MRMenuMoveNavigationBarSwitch')); // 调整下方左右边距 disableBtn(document.getElementById('MRMenuDownLayoutPaddingSwitch')); // 将弹幕栏整合到播放器内 disableBtn(document.getElementById('MRMenuPutSendingBarInPlayerSwitch')); // 把标题和头像移到视频下方 moveTitleAndUpinfo(); // 去除宽屏模式左右黑边 if (GM_getValue('MRMenuRemoveWidescreenBlack') == 1) { removeWidescreenBlack(); } } }) // 网页全屏模式 document.getElementById('MRMenuFullscreenSlider').addEventListener('click', function () { if (GM_getValue('MRPlayerMode') != 2) { if (GM_getValue('MRPlayerMode') == 1) { GM_setValue('MRPlayerMode', 2); autoWidescreen(); } else if (GM_getValue('MRPlayerMode') == 0) { GM_setValue('MRPlayerMode', 2); autoWidescreen(); } //关闭其他按钮 document.getElementById('MRMenuNormalCheckbox').checked = false; document.getElementById('MRMenuAutoWidescreenCheckbox').checked = false; fullscreen(); // 点击过后把当前按钮设为不可点击状态, 把其他按钮设成可点击状态 document.getElementById('MRMenuNormalSwitch').style.pointerEvents = ''; document.getElementById('MRMenuAutoWidescreenSwitch').style.pointerEvents = ''; document.getElementById('MRMenuFullscreenSwitch').style.pointerEvents = 'none'; // 移动导航栏到视频下方 enableBtn(document.getElementById('MRMenuMoveNavigationBarSwitch')); // 调整下方左右边距 enableBtn(document.getElementById('MRMenuDownLayoutPaddingSwitch')); // 将弹幕栏整合到播放器内 enableBtn(document.getElementById('MRMenuPutSendingBarInPlayerSwitch')); // 把标题和头像移到视频下方 moveTitleAndUpinfo(); } }) // 自定义布局 // 移动导航栏到视频下方 document.getElementById('MRMenuMoveNavigationBarSlider').addEventListener('click', function () { if (GM_getValue('MRMenuMoveNavigationBar') == 0) { GM_setValue('MRMenuMoveNavigationBar', 1); moveNavigationBar(); } else { GM_setValue('MRMenuMoveNavigationBar', 0); moveNavigationBar(); } }) // 隐藏新版反馈和旧版按钮 document.getElementById('MRMenuHideFeedbackBtnSlider').addEventListener('click', function () { if (GM_getValue('MRMenuHideFeedbackBtn') == 0) { GM_setValue('MRMenuHideFeedbackBtn', 1); hideFeedbackBtn(); } else { GM_setValue('MRMenuHideFeedbackBtn', 0); hideFeedbackBtn(); } }) // 调整下方左右边距 document.getElementById('MRMenuDownLayoutPaddingSlider').addEventListener('click', function () { if (GM_getValue('MRMenuDownLayoutPadding') == 0) { GM_setValue('MRMenuDownLayoutPadding', 1); downLayoutPadding(); } else { GM_setValue('MRMenuDownLayoutPadding', 0); downLayoutPadding(); } }) // 导航栏搜索框长度占满 document.getElementById('MRMenuSearchBarFullSlider').addEventListener('click', function () { if (GM_getValue('MRMenuDownLayoutSearchBarFull') == 0) { GM_setValue('MRMenuDownLayoutSearchBarFull', 1); searchBarFull(); } else { GM_setValue('MRMenuDownLayoutSearchBarFull', 0); searchBarFull(); } }) // 将弹幕栏整合到播放器内 document.getElementById('MRMenuPutSendingBarInPlayerSlider').addEventListener('click', function () { if (GM_getValue('MRMenuPutSendingBarInPlayer') == 0) { GM_setValue('MRMenuPutSendingBarInPlayer', 1); putSendingBarInPlayer(); } else { GM_setValue('MRMenuPutSendingBarInPlayer', 0); putSendingBarInPlayer(); } }) // 隐藏观看人数和弹幕装填信息 document.getElementById('MRMenuHideVideoInfoSlider').addEventListener('click', function () { if (GM_getValue('MRMenuHideVideoInfo') == 0) { GM_setValue('MRMenuHideVideoInfo', 1); hideVideoInfo(); } else { GM_setValue('MRMenuHideVideoInfo', 0); hideVideoInfo(); } }) // 播放器内显示选集按钮 document.getElementById('MRMenuDisplayEplistSlider').addEventListener('click', function () { if (GM_getValue('MRMenuDisplayEplist') == 0) { GM_setValue('MRMenuDisplayEplist', 1); } else { GM_setValue('MRMenuDisplayEplist', 0); } }) // 播放器内显示标题 document.getElementById('MRMenuDisplayTitleSlider').addEventListener('click', function () { if (GM_getValue('MRMenuDisplayTitle') == 0) { GM_setValue('MRMenuDisplayTitle', 1); displayTitle(); } else { GM_setValue('MRMenuDisplayTitle', 0); displayTitle(); } }) // 隐藏播放器内关注按钮 document.getElementById('MRMenuHideFollowBtnSlider').addEventListener('click', function () { if (GM_getValue('MRMenuHideFollowBtn') == 0) { GM_setValue('MRMenuHideFollowBtn', 1); hideFollowBtn(); } else { GM_setValue('MRMenuHideFollowBtn', 0); hideFollowBtn(); } }) // 把标题和头像移到视频下方 document.getElementById('MRMenuMoveTitleAndUpinfoSlider').addEventListener('click', function () { if (GM_getValue('MRMenuMoveTitleAndUpinfo') == 0) { GM_setValue('MRMenuMoveTitleAndUpinfo', 1); moveTitleAndUpinfo(); } else { GM_setValue('MRMenuMoveTitleAndUpinfo', 0); moveTitleAndUpinfo(); } }) // 隐藏导航栏标签 for (let i = 0; i < GM_getValue('MRMenuHideNavigationBarTag').split('').length; i++) { document.getElementById('MRMenuHideNavigationBarTag' + i + 'Checkbox').addEventListener('click', function () { let num = this.id.replace(/[^0-9]/ig, ''); if (GM_getValue('MRMenuHideNavigationBarTag').split('')[num] == 0) { changeText('MRMenuHideNavigationBarTag', num, '1'); } else { changeText('MRMenuHideNavigationBarTag', num, '0'); } hideNavigationBarTag(); }) } // 实用功能与工具 // 菜单半透明 document.getElementById('MRMenuTransparentSlider').addEventListener('click', function () { if (GM_getValue('MRMenuTransparent') == 1) { GM_setValue('MRMenuTransparent', 0.7); } else { GM_setValue('MRMenuTransparent', 1); } MRMenuElement.style.cssText += 'opacity: ' + GM_getValue('MRMenuTransparent') + ';'; }) // 播放器加载完毕后移动窗口到顶部 document.getElementById('MRMenuMoveWindowToTopSlider').addEventListener('click', function () { if (GM_getValue('MRMenuMoveWindowToTop') == 0) { GM_setValue('MRMenuMoveWindowToTop', 1); moveWindowToTop(); } else { GM_setValue('MRMenuMoveWindowToTop', 0); } }) // 去除宽屏模式左右黑边 document.getElementById('MRMenuRemoveWidescreenBlackSlider').addEventListener('click', function () { if (GM_getValue('MRMenuRemoveWidescreenBlack') == 0) { GM_setValue('MRMenuRemoveWidescreenBlack', 1); removeWidescreenBlack(); } else { GM_setValue('MRMenuRemoveWidescreenBlack', 0); removeWidescreenBlack(); } }) // 智能连播 document.getElementById('MRMenuSmartNextPlaySlider').addEventListener('click', function () { if (GM_getValue('MRMenuSmartNextPlay') == 0) { GM_setValue('MRMenuSmartNextPlay', 1); smartNextPlay(); } else { GM_setValue('MRMenuSmartNextPlay', 0); smartNextPlay(); } }) // 总是开启或关闭弹幕 document.getElementById('MRMenuAlwaysDisableDnmaku0Checkbox').addEventListener('click', function () { if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[0] == 0) { changeText('MRMenuAlwaysDisableDnmaku', 0, '1'); enableBtn(document.getElementById('MRMenuAlwaysDisableDnmaku1Switch')); enableBtn(document.getElementById('MRMenuAlwaysDisableDnmaku2Switch')); } else { changeText('MRMenuAlwaysDisableDnmaku', 0, '0'); disableBtn(document.getElementById('MRMenuAlwaysDisableDnmaku1Switch')); disableBtn(document.getElementById('MRMenuAlwaysDisableDnmaku2Switch')); } }) document.getElementById('MRMenuAlwaysDisableDnmaku1Checkbox').addEventListener('click', function () { if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[1] == 0) { changeText('MRMenuAlwaysDisableDnmaku', 1, '1'); changeText('MRMenuAlwaysDisableDnmaku', 2, '0'); document.getElementById('MRMenuAlwaysDisableDnmaku2Checkbox').checked = false; document.getElementById('MRMenuAlwaysDisableDnmaku1Switch').style.pointerEvents = 'none'; document.getElementById('MRMenuAlwaysDisableDnmaku2Switch').style.pointerEvents = ''; } alwaysDisableDnmaku(); }) document.getElementById('MRMenuAlwaysDisableDnmaku2Checkbox').addEventListener('click', function () { if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[2] == 0) { changeText('MRMenuAlwaysDisableDnmaku', 2, '1'); changeText('MRMenuAlwaysDisableDnmaku', 1, '0'); document.getElementById('MRMenuAlwaysDisableDnmaku1Checkbox').checked = false; document.getElementById('MRMenuAlwaysDisableDnmaku1Switch').style.pointerEvents = ''; document.getElementById('MRMenuAlwaysDisableDnmaku2Switch').style.pointerEvents = 'none'; } alwaysDisableDnmaku(); }) } // 功能函数 // 播放模式 // 自动宽屏模式函数 function autoWidescreen() { autoWidescreenEtime = 0; if (GM_getValue('MRPlayerMode') == 1) { if (webStatus == 0) { // 视频 autoWidescreenBtn = 'bpx-player-ctrl-wide'; autoWidescreenisWidescreenClass = 'bpx-state-entered'; autoWidescreenClickBtn(); } if (webStatus == 1) { // 影视 autoWidescreenBtn = 'squirtle-video-widescreen'; autoWidescreenisWidescreenClass = 'active'; autoWidescreenClickBtn(); } if (webStatus == 2) { // 列表 autoWidescreenBtn = 'bilibili-player-video-btn-widescreen'; autoWidescreenisWidescreenClass = 'closed'; autoWidescreenClickBtn(); } // 判断是否存在并点击宽屏模式按钮 function autoWidescreenClickBtn() { console.log('[' + notificationScriptName + '-' + notificationCheck + '] ' + '自动宽屏模式 - 正在检测宽屏模式按钮是否加载完成'); autoWidescreenClickBtnCheck(); function autoWidescreenClickBtnCheck() { // 检测宽屏模式相关元素是否加载完毕 if (document.getElementsByClassName(autoWidescreenBtn)[0]) { // 如果当前不是宽屏模式则点击宽屏模式按钮 if (!document.getElementsByClassName(autoWidescreenBtn)[0].className.match(autoWidescreenisWidescreenClass)) { document.getElementsByClassName(autoWidescreenBtn)[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '自动宽屏模式 - 已开启宽屏模式'); // 移动窗口到顶部 if (GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } } else { console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '自动宽屏模式 - 当前已是宽屏模式'); } } else { // 每100毫秒检测一次, 8秒后不再执行 autoWidescreenEtime += 200; if (autoWidescreenEtime < etime) { setTimeout(autoWidescreenClickBtnCheck, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '自动宽屏模式 - 未检测到宽屏模式按钮, 检测超时, 停止检测'); } } } } } else { if (webStatus == 0) { // 视频 autoWidescreenBtn = 'bpx-player-ctrl-wide'; autoWidescreenisWidescreenClass = 'bpx-state-entered'; autoWidescreenDisableClickBtn(); } if (webStatus == 1) { // 影视 autoWidescreenBtn = 'squirtle-video-widescreen'; autoWidescreenisWidescreenClass = 'active'; autoWidescreenDisableClickBtn(); } if (webStatus == 2) { // 列表 autoWidescreenBtn = 'bilibili-player-video-btn-widescreen'; autoWidescreenisWidescreenClass = 'closed'; autoWidescreenDisableClickBtn(); } // 其他模式取消宽屏模式 // 判断是否存在并点击宽屏模式按钮 function autoWidescreenDisableClickBtn() { console.log('[' + notificationScriptName + '-' + notificationCheck + '] ' + '自动宽屏模式 - 正在检测宽屏模式按钮是否加载完成'); autoWidescreenDisableClickBtnCheck(); function autoWidescreenDisableClickBtnCheck() { // 检测宽屏模式相关元素是否加载完毕 if (document.getElementsByClassName(autoWidescreenBtn)[0]) { // 如果当前不是宽屏模式则点击宽屏模式按钮 if (document.getElementsByClassName(autoWidescreenBtn)[0].className.match(autoWidescreenisWidescreenClass)) { document.getElementsByClassName(autoWidescreenBtn)[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '自动宽屏模式 - 已关闭宽屏模式'); // 移动窗口到顶部 if (GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } } else { console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '自动宽屏模式 - 宽屏模式已是关闭状态'); } } else { // 每100毫秒检测一次, 8秒后不再执行 autoWidescreenEtime += 200; if (autoWidescreenEtime < etime) { setTimeout(autoWidescreenDisableClickBtnCheck, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '自动宽屏模式 - 未检测到宽屏模式按钮, 检测超时, 停止检测'); } } } } } } // 网页全屏模式函数 function fullscreen() { fullscreenEtime = 0; if (GM_getValue('MRPlayerMode') == 2) { if (webStatus == 0) { // 视频 fullscreenVideo(); } if (webStatus == 1) { // 影视 if (window.location.href.match('theme=movie')) { if (window.location.href.match('inline')) { // 电影 fullscreenMovie(); } else { // 电影有主题的页面 fullscreenMovie(); } } else { // 影视/番剧 fullscreenMovie(); } } if (webStatus == 2) { // 列表 fullscreenList(); } // 视频 function fullscreenVideo() { if (document.getElementsByClassName('bpx-player-ctrl-time-duration')[0] && loadReady) { if (GM_getValue('MRMenuMoveNavigationBar') == 0) { document.getElementById('bilibili-player').style.cssText += 'width: 100% !important; height: calc(100vh - 64px) !important;'; } else { document.getElementById('bilibili-player').style.cssText += 'width: 100% !important; height: 100vh !important;'; } document.getElementById('playerWrap').style.cssText += 'height: auto !important; z-index: 50 !important;'; // 移动播放器到上级 document.getElementById('app').insertBefore(document.getElementById('playerWrap'), document.getElementsByClassName('video-container-v1')[0]); // 移动弹幕栏到播放器下方 document.getElementById('playerWrap').appendChild(document.getElementsByClassName('bpx-player-sending-area')[0]); // 弹幕栏属性 document.getElementsByClassName('bpx-player-sending-area')[0].setAttribute('mr_always_display', 'true'); // 移动窗口到顶部 if (GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } // 移动导航栏到视频下方 if (GM_getValue('MRMenuMoveNavigationBar') == 1) { moveNavigationBar(); } // 调整下方左右边距 if (GM_getValue('MRMenuDownLayoutPadding') == 1) { downLayoutPadding(); } // 将弹幕栏整合到播放器内 if (GM_getValue('MRMenuPutSendingBarInPlayer') == 1) { putSendingBarInPlayer(); } // 隐藏宽屏模式和网页全屏按钮, 避免冲突 if (document.getElementsByClassName('bpx-player-ctrl-wide')[0]) { document.getElementsByClassName('bpx-player-ctrl-wide')[0].style.cssText += 'display: none'; document.getElementsByClassName('bpx-player-ctrl-web')[0].style.cssText += 'display: none'; } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenVideo, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 未检测到宽屏模式按钮, 检测超时, 停止检测'); } // 调整弹幕栏观看人数和弹幕装填信息宽度 document.getElementsByClassName('bpx-player-video-info')[0].style.cssText += 'width: auto'; // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '网页全屏模式 - 已开启网页全屏模式'); } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenVideo, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 视频组件未加载, 检测超时, 停止检测'); } } // 影视 function fullscreenMovie() { if (document.getElementsByClassName('squirtle-video-time-total')[0] && loadReady) { if (GM_getValue('MRMenuMoveNavigationBar') == 0) { document.getElementById('bilibili-player').style.cssText += 'width: 100% !important; height: calc(100vh - 64px) !important;'; } else { document.getElementById('bilibili-player').style.cssText += 'width: 100% !important; height: 100vh !important;'; } document.getElementById('player_module').setAttribute('mr_fullscreen', 'true'); document.getElementById('app').setAttribute('mr_fullscreen', 'true'); document.getElementsByClassName('plp-l')[0].setAttribute('mr_fullscreen', 'true'); document.getElementsByClassName('plp-r')[0].setAttribute('mr_fullscreen', 'true'); // 移动播放器到上级 document.body.insertBefore(document.getElementById('player_module'), document.getElementById('app')); // 移动弹幕栏到播放器下方 document.getElementsByClassName('stardust-player')[0].appendChild(document.getElementsByClassName('bpx-player-sending-area')[0]); // 弹幕栏属性 document.getElementsByClassName('bpx-player-sending-area')[0].setAttribute('mr_always_display', 'true'); // 隐藏电影主题背景 if (document.getElementsByClassName('special-cover')[0]) { document.getElementsByClassName('special-cover')[0].style.cssText += 'display: none'; } // 移动窗口到顶部 if (GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } // 移动导航栏到视频下方 if (GM_getValue('MRMenuMoveNavigationBar') == 1) { moveNavigationBar(); } // 调整下方左右边距 if (GM_getValue('MRMenuDownLayoutPadding') == 1) { downLayoutPadding(); } // 将弹幕栏整合到播放器内 if (GM_getValue('MRMenuPutSendingBarInPlayer') == 1) { putSendingBarInPlayer(); } // 隐藏宽屏模式和网页全屏按钮, 避免冲突 if (document.getElementsByClassName('squirtle-widescreen-wrap')[0]) { document.getElementsByClassName('squirtle-widescreen-wrap')[0].style.cssText += 'display: none'; document.getElementsByClassName('squirtle-pagefullscreen-wrap')[0].style.cssText += 'display: none'; } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenMovie, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 未检测到宽屏模式按钮, 检测超时, 停止检测'); } // 调整弹幕栏观看人数和弹幕装填信息宽度 document.getElementsByClassName('bpx-player-video-info')[0].setAttribute('mr_fullscreen', 'true'); // // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '网页全屏模式 - 已开启网页全屏模式'); } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenMovie, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 视频组件未加载, 检测超时, 停止检测'); } } // 列表 function fullscreenList() { if (document.getElementsByClassName('bilibili-player-video-time-total')[0] && document.getElementsByClassName('bilibili-player-video-inputbar')[0] && loadReady) { if (GM_getValue('MRMenuMoveNavigationBar') == 0) { document.getElementById('bilibili-player').style.cssText += 'width: 100% !important; height: calc(100vh - 60px) !important;'; } else { document.getElementById('bilibili-player').style.cssText += 'width: 100% !important; height: 100vh !important;'; } document.getElementById('video-player').style.cssText += 'width: 100% !important; height: 100vh !important; z-index: 50 !important;'; // 移动播放器到上级 document.getElementById('app').children[0].insertBefore(document.getElementById('video-player'), document.getElementsByClassName('v-wrap')[0]); // 移动弹幕栏到播放器下方 document.getElementById('app').children[0].insertBefore(document.getElementsByClassName('bilibili-player-video-bottom-area')[0], document.getElementsByClassName('v-wrap')[0]); // 弹幕栏属性 document.getElementsByClassName('bilibili-player-video-bottom-area')[0].setAttribute('mr_always_display', 'true'); // 移动窗口到顶部 if (GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } // 移动导航栏到视频下方 if (GM_getValue('MRMenuMoveNavigationBar') == 1) { moveNavigationBar(); } // 调整下方左右边距 if (GM_getValue('MRMenuDownLayoutPadding') == 1) { downLayoutPadding(); } // 将弹幕栏整合到播放器内 if (GM_getValue('MRMenuPutSendingBarInPlayer') == 1) { putSendingBarInPlayer(); } // 隐藏宽屏模式和网页全屏按钮, 避免冲突 if (document.getElementsByClassName('bilibili-player-video-btn-widescreen')[0]) { document.getElementsByClassName('bilibili-player-video-btn-widescreen')[0].style.cssText += 'display: none'; document.getElementsByClassName('bilibili-player-video-web-fullscreen')[0].style.cssText += 'display: none'; } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenList, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 未检测到宽屏模式按钮, 检测超时, 停止检测'); } // 调整弹幕栏观看人数和弹幕装填信息宽度 document.getElementsByClassName('bilibili-player-video-inputbar')[0].style.cssText += 'width: auto; max-width: 100%;'; // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '网页全屏模式 - 已开启网页全屏模式'); } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenList, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 视频组件未加载, 检测超时, 停止检测'); } } } else { if (webStatus == 0) { // 视频 fullscreenDisableVideo(); } if (webStatus == 1) { // 影视 if (window.location.href.match('theme=movie')) { if (window.location.href.match('inline')) { // 电影 fullscreenDisableMovie(); } else { // 电影有主题的页面 fullscreenDisableMovie(); } } else { // 影视/番剧 fullscreenDisableMovie(); } } if (webStatus == 2) { // 列表 fullscreenDisableList(); } // 视频 function fullscreenDisableVideo() { if (document.getElementsByClassName('bpx-player-sending-area')[0] && loadReady) { // 其他模式下恢复改变的布局 document.getElementById('bilibili-player').style.width = ''; document.getElementById('bilibili-player').style.height = ''; document.getElementById('playerWrap').style.height = ''; document.getElementById('playerWrap').style.zIndex = ''; // 移动播放器到初始位置 // 先移动到父类的最下面, 再移动到指定层级, 否则会报错 document.getElementsByClassName('left-container')[0].appendChild(document.getElementById('playerWrap')); document.getElementsByClassName('left-container')[0].insertBefore(document.getElementById('playerWrap'), document.getElementById('arc_toolbar_report')); // 移动弹幕栏到初始位置 document.getElementsByClassName('bpx-player-primary-area')[0].appendChild(document.getElementsByClassName('bpx-player-sending-area')[0]); // 弹幕栏属性 document.getElementsByClassName('bpx-player-sending-area')[0].setAttribute('mr_always_display', ''); // 移动窗口到顶部 if (GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } // 移动导航栏到视频下方 if (GM_getValue('MRMenuMoveNavigationBar') == 1) { moveNavigationBar(); } // 调整下方左右边距 if (GM_getValue('MRMenuDownLayoutPadding') == 1) { downLayoutPadding(); } // 将弹幕栏整合到播放器内 if (GM_getValue('MRMenuPutSendingBarInPlayer') == 1) { putSendingBarInPlayer(); } // 恢复显示宽屏模式按钮 if (document.getElementsByClassName('bpx-player-ctrl-wide')[0]) { document.getElementsByClassName('bpx-player-ctrl-wide')[0].style.cssText += 'display: block'; document.getElementsByClassName('bpx-player-ctrl-web')[0].style.cssText += 'display: block'; } else { setTimeout(fullscreenDisableVideo, 200); } // 调整弹幕栏观看人数和弹幕装填信息宽度 document.getElementsByClassName('bpx-player-video-info')[0].style.width = ''; // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '网页全屏模式 - 已关闭网页全屏模式'); } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenDisableVideo, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 检测超时, 停止检测'); } } // 影视 function fullscreenDisableMovie() { if (document.getElementsByClassName('squirtle-video-time-total')[0] && loadReady) { // 其他模式下恢复改变的布局 document.getElementById('bilibili-player').style.width = ''; document.getElementById('bilibili-player').style.height = ''; document.getElementById('player_module').setAttribute('mr_fullscreen', ''); document.getElementById('app').setAttribute('mr_fullscreen', ''); document.getElementsByClassName('plp-l')[0].setAttribute('mr_fullscreen', ''); document.getElementsByClassName('plp-r')[0].setAttribute('mr_fullscreen', ''); // 移动播放器到上级 document.getElementsByClassName('plp-l')[0].insertBefore(document.getElementById('player_module'), document.getElementsByClassName('media-wrapper')[0]); // 移动弹幕栏到播放器下方 document.getElementsByClassName('bpx-player-primary-area')[0].appendChild(document.getElementsByClassName('bpx-player-sending-area')[0]); // 弹幕栏属性 document.getElementsByClassName('bpx-player-sending-area')[0].setAttribute('mr_always_display', ''); // 隐藏电影主题背景 if (document.getElementsByClassName('special-cover')[0]) { document.getElementsByClassName('special-cover')[0].style.display = ''; } // 移动窗口到顶部 if (GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } // 移动导航栏到视频下方 if (GM_getValue('MRMenuMoveNavigationBar') == 1) { moveNavigationBar(); } // 调整下方左右边距 if (GM_getValue('MRMenuDownLayoutPadding') == 1) { downLayoutPadding(); } // 将弹幕栏整合到播放器内 if (GM_getValue('MRMenuPutSendingBarInPlayer') == 1) { putSendingBarInPlayer(); } // 恢复显示宽屏模式按钮 if (document.getElementsByClassName('squirtle-widescreen-wrap')[0]) { document.getElementsByClassName('squirtle-widescreen-wrap')[0].style.cssText += 'display: block'; document.getElementsByClassName('squirtle-pagefullscreen-wrap')[0].style.cssText += 'display: block'; } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenDisableMovie, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 未检测到宽屏模式按钮, 检测超时, 停止检测'); } // 调整弹幕栏观看人数和弹幕装填信息宽度 document.getElementsByClassName('bpx-player-video-info')[0].setAttribute('mr', ''); // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '网页全屏模式 - 已开启网页全屏模式'); } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenDisableMovie, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 视频组件未加载, 检测超时, 停止检测'); } } // 列表 function fullscreenDisableList() { if (document.getElementsByClassName('bilibili-player-video-time-total')[0] && document.getElementsByClassName('bilibili-player-video-inputbar')[0] && loadReady) { // 其他模式下恢复改变的布局 document.getElementById('bilibili-player').style.width = ''; document.getElementById('bilibili-player').style.height = ''; document.getElementById('video-player').style.width = ''; document.getElementById('video-player').style.height = ''; document.getElementById('video-player').style.zIndex = ''; // 移动播放器到上级 document.getElementsByClassName('l-con')[0].insertBefore(document.getElementById('video-player'), document.getElementsByClassName('video-toolbar')[0]); // 移动弹幕栏到播放器下方 document.getElementsByClassName('bilibili-player-area')[0].appendChild(document.getElementsByClassName('bilibili-player-video-bottom-area')[0]); // 弹幕栏属性 document.getElementsByClassName('bilibili-player-video-bottom-area')[0].setAttribute('mr_always_display', ''); // 移动窗口到顶部 if (GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } // 移动导航栏到视频下方 if (GM_getValue('MRMenuMoveNavigationBar') == 1) { moveNavigationBar(); } // 调整下方左右边距 if (GM_getValue('MRMenuDownLayoutPadding') == 1) { downLayoutPadding(); } // 将弹幕栏整合到播放器内 if (GM_getValue('MRMenuPutSendingBarInPlayer') == 1) { putSendingBarInPlayer(); } // 隐藏宽屏模式和网页全屏按钮, 避免冲突 if (document.getElementsByClassName('bilibili-player-video-btn-widescreen')[0]) { document.getElementsByClassName('bilibili-player-video-btn-widescreen')[0].style.cssText += 'display: block'; document.getElementsByClassName('bilibili-player-video-web-fullscreen')[0].style.cssText += 'display: block'; } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenDisableList, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 未检测到宽屏模式按钮, 检测超时, 停止检测'); } // 调整弹幕栏观看人数和弹幕装填信息宽度 document.getElementsByClassName('bilibili-player-video-inputbar')[0].style.width = ''; document.getElementsByClassName('bilibili-player-video-inputbar')[0].style.maxWidth = ''; // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '网页全屏模式 - 已开启网页全屏模式'); } else if (fullscreenEtime < etime) { fullscreenEtime += 200; setTimeout(fullscreenDisableList, 200); } else { console.log('[' + notificationScriptName + '-' + notificationWarning + '] ' + '网页全屏模式 - 视频组件未加载, 检测超时, 停止检测'); } } } } // 自定义布局 // 移动导航栏到视频下方 function moveNavigationBar() { moveNavigationBarEtime = 0; if (webStatus == 0) { // 视频 moveNavigationBarVideoCheck(); } else if (webStatus == 1) { // 影视 if (window.location.href.match('theme=movie')) { if (window.location.href.match('inline')) { // 电影 moveNavigationBarMovieCheck(); } else { // 电影有主题的页面 moveNavigationBarMovieCheck(); } } else { // 影视/番剧 moveNavigationBarMovieCheck(); } } else if (webStatus == 2) { // 列表 moveNavigationBarListCheck(); } // 视频 function moveNavigationBarVideoCheck() { if (document.getElementById('bilibili-player') && loadReady) { if (GM_getValue('MRPlayerMode') == 2) { if (GM_getValue('MRMenuMoveNavigationBar') == 0) { document.getElementsByClassName('bili-header__bar mini-header')[0].style.position = ''; document.getElementsByClassName('bili-header__bar mini-header')[0].style.zIndex = ''; document.getElementById('app').insertBefore(document.getElementById('biliMainHeader'), document.getElementById('playerWrap')); document.getElementById('bilibili-player').style.cssText += 'height: calc(100vh - 64px) !important;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '移动导航栏到视频下方 - 导航栏已恢复'); } else { document.getElementsByClassName('bili-header__bar mini-header')[0].style.cssText += 'position: relative !important; z-index: 10 !important;'; document.getElementById('app').insertBefore(document.getElementById('biliMainHeader'), document.getElementsByClassName('video-container-v1')[0]); document.getElementById('bilibili-player').style.cssText += 'height: 100vh !important;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '移动导航栏到视频下方 - 导航栏移动完毕'); } } else { document.getElementsByClassName('bili-header__bar mini-header')[0].style.position = ''; document.getElementsByClassName('bili-header__bar mini-header')[0].style.zIndex = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '移动导航栏到视频下方 - 导航栏已恢复'); } } else if (moveNavigationBarEtime < etime) { moveNavigationBar += 200; setTimeout(moveNavigationBarVideoCheck, 200); } } // 影视 function moveNavigationBarMovieCheck() { if (document.getElementById('bilibili-player') && loadReady) { if (GM_getValue('MRPlayerMode') == 2) { if (GM_getValue('MRMenuMoveNavigationBar') == 0) { document.getElementsByClassName('bili-header__bar mini-header')[0].style.position = ''; document.getElementsByClassName('bili-header__bar mini-header')[0].style.zIndex = ''; document.getElementById('ogvVideoHeader').appendChild(document.getElementById('biliMainHeader')); document.getElementById('bilibili-player').style.cssText += 'height: calc(100vh - 64px) !important;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '移动导航栏到视频下方 - 导航栏已恢复'); } else { document.getElementsByClassName('bili-header__bar mini-header')[0].style.cssText += 'position: relative !important; z-index: 10 !important;'; document.body.insertBefore(document.getElementById('biliMainHeader'), document.getElementById('app')); document.getElementById('bilibili-player').style.cssText += 'height: 100vh !important;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '移动导航栏到视频下方 - 导航栏移动完毕'); } } else { document.getElementsByClassName('bili-header__bar mini-header')[0].style.position = ''; document.getElementsByClassName('bili-header__bar mini-header')[0].style.zIndex = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '移动导航栏到视频下方 - 导航栏已恢复'); } } else if (moveNavigationBarEtime < etime) { moveNavigationBar += 200; setTimeout(moveNavigationBarMovieCheck, 200); } } // 列表 function moveNavigationBarListCheck() { if (document.getElementById('bilibili-player') && document.getElementById('internationalHeader') && loadReady) { if (GM_getValue('MRPlayerMode') == 2) { if (GM_getValue('MRMenuMoveNavigationBar') == 0) { document.body.insertBefore(document.getElementById('internationalHeader'), document.getElementById('app')); document.getElementById('bilibili-player').style.cssText += 'height: calc(100vh - 60px) !important;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '移动导航栏到视频下方 - 导航栏已恢复'); } else { document.getElementById('app').children[0].insertBefore(document.getElementById('internationalHeader'), document.getElementsByClassName('v-wrap')[0]); document.getElementById('bilibili-player').style.cssText += 'height: 100vh !important;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '移动导航栏到视频下方 - 导航栏移动完毕'); } } else { console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '移动导航栏到视频下方 - 导航栏已恢复'); } } else if (moveNavigationBarEtime < etime) { moveNavigationBar += 200; setTimeout(moveNavigationBarListCheck, 200); } } } // 隐藏新版反馈和回到旧版按钮 function hideFeedbackBtn() { hideFeedbackBtnEtime = 0; let btn = ''; if (webStatus == 0) { // 视频 btn = 'fixed-nav'; hideFeedbackBtnVideoCheck(); } else if (webStatus == 4) { // 搜索 btn = 'side-buttons'; hideFeedbackBtnHomeCheck(); } else if (webStatus == 5) { // 主页 btn = 'palette-button-wrap'; hideFeedbackBtnHomeCheck(); } // 视频 function hideFeedbackBtnVideoCheck() { if (document.getElementsByClassName(btn)[0]) { if (GM_getValue('MRMenuHideFeedbackBtn') == 1) { document.getElementsByClassName(btn)[0].style.cssText += 'display: none'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '隐藏新版反馈和回到旧版按钮 - 已隐藏新版反馈和回到旧版按钮'); } else { document.getElementsByClassName(btn)[0].style.cssText += 'display: block'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '隐藏新版反馈和回到旧版按钮 - 已显示新版反馈和回到旧版按钮'); } } else if (hideFeedbackBtnEtime < etime) { hideFeedbackBtnEtime += 200; setTimeout(hideFeedbackBtnVideoCheck, 200); } } // 搜索和主页 function hideFeedbackBtnHomeCheck() { if (document.getElementsByClassName(btn)[0]) { let btnElement = document.getElementsByClassName(btn)[0]; for (let i = 0; i < btnElement.children.length; i++) { if (i != btnElement.children.length - 1) { if (GM_getValue('MRMenuHideFeedbackBtn') == 1) { btnElement.children[i].style.cssText += 'display: none'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '隐藏新版反馈和回到旧版按钮 - 已隐藏新版反馈和回到旧版按钮'); } else { btnElement.children[i].style.cssText += 'display: block'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '隐藏新版反馈和回到旧版按钮 - 已显示新版反馈和回到旧版按钮'); } } } } else if (hideFeedbackBtnEtime < etime) { hideFeedbackBtnEtime += 200; setTimeout(hideFeedbackBtnHomeCheck, 200); } } } // 调整下方左右边距 function downLayoutPadding() { downLayoutPaddingEtime = 0; if (webStatus == 0) { // 视频 downLayoutPaddingVideoCheck(); } else if (webStatus == 1) { // 影视 downLayoutPaddingMovieCheck(); } else if (webStatus == 2) { // 列表 downLayoutPaddingListCheck(); } // 视频 function downLayoutPaddingVideoCheck() { if (document.getElementsByClassName('left-container')[0]) { if (GM_getValue('MRMenuDownLayoutPadding') == 1) { if (GM_getValue('MRPlayerMode') == 2) { document.getElementsByClassName('video-container-v1')[0].style.cssText += 'justify-content: space-between; padding: 0px 20px 0px 20px;'; document.getElementsByClassName('left-container')[0].style.cssText += 'width: 100%;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '调整下方左右边距 - 下方左右边距调整完毕'); } else { document.getElementsByClassName('video-container-v1')[0].style.justifyContent = ''; document.getElementsByClassName('video-container-v1')[0].style.padding = ''; document.getElementsByClassName('left-container')[0].style.width = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '调整下方左右边距 - 下方左右边距已恢复'); } } else { document.getElementsByClassName('video-container-v1')[0].style.justifyContent = ''; document.getElementsByClassName('video-container-v1')[0].style.padding = ''; document.getElementsByClassName('left-container')[0].style.width = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '调整下方左右边距 - 下方左右边距已恢复'); } } else if (downLayoutPaddingEtime < etime) { downLayoutPaddingEtime += 200; setTimeout(downLayoutPaddingVideoCheck, 200); } } // 影视 function downLayoutPaddingMovieCheck() { if (document.getElementsByClassName('plp-l')[0]) { if (GM_getValue('MRMenuDownLayoutPadding') == 1) { if (GM_getValue('MRPlayerMode') == 2) { document.getElementById('app').setAttribute('mr_margin_fix', 'true'); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '调整下方左右边距 - 下方左右边距调整完毕'); } else { document.getElementById('app').setAttribute('mr_margin_fix', ''); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '调整下方左右边距 - 下方左右边距已恢复'); } } else { document.getElementById('app').setAttribute('mr_margin_fix', ''); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '调整下方左右边距 - 下方左右边距已恢复'); } } else if (downLayoutPaddingEtime < etime) { downLayoutPaddingEtime += 200; setTimeout(downLayoutPaddingMovieCheck, 200); } } // 列表 function downLayoutPaddingListCheck() { if (document.getElementsByClassName('l-con')[0]) { if (GM_getValue('MRMenuDownLayoutPadding') == 1) { if (GM_getValue('MRPlayerMode') == 2) { document.getElementsByClassName('v-wrap')[0].style.cssText += 'width: auto; padding: 0px 20px 0px 20px;'; document.getElementsByClassName('l-con')[0].style.cssText += 'width: 100%;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '调整下方左右边距 - 下方左右边距调整完毕'); } else { document.getElementsByClassName('v-wrap')[0].style.width = ''; document.getElementsByClassName('v-wrap')[0].style.padding = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '调整下方左右边距 - 下方左右边距已恢复'); } } else { document.getElementsByClassName('v-wrap')[0].style.width = ''; document.getElementsByClassName('v-wrap')[0].style.padding = ''; document.getElementsByClassName('l-con')[0].style.width = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '调整下方左右边距 - 下方左右边距已恢复'); } } else if (downLayoutPaddingEtime < etime) { downLayoutPaddingEtime += 200; setTimeout(downLayoutPaddingListCheck, 200); } } } // 导航栏搜索框长度占满 function searchBarFull() { searchBarFullEtime = 0; let btn = ''; if (webStatus == 0 || webStatus == 1 || webStatus == 3 || webStatus == 5) { // 视频/影视/空间/主页 btn = 'center-search__bar'; searchBarFullVideoCheck(); } else if (webStatus == 2 || webStatus == 7) { // 列表/个人中心 btn = 'nav-search-box'; searchBarFullListCheck(); } // 视频/影视/空间/主页 function searchBarFullVideoCheck() { if (document.getElementsByClassName(btn)[0]) { if (GM_getValue('MRMenuDownLayoutSearchBarFull') == 1) { document.getElementsByClassName(btn)[0].style.cssText += 'max-width: 100%'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '导航栏搜索框长度占满 - 导航栏搜索框长度调整完毕'); } else { document.getElementsByClassName(btn)[0].style.maxWidth = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '导航栏搜索框长度占满 - 导航栏搜索框长度已恢复'); } } else if (searchBarFullEtime < etime) { searchBarFullEtime += 200; setTimeout(searchBarFullVideoCheck, 200); } } // 列表 function searchBarFullListCheck() { if (document.getElementsByClassName(btn)[0]) { if (GM_getValue('MRMenuDownLayoutSearchBarFull') == 1) { document.getElementsByClassName(btn)[0].style.cssText += 'width: 100%; display: block;'; document.getElementsByClassName(btn)[0].style.cssText += 'width: 100%; display: block;'; document.getElementsByClassName('search-icon')[0].style.cssText += 'display: none;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '导航栏搜索框长度占满 - 导航栏搜索框长度调整完毕'); } else { document.getElementsByClassName(btn)[0].style.width = ''; document.getElementsByClassName(btn)[0].style.display = ''; document.getElementsByClassName('search-icon')[0].style.display = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '导航栏搜索框长度占满 - 导航栏搜索框长度已恢复'); } } else if (searchBarFullEtime < etime) { searchBarFullEtime += 200; setTimeout(searchBarFullListCheck, 200); } } } // 将弹幕栏整合到播放器内 function putSendingBarInPlayer() { putSendingBarInPlayerEtime = 0; if (webStatus == 0) { // 视频 putSendingBarInPlayerVideoCheck(); } else if (webStatus == 1) { // 影视 putSendingBarInPlayerMovieCheck(); } else if (webStatus == 2) { // 列表 putSendingBarInPlayerListCheck(); } // 视频 function putSendingBarInPlayerVideoCheck() { if (document.getElementsByClassName('bpx-player-dm-wrap')[0] && document.getElementsByClassName('bpx-player-dm-hint')[0]) { if (GM_getValue('MRPlayerMode') == 2) { if (GM_getValue('MRMenuPutSendingBarInPlayer') == 1) { putSendingBarInPlayerVideoEnable(); // 移动弹幕栏到播放器内 document.getElementsByClassName('bpx-player-control-bottom-center')[0].appendChild(document.getElementsByClassName('bpx-player-sending-area')[0]); } else { putSendingBarInPlayerVideoDisable(); // 移动弹幕栏到初始位置 document.getElementById('playerWrap').appendChild(document.getElementsByClassName('bpx-player-sending-area')[0]); } } else { putSendingBarInPlayerVideoDisable(); // 移动弹幕栏到初始位置 document.getElementsByClassName('bpx-player-primary-area')[0].appendChild(document.getElementsByClassName('bpx-player-sending-area')[0]); } function putSendingBarInPlayerVideoEnable() { // 调整播放器底部空间中间宽度 document.getElementsByClassName('bpx-player-control-bottom-center')[0].style.cssText += 'width: 50%; height: 34px; line-height: 34px;'; // 隐藏白线 document.getElementsByClassName('bpx-player-sending-area')[0].setAttribute('mr_inside_player', 'true'); // 弹幕栏整体样式 document.getElementsByClassName('bpx-player-sending-bar')[0].style.cssText += 'background: none; height: 34px; line-height: 34px; padding: 0px 20px 0px 0px; margin: -6px 0px 0px 0px;'; // 观看人数和弹幕装填信息 document.getElementsByClassName('bpx-player-video-info')[0].style.cssText += 'color: hsla(0,0%,100%,.8);'; // 弹幕开关, 适配DarkReader if (document.getElementsByTagName('html')[0].getAttribute('data-darkreader-scheme') != 'dark') { document.getElementsByClassName('bui-danmaku-switch')[0].style.cssText += 'fill: hsla(0,0%,100%,.9);'; } // 弹幕设置 if (document.getElementsByTagName('html')[0].getAttribute('data-darkreader-scheme') != 'dark') { document.getElementsByClassName('bpx-player-dm-setting')[0].style.cssText += 'fill: hsla(0,0%,100%,.9);'; } // 弹幕发送框背景 document.getElementsByClassName('bpx-player-video-inputbar')[0].style.cssText += 'width: auto; background: hsla(0,0%,100%,0.6);'; // 弹幕样式按钮样式 document.getElementsByClassName('bpx-player-video-btn-dm')[0].style.cssText += 'fill: hsla(0,0%,100%,.9);'; // 弹幕发送框文本样式 document.getElementsByClassName('bpx-player-dm-input')[0].style.cssText += 'color: hsla(0,0%,100%,.6);'; document.getElementsByClassName('bpx-player-dm-input')[0].setAttribute('mr_inside_player', 'true'); // 弹幕礼仪按钮 document.getElementsByClassName('bpx-player-dm-hint')[0].children[0].children[0].style.cssText += 'color: hsla(0,0%,100%,.6);'; document.getElementsByClassName('bpx-player-dm-hint')[0].children[0].children[1].style.cssText += 'fill: hsla(0,0%,100%,.6);'; // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '将弹幕栏整合到播放器内 - 已将弹幕栏整合到播放器内'); } function putSendingBarInPlayerVideoDisable() { // 调整播放器底部空间中间宽度 document.getElementsByClassName('bpx-player-control-bottom-center')[0].style.width = ''; document.getElementsByClassName('bpx-player-control-bottom-center')[0].style.height = ''; document.getElementsByClassName('bpx-player-control-bottom-center')[0].style.lineHeight = ''; // 隐藏白线 document.getElementsByClassName('bpx-player-sending-area')[0].setAttribute('mr_inside_player', '') // 弹幕栏整体样式 document.getElementsByClassName('bpx-player-sending-bar')[0].style.background = ''; document.getElementsByClassName('bpx-player-sending-bar')[0].style.height = ''; document.getElementsByClassName('bpx-player-sending-bar')[0].style.lineHeight = ''; document.getElementsByClassName('bpx-player-sending-bar')[0].style.padding = ''; document.getElementsByClassName('bpx-player-sending-bar')[0].style.margin = ''; // 观看人数和弹幕装填信息 document.getElementsByClassName('bpx-player-video-info')[0].style.color = ''; // 弹幕开关 document.getElementsByClassName('bui-danmaku-switch')[0].style.fill = ''; // 弹幕设置 document.getElementsByClassName('bpx-player-dm-setting')[0].style.fill = ''; // 弹幕发送框背景 document.getElementsByClassName('bpx-player-video-inputbar')[0].style.width = ''; document.getElementsByClassName('bpx-player-video-inputbar')[0].style.background = ''; // 弹幕样式按钮样式 document.getElementsByClassName('bpx-player-video-btn-dm')[0].style.fill = ''; // 弹幕发送框文本样式 document.getElementsByClassName('bpx-player-dm-input')[0].style.color = ''; document.getElementsByClassName('bpx-player-dm-input')[0].setAttribute('mr_inside_player', '') // 弹幕礼仪按钮 document.getElementsByClassName('bpx-player-dm-hint')[0].children[0].children[0].style.color = ''; document.getElementsByClassName('bpx-player-dm-hint')[0].children[0].children[1].style.fill = ''; // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '将弹幕栏整合到播放器内 - 弹幕栏位置已恢复'); } } else if (putSendingBarInPlayerEtime < etime) { putSendingBarInPlayerEtime += 200; setTimeout(putSendingBarInPlayerVideoCheck, 200); } } // 影视 function putSendingBarInPlayerMovieCheck() { if (document.getElementsByClassName('bpx-player-dm-wrap')[0] && document.getElementsByClassName('bpx-player-dm-hint')[0]) { if (GM_getValue('MRPlayerMode') == 2) { if (GM_getValue('MRMenuPutSendingBarInPlayer') == 1) { putSendingBarInPlayerMovieEnable(); // 移动弹幕栏到播放器内 document.getElementsByClassName('squirtle-controller-wrap-center')[0].appendChild(document.getElementsByClassName('bpx-player-sending-area')[0]); } else { putSendingBarInPlayerMovieDisable(); document.getElementsByClassName('stardust-player')[0].appendChild(document.getElementsByClassName('bpx-player-sending-area')[0]); } } else { putSendingBarInPlayerMovieDisable(); // 移动弹幕栏到原位 document.getElementsByClassName('squirtle-controller-wrap-center')[0].appendChild(document.getElementsByClassName('bpx-player-sending-area')[0]); } function putSendingBarInPlayerMovieEnable() { // 隐藏白线 document.getElementsByClassName('bpx-player-sending-area')[0].setAttribute('mr_inside_player', 'true'); // 弹幕栏整体样式 document.getElementsByClassName('bpx-player-sending-bar')[0].style.cssText += 'background: none; width: auto;'; // 观看人数和弹幕装填信息 document.getElementsByClassName('bpx-player-video-info')[0].style.cssText += 'color: hsla(0,0%,100%,.8);'; // 弹幕设置 if (document.getElementsByTagName('html')[0].getAttribute('data-darkreader-scheme') != 'dark') { document.getElementsByClassName('bpx-player-dm-setting')[0].style.cssText += 'fill: hsla(0,0%,100%,.9);'; } // 弹幕发送框背景 document.getElementsByClassName('bpx-player-video-inputbar')[0].style.cssText += 'width: auto; background: hsla(0,0%,100%,0.6);'; // 弹幕发送框描边 document.getElementsByClassName('bpx-player-video-inputbar-wrap')[0].style.cssText += 'border: 0; width: auto;'; // 弹幕样式按钮样式 document.getElementsByClassName('bpx-player-video-btn-dm')[0].style.cssText += 'fill: hsla(0,0%,100%,.9);'; // 弹幕发送框文本样式 document.getElementsByClassName('bpx-player-dm-input')[0].style.cssText += 'color: hsla(0,0%,100%,.6);'; document.getElementsByClassName('bpx-player-dm-input')[0].setAttribute('mr_inside_player', 'true'); // 弹幕礼仪按钮 document.getElementsByClassName('bpx-player-dm-hint')[0].children[0].children[0].style.cssText += 'color: hsla(0,0%,100%,.6);'; document.getElementsByClassName('bpx-player-dm-hint')[0].children[0].children[1].style.cssText += 'fill: hsla(0,0%,100%,.6);'; // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '将弹幕栏整合到播放器内 - 已将弹幕栏整合到播放器内'); } function putSendingBarInPlayerMovieDisable() { // 隐藏白线 document.getElementsByClassName('bpx-player-sending-area')[0].setAttribute('mr_inside_player', ''); // 弹幕栏整体样式 document.getElementsByClassName('bpx-player-sending-bar')[0].style.background = ''; document.getElementsByClassName('bpx-player-sending-bar')[0].style.width = ''; // 观看人数和弹幕装填信息 document.getElementsByClassName('bpx-player-video-info')[0].style.color = ''; // 弹幕设置 document.getElementsByClassName('bpx-player-dm-setting')[0].style.fill = ''; // 弹幕发送框背景 document.getElementsByClassName('bpx-player-video-inputbar')[0].style.width = ''; document.getElementsByClassName('bpx-player-video-inputbar')[0].style.background = ''; // 弹幕发送框描边 document.getElementsByClassName('bpx-player-video-inputbar-wrap')[0].style.border = ''; // 弹幕样式按钮样式 document.getElementsByClassName('bpx-player-video-btn-dm')[0].style.fill = ''; // 弹幕发送框文本样式 document.getElementsByClassName('bpx-player-dm-input')[0].style.color = ''; document.getElementsByClassName('bpx-player-dm-input')[0].setAttribute('mr_inside_player', ''); // 弹幕礼仪按钮 document.getElementsByClassName('bpx-player-dm-hint')[0].children[0].children[0].style.color = ''; document.getElementsByClassName('bpx-player-dm-hint')[0].children[0].children[1].style.fill = ''; // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '将弹幕栏整合到播放器内 - 已将弹幕栏整合到播放器内'); } } else if (putSendingBarInPlayerEtime < etime) { putSendingBarInPlayerEtime += 200; setTimeout(putSendingBarInPlayerMovieCheck, 200); } } // 列表 function putSendingBarInPlayerListCheck() { if (document.getElementsByClassName('bilibili-player-video-danmaku-wrap')[0] && document.getElementsByClassName('bilibili-player-video-hint')[0]) { if (GM_getValue('MRPlayerMode') == 2) { if (GM_getValue('MRMenuPutSendingBarInPlayer') == 1) { putSendingBarInPlayerListEnable(); // 移动弹幕栏到播放器内 document.getElementsByClassName('bilibili-player-video-control-bottom-center')[0].appendChild(document.getElementsByClassName('bilibili-player-video-bottom-area')[0]); } else { putSendingBarInPlayerListDisable(); if (GM_getValue('MRMenuMoveNavigationBar') == 0) { document.getElementById('app').insertBefore(document.getElementsByClassName('bilibili-player-video-bottom-area')[0], document.getElementsByClassName('v-wrap')[0]); } else { document.getElementById('app').insertBefore(document.getElementsByClassName('bilibili-player-video-bottom-area')[0], document.getElementById('internationalHeader')); } } } else { putSendingBarInPlayerListDisable(); // 移动弹幕栏到原位 document.getElementsByClassName('bilibili-player-area')[0].appendChild(document.getElementsByClassName('bilibili-player-video-bottom-area')[0]); } function putSendingBarInPlayerListEnable() { // 调整播放器底部空间中间宽度 document.getElementsByClassName('bilibili-player-video-control-bottom-center')[0].style.cssText += 'width: auto;'; // 隐藏白线 document.getElementsByClassName('bilibili-player-video-bottom-area')[0].setAttribute('mr_inside_player', 'true'); // 弹幕栏整体样式 document.getElementsByClassName('bilibili-player-video-sendbar')[0].style.cssText += 'background: none; padding: 0px 20px 0px 0px; margin: -12px 0px 0px 0px;'; // 观看人数和弹幕装填信息 document.getElementsByClassName('bilibili-player-video-info')[0].style.cssText += 'color: hsla(0,0%,100%,.8);'; // 弹幕设置 document.getElementsByClassName('bilibili-player-video-danmaku-setting')[0].style.cssText += 'fill: hsla(0,0%,100%,.9);'; // 弹幕发送框背景 document.getElementsByClassName('bilibili-player-video-inputbar')[0].style.cssText += 'background: hsla(0,0%,100%,0.6);'; // 弹幕发送框边框 document.getElementsByClassName('bilibili-player-video-inputbar-wrap')[0].style.cssText += 'border: 0; width: auto;'; // 弹幕样式按钮样式 document.getElementsByClassName('bilibili-player-video-btn-danmaku')[0].style.cssText += 'fill: hsla(0,0%,100%,.9); margin: 4px 0px 0px 0px;'; // 弹幕发送框文本样式 document.getElementsByClassName('bilibili-player-video-danmaku-input')[0].style.cssText += 'color: hsla(0,0%,100%,.6);'; document.getElementsByClassName('bilibili-player-video-danmaku-input')[0].setAttribute('mr_inside_player', 'true'); // 弹幕礼仪按钮 document.getElementsByClassName('bilibili-player-video-hint')[0].children[0].children[0].style.cssText += 'color: hsla(0,0%,100%,.6);'; document.getElementsByClassName('bilibili-player-video-hint')[0].children[0].children[1].style.cssText += 'fill: hsla(0,0%,100%,.6);'; // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '将弹幕栏整合到播放器内 - 已将弹幕栏整合到播放器内'); } function putSendingBarInPlayerListDisable() { // 调整播放器底部空间中间宽度 document.getElementsByClassName('bilibili-player-video-control-bottom-center')[0].style.width = ''; // 隐藏白线 document.getElementsByClassName('bilibili-player-video-bottom-area')[0].setAttribute('mr_inside_player', ''); // 弹幕栏整体样式 document.getElementsByClassName('bilibili-player-video-sendbar')[0].style.background = ''; document.getElementsByClassName('bilibili-player-video-sendbar')[0].style.padding = ''; document.getElementsByClassName('bilibili-player-video-sendbar')[0].style.margin = ''; // 观看人数和弹幕装填信息 document.getElementsByClassName('bilibili-player-video-info')[0].style.color = ''; // 弹幕设置 document.getElementsByClassName('bilibili-player-video-danmaku-setting')[0].style.fill = ''; // 弹幕发送框背景 document.getElementsByClassName('bilibili-player-video-inputbar')[0].style.background = ''; // 弹幕发送框边框 document.getElementsByClassName('bilibili-player-video-inputbar-wrap')[0].style.border = ''; // 弹幕样式按钮样式 document.getElementsByClassName('bilibili-player-video-btn-danmaku')[0].style.fill = ''; document.getElementsByClassName('bilibili-player-video-btn-danmaku')[0].style.margin = ''; // 弹幕发送框文本样式 document.getElementsByClassName('bilibili-player-video-danmaku-input')[0].style.color = ''; document.getElementsByClassName('bilibili-player-video-danmaku-input')[0].setAttribute('mr_inside_player', ''); // 弹幕礼仪按钮 document.getElementsByClassName('bilibili-player-video-hint')[0].children[0].children[0].style.color = ''; document.getElementsByClassName('bilibili-player-video-hint')[0].children[0].children[1].style.fill = ''; // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '将弹幕栏整合到播放器内 - 已将弹幕栏整合到播放器内'); } } else if (putSendingBarInPlayerEtime < etime) { putSendingBarInPlayerEtime += 200; setTimeout(putSendingBarInPlayerListCheck, 200); } } } // 隐藏观看人数和弹幕装填信息 function hideVideoInfo() { hideVideoInfoEtime = 0; let btn = ''; if (webStatus == 0 || webStatus == 1) { // 视频 btn = 'bpx-player-video-info'; hideVideoInfoVideoCheck(); } else if (webStatus == 2) { // 列表 btn = 'bilibili-player-video-info'; hideVideoInfoVideoCheck(); } // 视频 function hideVideoInfoVideoCheck() { if (document.getElementsByClassName(btn)[0]) { if (GM_getValue('MRMenuHideVideoInfo') == 1) { document.getElementsByClassName(btn)[0].style.cssText += 'display: none'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '隐藏观看人数和弹幕装填信息 - 已隐藏观看人数和弹幕装填信息'); } else { document.getElementsByClassName(btn)[0].style.display = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '隐藏观看人数和弹幕装填信息 - 已显示观看人数和弹幕装填信息'); } } else if (hideVideoInfoEtime < etime) { hideVideoInfoEtime += 200; setTimeout(hideVideoInfoVideoCheck, 200); } } } // 播放器内显示选集按钮 function displayEplist() { displayEplistEtime = 0; let btn = ''; if (webStatus == 0) { // 视频 btn = 'bpx-player-ctrl-eplist'; setInterval(displayEplistVideoCheck, 200); } else if (webStatus == 1) { // 影视 btn = 'squirtle-pagelist-wrap'; setInterval(displayEplistMovieCheck, 200); } // 视频 function displayEplistVideoCheck() { if (document.getElementsByClassName(btn)[0]) { if (GM_getValue('MRMenuDisplayEplist') == 1) { if (!document.getElementsByClassName(btn)[0].getAttribute('mr_show_eplist') || !document.getElementsByClassName(btn)[0].getAttribute('mr_show_eplist') == 'true') { document.getElementsByClassName(btn)[0].setAttribute('mr_show_eplist', 'true'); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '播放器内显示选集按钮 - 已显示选集按钮'); } } else if (document.getElementsByClassName(btn)[0].getAttribute('mr_show_eplist') == 'true') { document.getElementsByClassName(btn)[0].setAttribute('mr_show_eplist', ''); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '播放器内显示选集按钮 - 已隐藏选集按钮'); } } } // 影视 function displayEplistMovieCheck() { if (document.getElementsByClassName(btn)[0]) { if (GM_getValue('MRMenuDisplayEplist') == 1) { if (!document.getElementsByClassName(btn)[0].getAttribute('mr_always_display') || !document.getElementsByClassName(btn)[0].getAttribute('mr_always_display') == 'true') { document.getElementsByClassName(btn)[0].setAttribute('mr_always_display', 'true'); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '播放器内显示选集按钮 - 已显示选集按钮'); } } else if (document.getElementsByClassName(btn)[0].getAttribute('mr_always_display') == 'true') { document.getElementsByClassName(btn)[0].setAttribute('mr_always_display', ''); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '播放器内显示选集按钮 - 已隐藏选集按钮'); } } else if (displayEplistEtime < etime) { displayEplistEtime += 200; setTimeout(displayEplistMovieCheck, 200); } } } // 播放器内显示标题 function displayTitle() { displayTitleEtime = 0; if (webStatus == 0) { // 视频 setInterval(displayTitleVideoCheck, 200); } // 视频 function displayTitleVideoCheck() { if (document.getElementsByClassName('bpx-player-top-left-title')[0] && loadReady) { if (GM_getValue('MRMenuDisplayTitle') == 1) { if (window.getComputedStyle(document.getElementsByClassName('bpx-player-top-left-title')[0], null)['display'] != 'block') { document.getElementsByClassName('bpx-player-top-left-title')[0].style.cssText += 'display: block !important;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '播放器内显示标题 - 已显示标题'); } if (window.getComputedStyle(document.getElementsByClassName('bpx-player-top-mask')[0], null)['display'] != 'block') { document.getElementsByClassName('bpx-player-top-mask')[0].style.cssText += 'display: block !important;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '播放器内显示标题 - 已显示标题背景'); } } else { if (window.getComputedStyle(document.getElementsByClassName('bpx-player-top-left-title')[0], null)['display'] != 'none') { document.getElementsByClassName('bpx-player-top-left-title')[0].style.display = 'none'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '播放器内显示标题 - 已隐藏标题'); } if (window.getComputedStyle(document.getElementsByClassName('bpx-player-top-mask')[0], null)['display'] != 'none') { document.getElementsByClassName('bpx-player-top-mask')[0].style.display = 'none'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '播放器内显示标题 - 已隐藏标题背景'); } } } } } // 隐藏播放器内关注按钮 function hideFollowBtn() { hideFollowBtnEtime = 0; let btn = ''; if (webStatus == 0) { // 视频 btn = 'bpx-player-follow'; hideFollowBtnVideoCheck(); } else if (webStatus == 2) { // 列表 btn = 'bilibili-player-video-top-follow'; hideFollowBtnVideoCheck(); } // 视频 function hideFollowBtnVideoCheck() { if (document.getElementsByClassName(btn)[0]) { if (GM_getValue('MRMenuHideFollowBtn') == 1) { document.getElementsByClassName(btn)[0].style.cssText += 'display: none !important;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '隐藏播放器内关注按钮 - 已隐藏关注按钮'); } else { document.getElementsByClassName(btn)[0].style.display = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '隐藏播放器内关注按钮 - 已显示关注按钮'); } } else if (hideFollowBtnEtime < etime) { hideFollowBtnEtime += 200; setTimeout(hideFollowBtnVideoCheck, 200); } } } // 把标题和头像移到视频下方 function moveTitleAndUpinfo() { moveTitleAndUpinfoEtime = 0; if (webStatus == 0) { // 视频 moveTitleAndUpinfoVideoCheck(); } else if (webStatus == 2) { // 列表 moveTitleAndUpinfoListCheck(); } // 视频 function moveTitleAndUpinfoVideoCheck() { if (document.getElementById('viewbox_report') && (document.getElementById('v_upinfo') || document.getElementsByClassName('members-info-v1')[0]) && document.getElementById('arc_toolbar_report') && loadReady) { if (GM_getValue('MRMenuMoveTitleAndUpinfo') == 1) { // 移动标题到点赞栏上方 if (GM_getValue('MRPlayerMode') != 2) { document.getElementsByClassName('left-container')[0].insertBefore(document.getElementById('viewbox_report'), document.getElementById('arc_toolbar_report')); } // 标题样式 document.getElementById('viewbox_report').setAttribute('mr_layout', 'true'); if (!document.getElementsByClassName('members-info-v1')[0]) { // 移动头像到点赞栏上方 document.getElementsByClassName('left-container')[0].insertBefore(document.getElementById('v_upinfo'), document.getElementById('arc_toolbar_report')); // 头像栏样式 document.getElementById('v_upinfo').setAttribute('mr_layout', 'true'); // 播放器样式 if (GM_getValue('MRPlayerMode') != 2) { document.getElementById('playerWrap').setAttribute('mr_layout', 'true'); } else { document.getElementById('playerWrap').setAttribute('mr_layout', ''); } // 充电面板样式 document.getElementsByClassName('btn-panel')[0].setAttribute('mr_layout', 'true'); // 充电按钮样式 if (document.getElementsByClassName('old-charge-btn')[0]) { document.getElementsByClassName('old-charge-btn')[0].setAttribute('mr_layout', 'true'); } else if (document.getElementsByClassName('new-charge-btn')[0]) { document.getElementsByClassName('new-charge-btn')[0].setAttribute('mr_layout', 'true'); } // 关注按钮样式 document.getElementsByClassName('follow-btn')[0].setAttribute('mr_layout', 'true'); // 名称样式 document.getElementsByClassName('name')[0].setAttribute('mr_layout', 'true'); // 简介样式 if (document.getElementsByClassName('up-info_right')[0].children[1].className == 'desc') { document.getElementsByClassName('up-info_right')[0].children[1].style.cssText += 'width: calc(100% - 300px);'; } else { document.getElementsByClassName('btn-panel')[0].style.cssText += 'margin: -26px 10px 0px 0px;'; } // 当头像有装饰时 if (document.getElementsByClassName('u-face has-pendant')[0]) { document.getElementsByClassName('u-face has-pendant')[0].setAttribute('mr_layout', 'true'); } } else { // 联合投稿 document.getElementsByClassName('members-info-v1')[0].setAttribute('mr_layout', 'true'); // 移动联合投稿到点赞栏上方 document.getElementsByClassName('left-container')[0].insertBefore(document.getElementsByClassName('members-info-v1')[0], document.getElementById('arc_toolbar_report')); } // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '把标题和头像移到视频下方 - 已调整标题和头像样式并移动至视频下方'); } else { // 移动标题到原位 if (GM_getValue('MRPlayerMode') != 2) { document.getElementsByClassName('left-container')[0].insertBefore(document.getElementById('viewbox_report'), document.getElementById('playerWrap')); } if (!document.getElementsByClassName('members-info-v1')[0]) { // 移动头像到原位 document.getElementsByClassName('right-container-inner')[0].children[0].appendChild(document.getElementById('v_upinfo')); // 标题样式 document.getElementById('viewbox_report').setAttribute('mr_layout', ''); // 头像栏样式 document.getElementById('v_upinfo').setAttribute('mr_layout', ''); // 播放器样式 document.getElementById('playerWrap').setAttribute('mr_layout', ''); // 充电面板样式 document.getElementsByClassName('btn-panel')[0].setAttribute('mr_layout', ''); // 充电按钮样式 if (document.getElementsByClassName('old-charge-btn')[0]) { document.getElementsByClassName('old-charge-btn')[0].setAttribute('mr_layout', ''); } else if (document.getElementsByClassName('new-charge-btn')[0]) { document.getElementsByClassName('new-charge-btn')[0].setAttribute('mr_layout', ''); } // 关注按钮样式 document.getElementsByClassName('follow-btn')[0].setAttribute('mr_layout', ''); // 名称样式 document.getElementsByClassName('name')[0].setAttribute('mr_layout', ''); // 简介样式 if (document.getElementsByClassName('up-info_right')[0].children[1].className == 'desc') { document.getElementsByClassName('up-info_right')[0].children[1].style.width = ''; } else { document.getElementsByClassName('btn-panel')[0].style.margin = ''; } // 当头像有装饰时 if (document.getElementsByClassName('u-face has-pendant')[0]) { document.getElementsByClassName('u-face has-pendant')[0].setAttribute('mr_layout', ''); } } else { // 联合投稿 document.getElementsByClassName('members-info-v1')[0].setAttribute('mr_layout', ''); // 移动联合投稿到原位 document.getElementsByClassName('right-container-inner')[0].children[0].appendChild(document.getElementsByClassName('members-info-v1')[0]); } // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '把标题和头像移到视频下方 - 已恢复标题和头像位置'); } } else if (moveTitleAndUpinfoEtime < etime) { moveTitleAndUpinfoEtime += 200; setTimeout(moveTitleAndUpinfoVideoCheck, 200); } } // 列表 function moveTitleAndUpinfoListCheck() { if (document.getElementById('viewbox_report') && (document.getElementById('v_upinfo') || document.getElementsByClassName('members-info')[0]) && document.getElementById('arc_toolbar_report') && loadReady) { if (GM_getValue('MRMenuMoveTitleAndUpinfo') == 1) { // 移动标题到点赞栏上方 if (GM_getValue('MRPlayerMode') != 2) { document.getElementsByClassName('l-con')[0].insertBefore(document.getElementById('viewbox_report'), document.getElementById('arc_toolbar_report')); } // 标题栏样式 document.getElementById('viewbox_report').setAttribute('mr_layout_list', 'true'); // 头像栏样式 if (!document.getElementsByClassName('members-info')[0]) { // 移动头像到点赞栏上方 document.getElementsByClassName('l-con')[0].insertBefore(document.getElementById('v_upinfo'), document.getElementById('arc_toolbar_report')); // 标题样式 document.getElementById('viewbox_report').setAttribute('mr_layout_list', 'true'); // 头像栏样式 document.getElementById('v_upinfo').setAttribute('mr_layout_list', 'true'); // 头像栏右侧样式 document.getElementsByClassName('up-info_right')[0].setAttribute('mr_layout_list', 'true'); // 播放器样式 if (GM_getValue('MRPlayerMode') != 2) { document.getElementById('video-player').setAttribute('mr_layout', 'true'); document.getElementById('danmukuBox').setAttribute('mr_layout', 'true'); } else { document.getElementById('video-player').setAttribute('mr_layout', ''); document.getElementById('danmukuBox').setAttribute('mr_layout', 'true'); } // 充电面板样式 document.getElementsByClassName('btn-panel')[0].setAttribute('mr_layout_list', 'true'); // 充电按钮样式 if (document.getElementsByClassName('old-charge-btn')[0]) { document.getElementsByClassName('old-charge-btn')[0].setAttribute('mr_layout', 'true'); } else if (document.getElementsByClassName('new-charge-btn')[0]) { document.getElementsByClassName('new-charge-btn')[0].setAttribute('mr_layout', 'true'); } // 关注按钮样式 document.getElementsByClassName('follow-btn')[0].setAttribute('mr_layout', 'true'); // 名称样式 document.getElementsByClassName('up-info_right')[0].children[0].setAttribute('mr_layout_list', 'true'); // 简介样式 document.getElementsByClassName('desc')[0].style.cssText += 'width: calc(100% - 300px);'; // 移动简介 document.getElementsByClassName('up-info_right')[0].children[0].appendChild(document.getElementsByClassName('desc')[0]); // 当头像有装饰时 if (document.getElementsByClassName('u-face has-pendant')[0]) { document.getElementsByClassName('u-face has-pendant')[0].setAttribute('mr_layout', 'true'); } } else { // 联合投稿 document.getElementsByClassName('members-info')[0].setAttribute('mr_layout_list', 'true'); // 移动联合投稿到点赞栏上方 document.getElementsByClassName('l-con')[0].insertBefore(document.getElementsByClassName('members-info')[0], document.getElementById('arc_toolbar_report')); } // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '把标题和头像移到视频下方 - 已调整标题和头像样式并移动至视频下方'); } else { // 移动标题到原位 if (GM_getValue('MRPlayerMode') != 2) { document.getElementsByClassName('l-con')[0].insertBefore(document.getElementById('viewbox_report'), document.getElementById('video-player')); } // 标题栏样式 document.getElementById('viewbox_report').setAttribute('mr_layout_list', ''); if (!document.getElementsByClassName('members-info')[0]) { // 移动头像到原位 document.getElementsByClassName('r-con')[0].insertBefore(document.getElementById('v_upinfo'), document.getElementById('danmukuBox')); // 标题样式 document.getElementById('viewbox_report').setAttribute('mr_layout_list', ''); // 头像栏样式 document.getElementById('v_upinfo').setAttribute('mr_layout_list', ''); // 头像栏右侧样式 document.getElementsByClassName('up-info_right')[0].setAttribute('mr_layout_list', ''); // 播放器样式 document.getElementById('video-player').setAttribute('mr_layout', ''); document.getElementById('danmukuBox').setAttribute('mr_layout', ''); // 充电面板样式 document.getElementsByClassName('btn-panel')[0].setAttribute('mr_layout_list', ''); // 充电按钮样式 if (document.getElementsByClassName('old-charge-btn')[0]) { document.getElementsByClassName('old-charge-btn')[0].setAttribute('mr_layout', ''); } else if (document.getElementsByClassName('new-charge-btn')[0]) { document.getElementsByClassName('new-charge-btn')[0].setAttribute('mr_layout', ''); } // 关注按钮样式 document.getElementsByClassName('follow-btn')[0].setAttribute('mr_layout', ''); // 名称样式 document.getElementsByClassName('up-info_right')[0].children[0].setAttribute('mr_layout_list', ''); // 简介样式 document.getElementsByClassName('desc')[0].style.width = ''; // 移动简介 document.getElementsByClassName('up-info_right')[0].insertBefore(document.getElementsByClassName('desc')[0], document.getElementsByClassName('btn-panel')[0]); // 当头像有装饰时 if (document.getElementsByClassName('u-face has-pendant')[0]) { document.getElementsByClassName('u-face has-pendant')[0].setAttribute('mr_layout', ''); } } else { // 联合投稿 document.getElementsByClassName('members-info')[0].setAttribute('mr_layout_list', ''); // 移动联合投稿到原位 document.getElementsByClassName('r-con')[0].insertBefore(document.getElementsByClassName('members-info')[0], document.getElementsByClassName('r-con')[0].children[0]); } // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '把标题和头像移到视频下方 - 已恢复标题和头像位置'); } } else if (moveTitleAndUpinfoEtime < etime) { moveTitleAndUpinfoEtime += 200; setTimeout(moveTitleAndUpinfoListCheck, 200); } } } // 隐藏导航栏标签 function hideNavigationBarTag() { hideNavigationBarTagEtime = 0; if (webStatus == 0 || webStatus == 1 || webStatus == 3 || webStatus == 4 || webStatus == 5 || webStatus == 6) { // 视频/影视/空间/搜索/主页/信息 hideNavigationBarTagVideoCheck(); } else if (webStatus == 2 || webStatus == 7) { // 列表/个人中心 hideNavigationBarTagListCheck(); } // 视频 function hideNavigationBarTagVideoCheck() { if (document.getElementsByClassName('left-entry')[0] && loadReady) { for (let i = 0; i < GM_getValue('MRMenuHideNavigationBarTag').split('').length; i++) { if (GM_getValue('MRMenuHideNavigationBarTag').split('')[i] == 1) { if (i == 0) { document.getElementsByClassName('left-entry')[0].children[0].children[0].children[0].style.cssText += 'display: none'; } else if (i == 1) { document.getElementsByClassName('left-entry')[0].children[0].children[0].children[1].style.cssText += 'display: none'; } else if (i == 8) { for (let i2 = 0; i2 < document.getElementsByClassName('left-entry')[0].children.length; i2++) { if (document.getElementsByClassName('left-entry')[0].children[i2].className.match('left-loc-entry')) { document.getElementsByClassName('left-entry')[0].children[i2].style.cssText += 'display: none'; } } } else if (i == 9) { document.getElementsByClassName('left-entry')[0].children[document.getElementsByClassName('left-entry')[0].children.length - 1].style.cssText += 'display: none'; } else { document.getElementsByClassName('left-entry')[0].children[i - 1].style.cssText += 'display: none'; } } else { if (i == 0) { document.getElementsByClassName('left-entry')[0].children[0].children[0].children[0].style.display = ''; } else if (i == 1) { document.getElementsByClassName('left-entry')[0].children[0].children[0].children[1].style.display = ''; } else if (i == 8) { for (let i2 = 0; i2 < document.getElementsByClassName('left-entry')[0].children.length; i2++) { if (document.getElementsByClassName('left-entry')[0].children[i2].className.match('left-loc-entry')) { document.getElementsByClassName('left-entry')[0].children[i2].style.display = ''; } } } else if (i == 9) { document.getElementsByClassName('left-entry')[0].children[document.getElementsByClassName('left-entry')[0].children.length - 1].style.display = ''; } else { document.getElementsByClassName('left-entry')[0].children[i - 1].style.display = ''; } } } // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '隐藏导航栏标签 - 已调整导航栏标签'); } else if (hideNavigationBarTagEtime < etime) { hideNavigationBarTagEtime += 200; setTimeout(hideNavigationBarTagVideoCheck, 200); } } // 列表 function hideNavigationBarTagListCheck() { if (document.getElementsByClassName('nav-link-ul')[0] && loadReady) { for (let i = 0; i < GM_getValue('MRMenuHideNavigationBarTag').split('').length; i++) { if (GM_getValue('MRMenuHideNavigationBarTag').split('')[i] == 1) { if (i == 0) { document.getElementsByClassName('nav-link-ul')[0].children[0].children[0].children[1].childNodes[0].style.cssText += 'display: none'; } else if (i == 1) { document.getElementsByClassName('nav-link-ul')[0].children[0].children[0].children[1].childNodes[1].textContent = ''; document.getElementsByClassName('nav-link-ul')[0].children[0].children[0].children[1].childNodes[2].style.cssText += 'display: none'; } else if (i == 3) { document.getElementsByClassName('nav-link-ul')[0].children[3].style.cssText += 'display: none'; } else if (i == 4) { document.getElementsByClassName('nav-link-ul')[0].children[2].style.cssText += 'display: none'; } else if (i == 8) { let hideNavigationBarTagListBlockList = ['主站', '番剧', '游戏中心', '直播', '会员购', '漫画', '赛事', '下载客户端']; for (let i2 = 0; i2 < document.getElementsByClassName('nav-link-ul')[0].children.length; i2++) { let match = 0; for (let i3 = 0; i3 < hideNavigationBarTagListBlockList.length; i3++) { if (document.getElementsByClassName('nav-link-ul')[0].children[i2].textContent.match(hideNavigationBarTagListBlockList[i3])) { match = 1; } } if (match == 0) { document.getElementsByClassName('nav-link-ul')[0].children[i2].style.cssText += 'display: none'; } } } else if (i == 9) { document.getElementsByClassName('nav-link-ul')[0].children[document.getElementsByClassName('nav-link-ul')[0].children.length - 1].style.cssText += 'display: none'; } else { document.getElementsByClassName('nav-link-ul')[0].children[i - 1].style.cssText += 'display: none'; } } else { if (i == 0) { document.getElementsByClassName('nav-link-ul')[0].children[0].children[0].children[1].childNodes[0].style.display = ''; } else if (i == 1) { document.getElementsByClassName('nav-link-ul')[0].children[0].children[0].children[1].childNodes[1].textContent = '主站'; document.getElementsByClassName('nav-link-ul')[0].children[0].children[0].children[1].childNodes[2].style.display = ''; } else if (i == 3) { document.getElementsByClassName('nav-link-ul')[0].children[3].style.display = ''; } else if (i == 4) { document.getElementsByClassName('nav-link-ul')[0].children[2].style.display = ''; } else if (i == 8) { let hideNavigationBarTagListBlockList = ['主站', '番剧', '游戏中心', '直播', '会员购', '漫画', '赛事', '下载客户端']; for (let i2 = 0; i2 < document.getElementsByClassName('nav-link-ul')[0].children.length; i2++) { let match = 0; for (let i3 = 0; i3 < hideNavigationBarTagListBlockList.length; i3++) { if (document.getElementsByClassName('nav-link-ul')[0].children[i2].textContent.match(hideNavigationBarTagListBlockList[i3])) { match = 1; } } if (match == 0) { document.getElementsByClassName('nav-link-ul')[0].children[i2].style.display = ''; } } } else if (i == 9) { document.getElementsByClassName('nav-link-ul')[0].children[document.getElementsByClassName('nav-link-ul')[0].children.length - 1].style.display = ''; } else { document.getElementsByClassName('nav-link-ul')[0].children[i - 1].style.display = ''; } } } // 通知 console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '隐藏导航栏标签 - 已调整导航栏标签'); } else if (hideNavigationBarTagEtime < etime) { hideNavigationBarTagEtime += 200; setTimeout(hideNavigationBarTagListCheck, 200); } } } // 实用功能与工具 // 智能连播 function smartNextPlay() { smartNextPlayEtime = 0; if (webStatus == 0) { // 视频 smartNextPlayVideoCheck(); } else if (webStatus == 1) { // 影视 smartNextPlayMovieCheck(); } else if (webStatus == 2) { // 列表 smartNextPlayListCheck(); } // 视频 function smartNextPlayVideoCheck() { if (document.getElementsByClassName('video-episode-card')[0] || document.getElementsByClassName('list-box')[0] || loadReady) { if (document.getElementsByClassName('bpx-player-ctrl-setting-handoff-content')[0]) { if (document.getElementsByClassName('video-episode-card')[0] || document.getElementsByClassName('list-box')[0]) { document.getElementsByClassName('bpx-player-ctrl-setting-handoff-content')[0].children[0].children[0].children[0].children[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '智能连播 - 检测到当前为多集视频已开启自动连播'); } else { document.getElementsByClassName('bpx-player-ctrl-setting-handoff-content')[0].children[0].children[0].children[0].children[1].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '智能连播 - 检测到当前为单集视频已关闭自动连播'); } } else if (smartNextPlayEtime < etime) { smartNextPlayEtime += 20; setTimeout(smartNextPlayVideoCheck, 20); } } else if (smartNextPlayEtime < etime) { smartNextPlayEtime += 20; setTimeout(smartNextPlayVideoCheck, 20); } } // 影视 function smartNextPlayMovieCheck() { if (document.getElementsByClassName('ep-item')[0] || loadReady) { if (document.getElementsByClassName('squirtle-handoff-auto')[0]) { if (document.getElementsByClassName('list-wrapper')[0] && document.getElementsByClassName('list-wrapper')[0].children[0].children.length > 1) { document.getElementsByClassName('squirtle-handoff-auto')[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '智能连播 - 检测到当前为多集视频已开启自动连播'); } else { document.getElementsByClassName('squirtle-handoff-pause')[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '智能连播 - 检测到当前为单集视频已关闭自动连播'); } } else { smartNextPlayEtime += 20; setTimeout(smartNextPlayMovieCheck, 20); } } else if (smartNextPlayEtime < etime) { smartNextPlayEtime += 20; setTimeout(smartNextPlayMovieCheck, 20); } } // 列表 function smartNextPlayListCheck() { if (document.getElementsByClassName('player-auxiliary-playlist-item')[0] || loadReady) { if (document.getElementsByClassName('bilibili-player-video-btn-setting-right-playtype-content')[0]) { if (document.getElementsByClassName('player-auxiliary-playlist-item').length > 1) { document.getElementsByClassName('bilibili-player-video-btn-setting-right-playtype-content')[0].children[0].children[0].children[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '智能连播 - 检测到当前为多集视频已开启自动连播'); } else { document.getElementsByClassName('bilibili-player-video-btn-setting-right-playtype-content')[0].children[0].children[0].children[1].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '智能连播 - 检测到当前为单集视频已关闭自动连播'); } } else { smartNextPlayEtime += 20; setTimeout(smartNextPlayListCheck, 20); } } else if (smartNextPlayEtime < etime) { smartNextPlayEtime += 20; setTimeout(smartNextPlayListCheck, 20); } } } // 播放器加载完毕后移动窗口到顶部函数 function moveWindowToTop() { setTimeout(function () { window.scrollTo(0, 0); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '播放器加载完毕后移动窗口到顶部函数 - 已将窗口移至顶部'); }, 1); } // 去除宽屏模式左右黑边 function removeWidescreenBlack() { removeWidescreenBlackEtime = 0; let btn = ''; if (webStatus == 0) { // 视频 btn = 'bilibili-player'; removeWidescreenBlackVideoCheck(); } else if (webStatus == 1) { // 影视 btn = 'bpx-player-video-perch'; removeWidescreenBlackVideoCheck(); } else if (webStatus == 2) { // 列表 btn = 'player'; removeWidescreenBlackVideoCheck(); } // 视频 function removeWidescreenBlackVideoCheck() { if (GM_getValue('MRPlayerMode') != 2) { if (document.getElementById(btn) && loadReady) { document.getElementById(btn).style.cssText += 'height: auto !important;'; if (GM_getValue('MRMenuRemoveWidescreenBlack') == 1) { if (document.getElementById(btn).offsetWidth > document.getElementById(btn).offsetHeight) { document.getElementById(btn).style.cssText += 'height: auto !important;'; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '去除宽屏模式左右黑边 - 已去除宽屏模式左右黑边'); } else { document.getElementById(btn).style.height = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '去除宽屏模式左右黑边 - 竖版视频不做调整'); } } else { document.getElementById(btn).style.height = ''; console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '去除宽屏模式左右黑边 - 已恢复默认'); } } else if (removeWidescreenBlackEtime < etime) { removeWidescreenBlackEtime += 20; setTimeout(removeWidescreenBlackVideoCheck, 20); } } } } // 总是开启或关闭弹幕 function alwaysDisableDnmaku() { alwaysDisableDnmakuEtime = 0; if (webStatus == 0) { // 视频 alwaysDisableDnmakuVideoCheck(); } else if (webStatus == 1) { // 影视 alwaysDisableDnmakuMovieCheck(); } else if (webStatus == 2) { // 列表 alwaysDisableDnmakuListCheck(); } // 视频 function alwaysDisableDnmakuVideoCheck() { if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[0] == 1) { if (document.getElementsByClassName('bui-danmaku-switch-on')[0]) { for (let i = 0; i < GM_getValue('MRMenuAlwaysDisableDnmaku').split('').length; i++) { if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[i] == 1) { if (i == 1 && window.getComputedStyle(document.getElementsByClassName('bui-danmaku-switch-on')[0], null)['display'] == 'none') { document.getElementsByClassName('bui-danmaku-switch-input')[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '总是开启或关闭弹幕 - 已开启弹幕'); } else if (i == 2 && window.getComputedStyle(document.getElementsByClassName('bui-danmaku-switch-on')[0], null)['display'] == 'block') { document.getElementsByClassName('bui-danmaku-switch-input')[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '总是开启或关闭弹幕 - 已关闭弹幕'); } } } } else if (alwaysDisableDnmakuEtime < etime) { alwaysDisableDnmakuEtime += 200; setTimeout(alwaysDisableDnmakuVideoCheck, 200); } } } // 影视 function alwaysDisableDnmakuMovieCheck() { if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[0] == 1) { if (document.getElementsByClassName('bui-switch-input')[0]) { for (let i = 0; i < GM_getValue('MRMenuAlwaysDisableDnmaku').split('').length; i++) { if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[i] == 1) { if (i == 1 && document.getElementsByClassName('bui-switch-input')[0].checked == false) { document.getElementsByClassName('bui-switch-input')[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '总是开启或关闭弹幕 - 已开启弹幕'); } else if (i == 2 && document.getElementsByClassName('bui-switch-input')[0].checked == true) { document.getElementsByClassName('bui-switch-input')[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '总是开启或关闭弹幕 - 已关闭弹幕'); } } } } else if (alwaysDisableDnmakuEtime < etime) { alwaysDisableDnmakuEtime += 200; setTimeout(alwaysDisableDnmakuMovieCheck, 200); } } } // 列表 function alwaysDisableDnmakuListCheck() { if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[0] == 1) { if (document.getElementsByClassName('bilibili-player-video-danmaku-switch')[0] && document.getElementsByClassName('bilibili-player-video-danmaku-switch')[0].children[0] && document.getElementsByClassName('bui-switch-dot')[0] && loadReady) { // 由于列表没有好办法判定列表页是否开启了弹幕, 只能尽量拖延脚本执行时间来判断弹幕按钮是否打开了 setTimeout(alwaysDisableDnmakuListCheckDelay, 100); function alwaysDisableDnmakuListCheckDelay() { for (let i = 0; i < GM_getValue('MRMenuAlwaysDisableDnmaku').split('').length; i++) { console.log(GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[i] + ' ' + i); if (GM_getValue('MRMenuAlwaysDisableDnmaku').split('')[i] == 1) { if (i == 1 && window.getComputedStyle(document.getElementsByClassName('bui-switch-dot')[0], null)['left'] == '2px') { document.getElementsByClassName('bilibili-player-video-danmaku-switch')[0].children[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '总是开启或关闭弹幕 - 已开启弹幕'); } else if (i == 2 && window.getComputedStyle(document.getElementsByClassName('bui-switch-dot')[0], null)['left'] != '2px') { document.getElementsByClassName('bilibili-player-video-danmaku-switch')[0].children[0].click(); console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '总是开启或关闭弹幕 - 已关闭弹幕'); } } } } } else if (alwaysDisableDnmakuEtime < etime) { alwaysDisableDnmakuEtime += 200; setTimeout(alwaysDisableDnmakuListCheck, 200); } } } } // 其他 // 禁用按钮改变样式 function disableBtn(elementSwitch) { elementSwitch.style.pointerEvents = 'none'; elementSwitch.children[1].setAttribute('mr_disable', 'true'); } // 激活按钮改变样式 function enableBtn(elementSwitch) { elementSwitch.style.pointerEvents = ''; elementSwitch.children[1].setAttribute('mr_disable', ''); } // 判断页面加载完毕 function loadReadyFunction() { loadReadyEtime = 0; if (webStatus == 0 || webStatus == 1 || webStatus == 3 || webStatus == 5 || webStatus == 6) { // 视频/影视/空间/主页/信息 loadReadyVideoCheck(); } else if (webStatus == 2) { // 列表 loadReadyListCheck(); } else if (webStatus == 4) { // 搜索 loadReadySearchCheck(); } else if (webStatus == 7) { // 个人中心 loadReadyAccountCheck(); } // 视频 function loadReadyVideoCheck() { if (document.getElementsByClassName('nav-search-input')[0] && document.getElementsByClassName('nav-search-input')[0].title != '') { console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '页面加载完毕'); loadReady = true; // 恢复菜单点击 if (GM_getValue('MRMenuSwitch') == 1) { MRMenuElement.style.pointerEvents = ''; } // 菜单文本 if (document.getElementById('MRMenuStatus')) { document.getElementById('MRMenuStatus').textContent = ''; } if (webStatus == 0 || webStatus == 1) { // 默认模式, 播放器加载完毕后移动窗口到顶部 if (GM_getValue('MRPlayerMode') == 0 && GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } } } else if (loadReadyEtime < etime) { loadReadyEtime += 200; setTimeout(loadReadyVideoCheck, 200); } } // 列表 function loadReadyListCheck() { if (document.getElementsByClassName('bilibili-player-video-info-people-number')[0] && document.getElementsByClassName('bilibili-player-video-info-people-number')[0].textContent != '-') { console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '页面加载完毕'); loadReady = true; // 恢复菜单点击 if (GM_getValue('MRMenuSwitch') == 1) { MRMenuElement.style.pointerEvents = ''; } // 菜单文本 document.getElementById('MRMenuStatus').textContent = ''; // 默认模式, 播放器加载完毕后移动窗口到顶部 if (GM_getValue('MRPlayerMode') == 0 && GM_getValue('MRMenuMoveWindowToTop') == 1) { moveWindowToTop(); } } else if (loadReadyEtime < etime) { loadReadyEtime += 200; setTimeout(loadReadyListCheck, 200); } } // 搜索 function loadReadySearchCheck() { if (document.getElementsByClassName('right-entry')[0]) { console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '页面加载完毕'); loadReady = true; // 恢复菜单点击 if (GM_getValue('MRMenuSwitch') == 1) { MRMenuElement.style.pointerEvents = ''; } // 菜单文本 document.getElementById('MRMenuStatus').textContent = ''; } else if (loadReadyEtime < etime) { loadReadyEtime += 200; setTimeout(loadReadySearchCheck, 200); } } // 个人中心 function loadReadyAccountCheck() { if (document.getElementsByClassName('index-info')[0]) { console.log('[' + notificationScriptName + '-' + notificationNotification + '] ' + '页面加载完毕'); loadReady = true; // 恢复菜单点击 if (GM_getValue('MRMenuSwitch') == 1) { MRMenuElement.style.pointerEvents = ''; } // 菜单文本 document.getElementById('MRMenuStatus').textContent = ''; } else if (loadReadyEtime < etime) { loadReadyEtime += 200; setTimeout(loadReadyAccountCheck, 200); } } } // 改变GM字符串变量中的指定值 function changeText(str, location, newText) { let strSplit = GM_getValue(str).split(''); strSplit[location] = newText; GM_setValue(str, strSplit.join('')); } } })();