// ==UserScript== // @name H2P: 斗鱼B站小工具 // @namespace http://tampermonkey.net/ // @version 1.8.1 // @icon http://www.douyutv.com/favicon.ico // @description 斗鱼:抽奖、抄袭、循环弹幕,关键词回复 ____ 黑暗(夜间)模式、清爽模式 ____ 批量取关、直播时长、真实人数、暂停播放、关闭滚动弹幕、静音、签到、领取鱼塘、默认画质、自动维持亲密度 ____ 快捷键。 ________ B 站:(首页、动态、排行榜、video)黑暗模式(夜间模式)。 // @author H2P // @compatible chrome // @match *://*.douyu.com/0* // @match *://*.douyu.com/1* // @match *://*.douyu.com/2* // @match *://*.douyu.com/3* // @match *://*.douyu.com/4* // @match *://*.douyu.com/5* // @match *://*.douyu.com/6* // @match *://*.douyu.com/7* // @match *://*.douyu.com/8* // @match *://*.douyu.com/9* // @match *://*.douyu.com/topic/* // @match https://www.douyu.com/directory/myFollow // @match *://*.bilibili.com/ // @match *://*.bilibili.com/?* // @match *://*.bilibili.com/video/* // @match *://*.t.bilibili.com/* // @match *://*.bilibili.com/ranking?* // @note 2019.03.18-V0.2.00 循环弹幕可以设置多条,随机发送;新增弹幕倒计时;界面美化一下?抽奖弹幕新增一种查询类型 // @note 2019.03.18-V0.3.00 界面修改;界面可隐藏;可以设置是否发送默认弹幕 // @note 2019.03.18-V0.3.01 小 BUG 修复 // @note 2019.03.19-V0.4.00 引入 JQuery 改写,还没改完;更新了弹幕抽奖元素获取(因为斗鱼改了);增加设置抽奖弹幕次数;发送弹幕时可以修改循环弹幕 // @note 2019.03.23-V0.4.01 完善了一下代码;完善了界面;修改了字体 // @note 2019.03.23-V0.5.00 添加了斗鱼清爽模式 : 隐藏部分、隐藏全部、删除元素 // @note 2019.03.23-V0.5.01 修缮清爽模式;添加自动领取观看鱼丸(不是鱼秀宝箱) // @note 2019.03.24-V0.5.02 修缮自动领取观看鱼丸;修缮隐藏全部元素的返回按钮 // @note 2019.03.24-V0.5.03 修改介绍。。。 // @note 2019.03.26-V0.5.04 修缮自动领取观看鱼丸,如果无法领取则清除循环 // @note 2019.03.28-V0.5.05 解决 jQuery $ 冲突;清爽模式处理粉丝节 // @note 2019.03.31-V0.6.00 添加“功能自动化”设置面板 // @note 2019.03.31-V0.6.01 修改介绍 // @note 2019.04.02-V0.6.02 代码重写 // @note 2019.04.04-V0.6.03 添加抄袭弹幕;完善设置信息存储 // @note 2019.05.25-V0.6.04 完善清爽模式退出 // @note 2019.06.11-V0.6.05 更新斗鱼领取宝箱 // @note 2019.07.04-V0.7.00 聚合脚本图标;删去抽奖弹幕 // @note 2019.07.05-V0.7.01 添加抽奖弹幕;发送时间设定改为间隔时间,单位改为毫秒;修改循环弹幕会自动保存 // @note 2019.07.06-V0.7.02 小小修缮 // @note 2019.07.06-V0.7.03 发送弹幕时间在间隔内随机 // @note 2019.07.06-V0.7.04 更新介绍(我觉得我输在介绍不够长、不够骚) // @note 2019.07.06-V0.7.05 自动领鱼丸更新;抽奖弹幕更新(感谢 beacoolguy 的反馈) // @note 2019.07.06-V0.7.06 自动点击抽奖弹幕“一键参与”(仅限发弹幕抽奖);清爽模式屏蔽贵族弹幕 // @note 2019.07.09-V0.7.07 抽奖弹幕“一键参与”(仅限条件 : 发弹幕和关注主播);样式修改;新功能(关键词自动回复展望) // @note 2019.07.09-V0.7.08 清爽模式针对“topic”直播间和大屏幕优化 // @note 2019.07.11-V0.7.09 添加关键词回复(目前只能设置关键词和回复,无法使用) // @note 2019.07.14-V0.8.00 关键词回复可以使用啦!!!(最多五条关键词) // @note 2019.07.22-V0.8.01 修复关键词回复 // @note 2019.08.02-V0.8.02 弹幕抽奖增加拥有粉丝牌的抽奖条件 // @note 2019.08.12-V0.8.03 弹幕抽奖完善拥有粉丝牌的抽奖条件;部分清爽模式修改 // @note 2019.08.13-V0.8.04 清爽模式部分隐藏修缮 // @note 2019.08.16-V0.8.05 清爽模式修缮 // @note 2019.08.17-V0.8.06 清爽模式部分隐藏修缮 // @note 2019.08.26-V0.8.07 清爽模式添加宽屏模式;ESC 快捷退出清爽模式 // @note 2019.08.26-V0.8.08 清爽模式位置更换 // @note 2019.09.05-V0.8.09 修缮关键词回复对于有粉丝牌无效的问题 // @note 2019.09.08-V0.9.00 关键词回复可以添加和删除;新一轮抽奖开启后清除上一轮抽奖弹幕内容 // @note 2019.09.10-V0.9.01 解决初始化失败的问题 // @note 2019.09.10-V0.9.02 解决关键词回复自己弹幕的问题 // @note 2019.09.10-V0.9.03 解决初始化失败的问题 // @note 2019.09.12-V0.9.04 在主播公司旁显示直播时长 // @note 2019.09.14-V1.0.00 Vue 重写自动发送弹幕和自动化配置界面;取消默认弹幕,抄袭弹幕增加抄袭间隔;取消显示直播时长 // @note 2019.09.14-V1.0.01 更新介绍 // @note 2019.09.14-V1.0.02 修复弹幕抽奖不工作;添加删除无关元素 // @note 2019.09.14-V1.0.03 修复弹幕抽奖不工作;Vue 重写清爽模式 // @note 2019.09.14-V1.0.04 修复关键词回复无法自动配置的问题;添加保留词 {showT} 用于替换主播直播时长 // @note 2019.09.15-V1.0.05 将主播直播时长保存在本地;修复 {showT} 替换失败问题 // @note 2019.09.15-V1.0.06 修复抽奖弹幕赠送 666 的问题 // @note 2019.09.16-V1.0.07 设置抄袭弹幕和循环弹幕优先级相同 // @note 2019.09.16-V1.0.08 解决 topic 房间 id 获取失败的问题 // @note 2019.09.24-V1.0.09 清除分区冠军赛;自动最低(高)画质 // @note 2019.09.24-V1.1.00 自动参与火力全开;解决自动签到、领取鱼丸一直检测的问题 // @note 2019.09.25-V1.1.01 更新自动领取鱼丸;解决处于发送等待期尝试发送弹幕的问题;领取鱼丸发送弹幕任务无法完成 // @note 2019.09.25-V1.1.02 添加在电脑面前检测 // @note 2019.09.28-V1.1.03 修复删除元素后宽屏导致礼物栏显示空白的问题 // @note 2019.10.06-V1.1.04 清爽模式增加单独处理弹幕栏;清爽信息栏还未实现 // @note 2019.10.07-V1.1.05 优化清爽模式;全屏模式、网页全屏已失效 // @note 2019.10.07-V1.1.06 解决宽屏模式白屏的问题;添加清爽模式功能;全屏模式、网页全屏在 Mac Chrome 会失效 // @note 2019.10.08-V1.1.07 优化清爽模式按键;新增删除元素解决内存溢出 // @note 2019.10.08-V1.1.08 修改介绍 // @note 2019.10.13-V1.1.09 普通直播间关灯模式优化;topic 房间清爽模式播放器和删除元素优化 // @note 2019.10.14-V1.1.10 优化 topic 房间和大屏关灯模式 // @note 2019.10.14-V1.2.01 优化脚本界面;添加脚本清爽,页面加载时即可清爽 // @note 2019.10.14-V1.2.02 修改介绍 // @note 2019.10.15-V1.2.03 修复设置版面清爽模式启动后无限触发的问题;修复脚本清爽无法启动的问题 // @note 2019.10.15-V1.2.04 优化关灯模式;针对有背景直播间优化;静音、关闭弹幕自动化 // @note 2019.10.16-V1.2.05 修改介绍 // @note 2019.10.16-V1.2.06 更新快捷键(Shift + a : 打开发送弹幕界面;Shift + s : 打开清爽模式界面;Shift + d : 打开自动设置界面) // @note 2019.10.17-V1.2.07 修改按钮配色 // @note 2019.10.19-V1.3.01 弹幕栏清爽后显示直播间热度和直播时长;优化脚本清爽(针对有背景图片的直播间) // @note 2019.10.19-V1.3.02 脚本清爽普通直播间白屏问题 // @note 2019.10.19-V1.3.03 脚本清爽有背景的普通直播间白屏问题;完善主播直播时间获取;弹幕栏清爽(去除标签) // @note 2019.10.19-V1.3.04 完善弹幕栏清爽(去除背景颜色) // @note 2019.10.20-V1.3.05 解决脚本清爽启动消除弹幕栏清爽的 BUG // @note 2019.10.24-V1.3.06 增加显示真实人数 // @note 2019.10.24-V1.3.07 增加显示真实人数 // @note 2019.10.24-V1.3.08 修复真实人数 BUG // @note 2019.11.11-V1.3.09 弹幕抽奖更新;真实人数更新 // @note 2019.11.13-V1.3.10 签到后关闭弹出的框;宽屏模式显示竞猜 // @note 2019.11.15-V1.3.11 修复抽奖弹幕会复制“复制”两个字的问题 // @note 2019.11.17-V1.3.12 清爽模式和宽屏模式优化 // @note 2019.11.24-V1.3.13 关灯模式优化 // @note 2019.12.10-V1.4.01 批量取关 // @note 2019.12.29-V1.4.02 清爽模式自定义;快捷键清除弹幕(Shift + c);清爽模式快捷键(Shift + u/i/o/p);礼物栏清爽优化 // @note 2020.04.16-V1.4.03 清爽模式信息栏、弹幕栏、播放器更新(有背景的直播间播放器还未更新) // @note 2020.04.16-V1.4.04 清爽模式信息栏优化 // @note 2020.04.26-V1.4.05 代码修改 // @note 2020.04.27-V1.4.06 自动给有牌子的主播赠送一根荧光棒 // @note 2020.04.28-V1.4.07 发送弹幕部分使用原生 JS 重写 // @note 2020.04.29-V1.4.08 弹幕栏清爽模式优化 // @note 2020.04.29-V1.4.09 关灯模式改为黑暗模式 // @note 2020.04.29-V1.4.10 黑暗模式需要手动开启 // @note 2020.04.30-V1.5.01 黑暗模式优化,且可以自动开启 // @note 2020.04.30-V1.5.02 网页打开就是黑暗模式,无需加载原来的样式 // @note 2020.04.30-V1.5.03 黑暗模式优化 // @note 2020.04.30-V1.5.04 黑暗模式优化 // @note 2020.04.30-V1.5.05 脚本清爽礼物栏优化 // @note 2020.04.30-V1.5.06 修复关键词回复 BUG // @note 2020.04.30-V1.5.07 修复抽奖弹幕 BUG // @note 2020.05.05-V1.5.08 清爽模式优化,页面加载过程中即可隐藏元素 // @note 2020.05.05-V1.5.09 清爽模式优化 // @note 2020.05.07-V1.6.00 代码重写完毕,不依赖于 jQuery 和 Vue // @note 2020.05.07-V1.6.01 修复抽奖弹幕提取失败的问题 // @note 2020.05.07-V1.6.02 针对 topic 房间优化清爽模式和黑暗模式 // @note 2020.05.07-V1.6.03 黑暗模式按钮修改到右上角,并且关注列表也有黑暗模式 // @note 2020.05.07-V1.6.04 修复自动静音 BUG // @note 2020.05.07-V1.6.05 领取鱼塘优化 // @note 2020.05.07-V1.6.06 解决关键词回复会回复同一个弹幕的问题 // @note 2020.05.08-V1.7.00 B 站首页和 video 黑暗模式 // @note 2020.05.08-V1.7.01 B 站动态和排行榜黑暗模式 // @note 2020.05.08-V1.7.02 B 站黑暗模式优化 // @note 2020.05.08-V1.7.03 修复不能赠送荧光棒的问题 // @note 2020.05.09-V1.7.04 斗鱼黑暗模式和礼物栏清爽模式优化 // @note 2020.05.10-V1.7.05 斗鱼礼物栏清爽模式优化 // @note 2020.05.11-V1.7.06 黑暗模式快捷键修改 // @note 2020.05.11-V1.7.07 自动暂停播放 // @note 2020.05.13-V1.8.00 黑暗模式(灰色、黑色、自定义) // @note 2020.05.13-V1.8.01 黑暗模式自定义优化 // @downloadURL none // ==/UserScript== (() => { 'use strict'; const $H2P = function (xpath, one = true) { if (one) { return document.querySelector(xpath); } else { return Array.from(document.querySelectorAll(xpath)); } } const myKeyCode = { 'a':65, 'b': 66, 'c': 67, 'd':68, 's':83, 'i': 73, 'o': 79, 'p': 80, 'z': 90,} const isDouyu = window.location.href.includes('douyu.com'); const isDouyuTopic = window.location.href.startsWith('https://www.douyu.com/topic/'); const isDouyuFollow = window.location.href.startsWith('https://www.douyu.com/directory/myFollow'); const isBilibili = window.location.href.includes('bilibili.com'); const isBilibiliHome = window.location.href === 'https://www.bilibili.com' || window.location.href === 'https://www.bilibili.com/' || window.location.href.startsWith('https://www.bilibili.com/?'); const isBilibiliVideo = window.location.href.startsWith('https://www.bilibili.com/video/'); const isBilibiliAct = window.location.href.startsWith('https://t.bilibili.com/'); const isBilibiliRank = window.location.href.startsWith('https://www.bilibili.com/ranking?'); localStorage.removeItem('h2p-DYScript-configPre'); localStorage.removeItem('h2p-DYScript-config'); // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 全局样式 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // let eleStyle = document.createElement('style'); eleStyle.innerHTML += ` .h2p-flex-main-start { height : 22px; margin : 0 0 15px 0; display : flex; flex-flow : row wrap; justify-content : flex-start; align-items : center; } .h2p-flex-main-center { height : 22px; margin : 0 0 14px 0; display : flex; flex-flow : row wrap; justify-content : center; align-items : center; } .h2p-flex-main-end { height : 22px; margin : 0 0 15px 0; display : flex; flex-flow : row wrap; justify-content : flex-end; align-items : center; } .h2p-item-100p { width : 100%; } .h2p-item-75p { width : 75%; } .h2p-item-50p { width : 50%; } .h2p-item-33p { width : 33.33%; } .h2p-item-25p { width : 25%; } `; document.head.appendChild(eleStyle); // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 黑暗模式 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // const LSClear = 'h2p-DY-config-clear'; let config_clear_pre = { isClearNav : false, isClearInfo : false, isClearAside: false, isClearGift : false, isClearBar : false, isClearPlay : false, blackMode : false, clearMode : false, delEle : false, wideMode : false, fullMode : false, BMGrey : true, BMBlack : false, BMDIY : false, BMBGDeep : '#2d2e37', BMBGLight : '#363636', BMFontDeep : '#a7a7a7', BMFontLight : '#888888', }; let config_clear = {}; Object.assign(config_clear, config_clear_pre); let config_clear_tmp = JSON.parse(localStorage.getItem(LSClear)) || {}; Object.assign(config_clear, config_clear_tmp); for (let key in config_clear) { if (!(key in config_clear_pre)) { delete config_clear[key]; } } localStorage.removeItem(LSClear); localStorage.setItem(LSClear, JSON.stringify(config_clear)); function blackMode () { console.log(`${config_clear.blackMode ? '启动' : '关闭'} : 黑暗模式`); let black = { bg: { deep : config_clear.BMDIY ? config_clear.BMBGDeep : (config_clear.BMBlack ? '#000000' : '#2d2e37'), light : config_clear.BMDIY ? config_clear.BMBGLight : (config_clear.BMBlack ? '#121212' : '#282930'), }, font: { deep : config_clear.BMDIY ? config_clear.BMFontDeep : (config_clear.BMBlack ? '#777777' : '#999999'), light : config_clear.BMDIY ? config_clear.BMFontLight : (config_clear.BMBlack ? '#666666' : '#888888'), } }; if (config_clear.blackMode) { if ($H2P('style#h2p-style-blackMode')) { $H2P('style#h2p-style-blackMode').remove(); } let eleStyle = document.createElement('style'); eleStyle.id = 'h2p-style-blackMode'; eleStyle.innerHTML += ` .h2p-dropdown-menu { background-color: ${black.bg.light}; color: ${black.font.deep}; border-color: ${black.bg.light}; box-shadow: 0 2px 6px ${black.bg.light}; } `; if (isDouyu) { eleStyle.innerHTML += ` body, div.Header-wrap, main.layout-Main, div.FishpondTreasure-v4-area { background-color: ${black.bg.deep}; } `; // header 左边 eleStyle.innerHTML += ` div.Header-wrap { border-bottom-color: ${black.bg.deep}; } #js-header div.HeaderNav a.EntryNav-desc, #js-header ul.Header-menu > li a, svg.Header-icon use, .DropMenuList-name { color: ${black.font.deep}; } .public-DropMenu-drop { background-color: ${black.bg.deep}; box-shadow: 0 2px 6px ${black.bg.light}; } a.Category-item { background-color: ${black.bg.light}; } `; // 搜索框 eleStyle.innerHTML += ` #js-header div.Header-right div.Search { background-color: ${black.bg.light}; border: 1px solid ${black.bg.light}; } #js-header div.Header-right div.Search svg.Header-icon, .Search-hot-title { color: ${black.font.deep}; } .Search-hotList a { color: ${black.font.light}; } .Search-hotList li:hover { background-color: ${black.bg.light}; } .Search-direct { background-color: ${black.bg.light}; border-color: ${black.bg.light}; } `; // header 右边 eleStyle.innerHTML += ` #js-header div.Header-right a.public-DropMenu-link, .User-nickname a, .DropPaneList.HistoryList .DropPaneList-title, .DropPaneList span.DropPaneList-title, .YubaMessage-link { color: ${black.font.deep}; } .DropPaneList > a:hover, .YubaMessage-link:hover { background-color: ${black.bg.light}; } `; // 侧边栏 eleStyle.innerHTML += ` .Aside-main--shrink, .Aside-toggle { background-color: ${black.bg.deep}; } .Aside-toggle>i:before { border-right-color: ${black.bg.deep}; } .Aside-shrink-item:last-child { border-top-color: ${black.bg.deep}; } `; // 主播信息 eleStyle.innerHTML += ` div#js-player-title { background-color: ${black.bg.deep}; border-color: ${black.bg.light}; border-bottom-color: ${black.bg.deep}; } div.Title-roomInfo div.Title-row h3.Title-header, div.Title-roomInfo div.Title-row h2.Title-anchorNameH2, div.Title-roomInfo div.Title-row a.Title-anchorHot div.Title-anchorText, div.Title-roomInfo div.Title-anchorLocation span, div.Title-roomInfo div.Title-sharkWeight span, div.Title-roomInfo div.Title-row div.Title-blockInline span { color: ${black.font.deep}; } `; // 礼物栏 eleStyle.innerHTML += ` div#js-player-toolbar, .GiftInfoPanel-cont { background-color: ${black.bg.deep}; border-color: ${black.bg.light}; } div#js-player-toolbar div.PlayerToolbar-ywInfo span, div#js-player-toolbar div.PlayerToolbar-ycInfo span, .GiftExpandPanel-descName, .GiftInfoPanel-name { color: ${black.font.deep}; } div#js-player-toolbar div.PlayerToolbar-Content:nth-child(2) div.PlayerToolbar-ContentCell:nth-child(1) { visibility: hidden; } div.GiftExpandPanel { background-color: ${black.bg.deep}; border-color: ${black.bg.deep}; } span.BatchGiveForm-num { background-color: ${black.bg.light}; border-color: ${black.bg.light}; color: ${black.font.deep}; } div.ShieldTool-list { background-color: ${black.bg.light}; border-color: ${black.bg.light}; } `; // 弹幕栏 eleStyle.innerHTML += ` div#js-player-asideMain { background-color: ${black.bg.deep}; border-color: ${black.bg.light}; } `; // 弹幕栏 - 公告 eleStyle.innerHTML += ` div.layout-Player-announce { background-color: ${black.bg.deep}; border-bottom-color: ${black.bg.light}; } div.layout-Player-rank ul.ChatTabContainer-titleWraper--tabTitle li { background-color: ${black.bg.deep}; border-color: ${black.bg.deep}; } `; // 弹幕栏 - 周榜 eleStyle.innerHTML += `div.ChatRankWeek-headerContent { background-color: ${black.bg.deep}; }`; // 弹幕栏 - 贵宾 eleStyle.innerHTML += `div.NobleRank, div.NobleRankTips { background-color: ${black.bg.deep}; }`; // 弹幕栏 - 粉丝团 eleStyle.innerHTML += ` div.FansRankInfo, div.ChatTabContainer { background-color: ${black.bg.deep}; } div.FansRankInfo span { color: ${black.font.deep}; } `; // 弹幕栏 - 主体 eleStyle.innerHTML += ` div#js-player-barrage, div.Barrage-main { background-color: ${black.bg.deep}; } span.Barrage-content { color: ${black.font.deep}; } div.Barrage { border-color: ${black.bg.light}; } `; // 弹幕栏 - 聊天框 eleStyle.innerHTML += ` div.layout-Player-chat { background-color: ${black.bg.deep}; } div.layout-Player-chat textarea.ChatSend-txt { background-color: ${black.bg.deep}; color: ${black.font.deep}!important; } `; // 弹幕栏脚本面板 eleStyle.innerHTML += ` div#h2p-div-clear-anchorHot { background-color: ${black.bg.deep}; border-bottom: 1px solid ${black.bg.deep}} div#h2p-div-clear-anchorHot div.Title-anchorText, div#h2p-div-clear-anchorHot div.Title-blockInline:nth-child(2) span.Title-row-icon, div#h2p-div-clear-anchorHot div.Title-blockInline:nth-child(2) i.Title-row-text { color: ${black.font.deep}; } `; // 互动预言 eleStyle.innerHTML += ` div#guess-main-panel { background: ${black.bg.deep}; border-color: ${black.bg.light}; } div.GuessMainPanelHeader-panelLeft span.GuessMainPanelHeader-slogon { color: ${black.font.deep}; } div.GuessGameBox, div.GuessReturnYwFdSlider-numIptWrap { background: ${black.bg.deep}; border-color: ${black.bg.light}; } div.GuessGameBox-header div.boxLeft, div.GuessReturnYwFdSlider-giftName { color: ${black.font.deep}; } div.GuessRankPanel-rank { border-color: ${black.bg.light}; } div.GuessReturnYwFdSlider-numIptWrap, div.GuessRankPanel, input.GuessReturnYwFdSlider-numIpt { background-color: ${black.bg.light}; border-color: ${black.bg.light}; color: ${black.font.deep}; } a.GuessGuideList-itemBox { background-color: ${black.bg.light}; } h2.guessGame--ell { color: ${black.font.deep}; } `; // 友邻 eleStyle.innerHTML += ` div#js-bottom-right { background-color: ${black.bg.deep}; } div.AnchorFriendPane-title { border-bottom-color: ${black.bg.light}!important } div.AnchorFriendPane-title h3 { color: ${black.font.deep}!important; } div.AnchorLike-ItemBox { border-color: ${black.bg.light}; } div.AnchorFriend-footer { border-top-color: ${black.bg.light}; } div.AnchorFriend-footer a { background-color: ${black.bg.deep}; color: ${black.font.deep}; } div.GuessReturnYwFdSlider { background-color: ${black.bg.deep}; border-color: ${black.bg.deep};} div.AnchorFriendPane-title a:first-child { display: none; } `; // 聊天框 eleStyle.innerHTML += ` .main-left { background-color: ${black.bg.deep}; border-right: 1px solid ${black.bg.light}; } .motorcadeHeader-motorcadeName-3mPkv { color: ${black.font.deep}; } .cl-item-username { color: ${black.font.light}; } .cl-item-line { background-color: ${black.bg.light}; } .main-left-header.main-left-header-small, .jumpBox-jumpBox-2BlGl { border-color: ${black.bg.light}; } `; if (isDouyuFollow) { eleStyle.innerHTML += ` div.layout-Module-head.ScrollTabFrame-head { background-color: ${black.bg.deep}; color: ${black.font.deep}; } div.layout-Cover-card { background-color: ${black.bg.deep}; } `; // 特别关注等按钮 eleStyle.innerHTML += ` .layout-Module-label { background-color: ${black.bg.light}; border-color: ${black.bg.light}; } `; // 可能感兴趣 eleStyle.innerHTML += ` .AthenaBoothPanel-wrapper, .AthenaBoothPanel-item { background-color: ${black.bg.light}; } .AthenaBoothPanel-des h3 { color: ${black.font.deep}; } .AthenaBoothPanel-followBtn { border-color: ${black.font.light}; color: ${black.font.light}; } `; // 每个卡片 eleStyle.innerHTML += ` .DyLiveCover-wrap, .DyLiveCover-wrap.is-hover, .DyLiveRecord { background-color: ${black.bg.light}; } .DyLiveCover-intro, .DyLiveRecord-intro { color: ${black.font.deep}; } `; } if (isDouyuTopic) { eleStyle.innerHTML += ` div.wm-general div.wm-general-bgblur, div.wm-general div.wm-general-wrapper { background: ${black.bg.deep}!important; } `; } } else if (isBilibili) { // 导航栏 eleStyle.innerHTML += ` body, #internationalHeader, #internationalHeader > div.mini-header { background: ${black.bg.deep}; } .international-header .nav-search #nav_searchform { background-color: ${black.bg.light}; } .international-header .mini-type .nav-link .nav-link-ul .nav-link-item .link, .mini-type .nav-user-center .user-con .item .name, .video-toolbar .ops > span, .video-toolbar .appeal-text, .international-header .nav-search .nav-search-keyword, .bilibili-search-history .history-item a { color: ${black.font.deep}; } .international-header .mini-type .user-con.logout .item a { color: ${black.font.deep}!important; } .international-header .mini-type .nav-search #nav_searchform, .bilibili-search-history { background: ${black.bg.light}; border-color: ${black.bg.light}; color: ${black.font.deep}; } `; // 登录 eleStyle.innerHTML += ` .van-popper-login .title[data-v-106692e2], .lang-intro-item, .lang-change .lang-title { color: ${black.font.deep}; } .van-popper-login .vp-container[data-v-106692e2], .lang-change { background-color: ${black.bg.deep}; border-color: ${black.bg.deep}; } .lang-change .lang-intro { background-color: ${black.bg.deep}; } .lang-change .lang-intro-item:hover { background-color: ${black.bg.light}; } .lang-change .lang-item:hover { background-color: ${black.bg.light}; } `; if (isBilibiliHome) { // 导航栏下边 eleStyle.innerHTML += ` .page-tab .con li { border: 1px solid transparent; } .international-header a { color: ${black.font.deep}; } .tab-line-itnl { border-color: ${black.font.deep}; } `; // 主体部分 eleStyle.innerHTML += ` a { color: ${black.font.deep}; } div.international-home { background-color: ${black.bg.deep}; } .contact-help { box-shadow: none; } `; // 主体部分 - 推广 eleStyle.innerHTML += ` .storey-title .no-link, .storey-title .text-info a, .video-card-common .ex-title { color: ${black.font.deep}; } `; // 主体部分 - 正在直播 eleStyle.innerHTML += ` .storey-title .name, .storey-title .text-info, .live-card .up .txt .name, .live-card .up .txt .desc, .exchange-btn .btn { color: ${black.font.deep}; } `; // 主体部分 - 动画 eleStyle.innerHTML += ` .rank-header .name, .live-tabs .tab-switch, .rank-header .more { color: ${black.font.deep}; } `; // 主体部分 - 番剧 eleStyle.innerHTML += ` .time-line .tab-switch .tab-switch-item, .special-recommend header { color: ${black.font.deep}; } `; // 主体部分 - 漫画 eleStyle.innerHTML += ` .time-line .tab-switch .tab-switch-item, .manga-panel .tab-switch .tab-switch-item, .manga-panel .app-download-link, .special-recommend header, .manga-rank .tab-switch .tab-switch-item, .manga-panel .manga-list-box .manga-card .manga-title { color: ${black.font.deep}; } `; // 底部 eleStyle.innerHTML += ` body, .international-footer { background: ${black.bg.deep}; } .international-footer a, .international-footer .link-box .link-item.link-c p { color: ${black.font.deep}; } .international-footer .link-box .link-item { border-color: ${black.bg.light}; } `; } else if (isBilibiliVideo) { // 信息栏 eleStyle.innerHTML += ` .video-info .video-title .tit { color: ${black.font.deep}; } `; // 播放器 eleStyle.innerHTML += ` #bilibiliPlayer { box-shadow: none; } .bilibili-player-video-sendbar, .bilibili-player-video-sendbar .bilibili-player-video-inputbar { background-color: ${black.bg.light}; } .video-desc .info, .bilibili-player-video-info, .bilibili-player * { color: ${black.font.deep}; } .video-toolbar, .v-wrap .s_tag { border-bottom-color: ${black.bg.light}; } .bilibili-player-video-sendbar .bilibili-player-video-inputbar .bilibili-player-video-inputbar-wrap { background-color: ${black.bg.deep}; border-color: ${black.bg.deep}; } .s_tag .tag-area > li { background-color: ${black.bg.light}; border-color: ${black.bg.light}; } .bilibili-player-video-sendbar .bilibili-player-video-inputbar .bilibili-player-video-danmaku-input, .s_tag .tag-area>li>a { color: ${black.font.deep}; } .s_tag .btn-add { background-color: ${black.bg.light}; } `; // 相关推荐 eleStyle.innerHTML += ` .v-wrap .danmaku-wrap, .bui-collapse .bui-collapse-wrap, .bui-collapse .bui-collapse-header, .player-auxiliary-area .player-auxiliary-filter, .video-page-card .card-box .pic-box { background-color: ${black.bg.light}; } .up-info .u-info .name .message, .info .title[data-v-3220bba8], .up-info .u-info .name .username, .player-auxiliary-area .player-auxiliary-filter-title, .bui-collapse .bui-collapse-header .bui-collapse-arrow, .recommend-list .rec-title, .video-page-card .card-box .info .title { color: ${black.font.deep}; } `; // 活动 eleStyle.innerHTML += ` .activity-m .inside-wrp { border-color: ${black.bg.light}; color: ${black.font.deep}; } `; // 评论 eleStyle.innerHTML += ` .bb-comment .comment-send .textarea-container textarea { background-color: ${black.bg.light}!important; border-color: ${black.bg.light}!important; } .bb-comment .comment-send .comment-emoji { border-color: ${black.bg.light}!important; } .bb-comment { background: ${black.bg.deep}!important; } .comment-m .b-head, .bb-comment .comment-header .tabs-order li, .paging-box, .paging-box .tcd-number, .bb-comment * { color: ${black.font.deep}!important; } .bb-comment .comment-list .list-item .con { border-top-color: ${black.bg.light}!important; } .bb-comment .comment-send .comment-submit { color: #fff!important; } `; // 创作团队 eleStyle.innerHTML += ` .members-info__header[data-v-f843d968], .members-info .up-card .avatar[data-v-f843d968] { background-color: ${black.bg.light}!important; } .members-info__header .title[data-v-f843d968] { color: ${black.font.deep}; } `; // 返回顶端 eleStyle.innerHTML += ` .float-nav .nav-menu .item { background-color: ${black.bg.light}!important; border-color: ${black.bg.light}; } `; } else if (isBilibiliAct) { // 主体 eleStyle.innerHTML += ` #app { background: ${black.bg.deep}; } `; // 动态 eleStyle.innerHTML += ` .feed-title[data-v-baaa0e9e] { background-color: ${black.bg.light}; color: ${black.font.deep}; } .card[data-v-62336402] { background-color: ${black.bg.light}; border-color: ${black.bg.light}!important; } .card .main-content .user-name a[data-v-62336402] { color: ${black.font.deep}; } .content-full[data-v-77d7458b], .content-ellipsis[data-v-77d7458b] { color: ${black.font.light}; } `; // 登陆板子 eleStyle.innerHTML += ` .login-panel[data-v-23be4e6a], .notice-panel[data-v-64440e39] { background-color: ${black.bg.light}; } .title h1[data-v-23be4e6a], .notice-panel .title[data-v-64440e39] { color: ${black.font.deep}; } `; } else if (isBilibiliRank) { // 导航栏下面 eleStyle.innerHTML += ` .page-tab .con li { border-color: transparent; } .international-header a, .rank-menu li { color: ${black.font.deep}; } `; // 主体 eleStyle.innerHTML += ` .rank-tab-wrap, .rank-list-head .rank_tips { background-color: ${black.bg.light}; } .rank-tab-wrap .rank-dropdown { background-color: ${black.bg.deep}; border-color: ${black.bg.deep}; color: ${black.font.deep}; } .rank-tab-wrap .rank-tab, .rank-list-head .rank_tips, .rank-item .content .info .title, .other .other-link .title { color: ${black.font.deep}; } .rank-item { border-bottom-color: ${black.bg.light}; } .rank-item:hover { box-shadow: 0 2px 5px ${black.bg.light}; } `; } } document.body.appendChild(eleStyle); } else { if ($H2P('style#h2p-style-blackMode')) { $H2P('style#h2p-style-blackMode').remove(); } } } if (config_clear.blackMode) { blackMode(); } const whiteBase64s = { douyu: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9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xNiAzNzAuMDA1MzMzbDEzOS45ODkzMzMgMTQxLjk5NDY2Ny0xMzkuOTg5MzMzIDE0MS45OTQ2NjcgMCAyMDAuMDIxMzMzLTIwMC4wMjEzMzMgMC0xNDEuOTk0NjY3IDEzOS45ODkzMzMtMTQxLjk5NDY2Ny0xMzkuOTg5MzMzLTIwMC4wMjEzMzMgMCAwLTIwMC4wMjEzMzMtMTM5Ljk4OTMzMy0xNDEuOTk0NjY3IDEzOS45ODkzMzMtMTQxLjk5NDY2NyAwLTIwMC4wMjEzMzMgMjAwLjAyMTMzMyAwIDE0MS45OTQ2NjctMTM5Ljk4OTMzMyAxNDEuOTk0NjY3IDEzOS45ODkzMzMgMjAwLjAyMTMzMyAwIDAgMjAwLjAyMTMzM3oiIHAtaWQ9IjIxMjgiIGZpbGw9IiNhN2E3YTciPjwvcGF0aD48L3N2Zz4='; const whiteBase64 = isDouyu ? whiteBase64s.douyu : (isBilibili ? (isBilibiliHome ? whiteBase64s.bilibili : whiteBase64s.bilibiliVideo) : whiteBase64s.finally); new Promise((resolve, reject) => { let eleStyle = document.createElement('style'); eleStyle.innerHTML += ` #h2p-img-blackMode { cursor: pointer; } .h2p-dropdown { position : relative; display : inline-block; } .h2p-dropdown:hover .h2p-dropdown-menu { display : flex; visibility : visible; } .h2p-dropdown-menu { position : absolute; left : -97px; top : ${isDouyu ? '' : (isBilibili ? '20px' : '')}; width : 210px; padding : 10px; border : 1px solid #d2d2d2; border-radius: 5px; box-shadow : 0 2px 6px rgba(0,0,0,.1); background : #ffffff; color : #000000; display : flex; visibility : hidden; flex-flow : row wrap; font-size : 15px; font-family : WeibeiSC-Bold, STKaiti; z-index : 999; } .h2p-dropdown .h2p-flex-main-start, .h2p-dropdown .h2p-flex-main-center { margin : 0; } .h2p-dropdown span { cursor : default; user-select : none; } #h2p-div-blackMode-select span { margin-left : 2px; } .h2p-dropdown .input-color-show { cursor : pointer; width : 50px; height : 20px; padding : 0; margin-left : 10px; outline : none; } #h2p-div-blackMode-BG { position : fixed; top : 0; left : 0; width : 100%; height : 100%; display : none; opacity : 0; } `; if (isDouyu) {} else if (isBilibili) { eleStyle.innerHTML += ` ul.nav-link-ul > li:last-child > span { display: none!important; } `; } document.head.appendChild(eleStyle); let div = document.createElement('div'); div.className = 'h2p-dropdown'; if (isDouyu) { div.style = 'position: relative; float: left; margin: 15px -20px 15px 20px;'; div.innerHTML = ` `; } else if (isBilibili) { div.style = 'display: flex; justify-content: center;'; div.innerHTML = ` `; } else { div.style = ''; div.innerHTML = ` `; } div.innerHTML += `
灰色
黑色
自定义
背景
面板
标题
正文
`; let setINVL_wait_div_header = setInterval(() => { if ($H2P('img#h2p-img-blackMode')) { window.clearInterval(setINVL_wait_div_header); setINVL_wait_div_header = null; return; } if (isDouyu && $H2P('div.Header-right')) { window.clearInterval(setINVL_wait_div_header); setINVL_wait_div_header = null; $H2P('div.Header-right').appendChild(div); resolve(); } else if (isBilibili && $H2P('ul.nav-link-ul > li:nth-child(8)')) { window.clearInterval(setINVL_wait_div_header); setINVL_wait_div_header = null; $H2P('ul.nav-link-ul > li:nth-child(8)').appendChild(div); resolve(); } if (!isDouyu && !isBilibili) { window.clearInterval(setINVL_wait_div_header); setINVL_wait_div_header = null; div.style.left = '250px'; document.body.appendChild(div); resolve(); } }, 500); }) .then(() => { document.addEventListener('keydown', (e) => { // 黑暗模式快捷键 if (e.shiftKey && e.which == myKeyCode.z) { $H2P('img#h2p-img-blackMode').click(); } }); let eleBM = $H2P('img#h2p-img-blackMode'); eleBM.addEventListener('click', () => { config_clear.blackMode = !config_clear.blackMode; localStorage.setItem(LSClear, JSON.stringify(config_clear)); eleBM.src = config_clear.blackMode ? blackBase64 : whiteBase64; blackMode(); }); let eleSelect = $H2P('div#h2p-div-blackMode-select'); eleSelect.addEventListener('click', (event) => { if (event.target.tagName.toLowerCase() !== 'input') { return; } const target = event.target; if (target.id === 'h2p-input-blackMode-grey') { config_clear.BMGrey = true; config_clear.BMBlack = false; config_clear.BMDIY = false; $H2P('input#h2p-input-blackMode-grey').checked = config_clear.BMGrey; $H2P('input#h2p-input-blackMode-black').checked = false; $H2P('input#h2p-input-blackMode-DIY').checked = false; } else if (target.id === 'h2p-input-blackMode-black') { config_clear.BMGrey = false; config_clear.BMBlack = true; config_clear.BMDIY = false; $H2P('input#h2p-input-blackMode-grey').checked = false; $H2P('input#h2p-input-blackMode-black').checked = config_clear.BMBlack; $H2P('input#h2p-input-blackMode-DIY').checked = false; } else if (target.id === 'h2p-input-blackMode-DIY') { config_clear.BMGrey = false; config_clear.BMBlack = false; config_clear.BMDIY = true; $H2P('input#h2p-input-blackMode-grey').checked = false; $H2P('input#h2p-input-blackMode-black').checked = false; $H2P('input#h2p-input-blackMode-DIY').checked = config_clear.BMDIY; } localStorage.setItem(LSClear, JSON.stringify(config_clear)); blackMode(); }) $H2P('input#h2p-input-blackMode-DIY-BG-deep').addEventListener('change', (event) => { config_clear.BMBGDeep = event.target.value; localStorage.setItem(LSClear, JSON.stringify(config_clear)); blackMode(); }, false); $H2P('input#h2p-input-blackMode-DIY-BG-light').addEventListener('change', (event) => { config_clear.BMBGLight = event.target.value; localStorage.setItem(LSClear, JSON.stringify(config_clear)); blackMode(); }, false); $H2P('input#h2p-input-blackMode-DIY-font-deep').addEventListener('change', (event) => { config_clear.BMFontDeep = event.target.value; localStorage.setItem(LSClear, JSON.stringify(config_clear)); blackMode(); }, false); $H2P('input#h2p-input-blackMode-DIY-font-light').addEventListener('change', (event) => { config_clear.BMFontLight = event.target.value; localStorage.setItem(LSClear, JSON.stringify(config_clear)); blackMode(); }, false); }) .then(() => { if (config_clear.BMGrey) { $H2P('input#h2p-input-blackMode-grey').checked = true; } if (config_clear.BMBlack) { $H2P('input#h2p-input-blackMode-black').checked = true; } if (config_clear.BMDIY) { $H2P('input#h2p-input-blackMode-DIY').checked = true; } if (config_clear.BMBGDeep) { $H2P('input#h2p-input-blackMode-DIY-BG-deep').value = config_clear.BMBGDeep; } if (config_clear.BMBGLight) { $H2P('input#h2p-input-blackMode-DIY-BG-light').value = config_clear.BMBGLight; } if (config_clear.BMFontDeep) { $H2P('input#h2p-input-blackMode-DIY-font-deep').value = config_clear.BMFontDeep; } if (config_clear.BMFontLight) { $H2P('input#h2p-input-blackMode-DIY-font-light').value = config_clear.BMFontLight; } }) if (!isDouyu) { return; } // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 取消关注 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // if (isDouyuFollow){ let anchorsSelected = []; new Promise((resolve, reject) => { let INVL_AddBtnCancelFollow = setInterval(() => { if ($H2P('div#filter-tab-expandable-wrapper') && !$H2P('a#h2p-a-cancelFollow')) { window.clearInterval(INVL_AddBtnCancelFollow); INVL_AddBtnCancelFollow = null; resolve(); } }, 500); }) .then(() => { let a_cancelFollow = document.createElement('a'); a_cancelFollow.id = 'h2p-a-cancelFollow'; a_cancelFollow.className = 'layout-Module-label'; a_cancelFollow.innerHTML = ` 取消关注 `; $H2P('div#filter-tab-expandable-wrapper').appendChild(a_cancelFollow); }) .then(() => { $H2P('a#h2p-a-cancelFollow').addEventListener('click', () => { let anchorSelected = $H2P('li.layout-Cover-item div.DyLiveCover-selectArea.is-active', false); anchorSelected.forEach(anchor => { let anchorHref = anchor.nextSibling.href; if (!anchorHref || anchorHref.length == 0) { anchorHref = anchor.parentNode.href; } let anchorId = anchorHref.split('/').pop(); anchorsSelected.push(anchorId); }); console.log(anchorsSelected); setTO_cancelFollow(); }); }) .catch(error => { console.log(error); }) function setTO_cancelFollow () { if (anchorsSelected && anchorsSelected.length > 0) { for (let i = 0; i < anchorsSelected.length; i++) { let anchorId = anchorsSelected[i]; setTimeout(() => { cancelFollow(anchorId); }, (i + 1) * 1000); } } } function cancelFollow (anchorId) { fetch(`https://www.douyu.com/room/follow/cancel_confuse/${anchorId}`, { method: 'POST' }) .then(res => res.json()) .then(res => { if (res && 'error' in res && res.error === 0) { console.log(`成功取消关注主播 : ${anchorId}`); let parentEle = $H2P(`a[href="/${anchorId}"]`).parentNode; // 从主播 id 找到主播信息所在 ele 的根节点 while (!parentEle.classList.contains('layout-Cover-item') && parentEle.tagName.toLowerCase() !== 'body') { parentEle = parentEle.parentNode; } if (parentEle.classList.contains('layout-Cover-item') && parentEle.tagName.toLowerCase() !== 'body') { parentEle.remove(); } } else { console.log(`取消关注主播 : ${anchorId} 失败`); } }); } return; } // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 全局变量 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 用户拥有牌子的主播信息 let roomOfAnchorFan = undefined; let userInfo = { nickName : '', // 昵称 isAnchorFan : false, // 是否拥有主播的粉丝牌 }; let roomInfo = { id : '', showT : 0, online : 0, } // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 主播信息获取 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // const LSInfo = 'h2p-DY-config-info'; let config_info = JSON.parse(localStorage.getItem(LSInfo)) || { showTs: {}, }; // 获取 roomInfo.id let regNums = /\d+/; if (regNums.test($H2P('head > title').textContent)) { roomInfo.id = regNums.exec($H2P('head > title').textContent)[0]; } else { roomInfo.id = regNums.exec(window.location.href)[0]; } // 获取在线人数 let urlId = isDouyuTopic ? window.location.href.split('=').pop() : window.location.pathname.split('/').pop(); fetch(`https://bojianger.com/data/api/common/search.do?keyword=${urlId}`) .then(res => res.json()) .then(res => { try { if (res.data) { if (res.data.online) { roomInfo.online = Number(res.data.online); } else if (res.data.anchorVo) { roomInfo.online = Number(res.data.anchorVo.audience_count); } } else { let res = JSON.parse(JSON.stringify(res)); roomInfo.online = Number(res.split('online":')[1].split(',')[0]); } console.log(`Succeed getting online : ${roomInfo.online}.`); } catch (error) { console.log(error); console.log('Fail to get online'); } }); // 获取直播时间 let showTs = {}; if (Array.isArray(config_info.showTs)) { config_info.showTs = {}; localStorage.setItem(LSInfo, JSON.stringify(config_info)); } else { showTs = config_info.showTs || {}; } let [showT, getT] = [0, 0]; if (showTs[roomInfo.id]) { showT = showTs[roomInfo.id].showT; getT = showTs[roomInfo.id].getT; } // 获取时间 < 6h if ((((new Date().getTime() / 1000) - getT) / 3600.0) < 6) { roomInfo.showT = showT; console.log(`Succeed getting anchor showTime : ${roomInfo.showT}.`); } else { fetch('https://www.douyu.com/betard/' + roomInfo.id) .then(res => res.json()) .then(res => { try { if (res) { if (res.cache_time) { roomInfo.showT = Number.parseInt(res.cache_time); } else { let r = res.split('"cache_time":')[1]; let l = r.substr(0, r.indexOf(',')); roomInfo.showT = Number.parseInt(l); } config_info.showTs[roomInfo.id] = { 'showT' : roomInfo.showT, "getT" : Number.parseInt(new Date().getTime() / 1000) }; console.log(`Succeed getting anchor showTime : `); console.log(config_info.showTs[roomInfo.id]); localStorage.setItem(LSInfo, JSON.stringify(config_info)); } else { console.log('Fail to get anchor showTime.') } } catch (error) { console.log(error); console.log('Fail to get anchor showTime.') } }); } // 根据 cookie 获取用户昵称 let cookies = document.cookie.split(/;\s/g); for (let i = 0; i < cookies.length; i++) { let cookie = cookies[i]; let keyVal = cookie.split('='); if (keyVal && keyVal.length == 2 && keyVal[0] == 'acf_nickname') { userInfo.nickName = keyVal[1]; break; } } // 自动获取已有徽章的主播 new Promise((resolve, reject) => { let iframe = document.createElement('iframe'); iframe.id = 'h2p-fansBadgeList'; iframe.style = 'display: none;' iframe.src = '/member/cp/getFansBadgeList'; document.body.appendChild(iframe); setTimeout(resolve, 250); }) .then(() => { let iframe = $H2P('iframe#h2p-fansBadgeList'); iframe.addEventListener('load', () => { // 获取有粉丝牌的主播房间号 roomOfAnchorFan = {}; let idoc = iframe.contentWindow.document; let ele_anchors = Array.from(idoc.querySelectorAll('table.aui_room_table.fans-badge-list > tbody > tr')); for ( let i = 0; i < ele_anchors.length; i++ ) { let ele = ele_anchors[i]; let anchorURL = ele.querySelector('td:nth-child(2)').querySelector('a').getAttribute('href'); let anchorName = ele.querySelector('td:nth-child(2)').querySelector('a').textContent; let anchorRoom = ele.getAttribute('data-fans-room'); let anchorUp = Number(ele.querySelector('td:nth-child(4)').querySelector('span').textContent); roomOfAnchorFan[anchorRoom] = {anchorName, anchorURL, anchorUp}; } console.log('有粉丝牌的主播房间号'); console.log(roomOfAnchorFan); let anchorRoom= window.location.href.split('/').pop(); userInfo.isAnchorFan = anchorRoom in roomOfAnchorFan; setTimeout(() => { $H2P('iframe#h2p-fansBadgeList').remove(); }, 2000) }); }) .catch(error => console.log(error)); // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 🐯和面板初始化 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // let viewShow_bar = false; let viewShow_clear = false; let viewShow_config = false; let viewShow_script = false; new Promise((resolve, reject) => { // 创建元素样式 let eleStyle = document.createElement('style'); eleStyle.type = 'text/css'; eleStyle.innerHTML += ` #h2p-div-sign { width : 18px; height : 18px; display : inline-block; vertical-align : middle; } #h2p-div-sign span { font-size : 18px; cursor : pointer; } #div-DYScript input, #div-DYScript button, #div-DYScript select { outline : none; line-height : 10px; } #div-DYScript { position : absolute; bottom : 1px; min-width : 335px; max-width : 335px; border : none; margin : 0 0 0 -1px; box-shadow : #c7c7c7 0 -5px 5px 0; display : flex; flex-flow : row wrap; z-index : 999; } #div-DYScript .h2p-div-inlinepanel { min-width : 315px; max-width : 315px; padding : 10px; border-width : 0 0 1px 0; font-family : WeibeiSC-Bold, STKaiti; font-size : 16px; background : #f5f5f5; } #div-DYScript .h2p-div-inlinetab { min-width : 335px; max-width : 335px; border-top : 1px solid #DCDCDC; border-radius : 2px; font-family : WeibeiSC-Bold, STKaiti; font-size : 16px; background : #f5f5f5; display : flex; flex-flow : row wrap; } #div-DYScript .h2p-div-layer { position : relative; width : 100%; height : 24px; } #div-DYScript .h2p-div-layer-half { position : absolute; width : 50%; height : 24px; } #div-DYScript .h2p-input-normal { height : 22px; padding : 0px 5px; border : 1px solid #708090; border-radius : 5px; font-size : 13px; } #div-DYScript .h2p-input-disable { background : #DCDCDC; cursor : default; } #div-DYScript .h2p-input-able { background : white; cursor : text; } #div-DYScript .h2p-div-tab { width : 33.3%; max-height : 29px; padding : 2px 0; text-align : center; } #div-DYScript .h2p-div-tab:hover { cursor : pointer; background : #DDDDDD; } #div-DYScript .h2p-hover-pointer:hover { cursor : pointer; background : #DDDDDD; } .h2p-bg-close { background : #00ddbb } .h2p-bg-close:hover{ background : #00ccaa } .h2p-bg-open { background : #99aaff } .h2p-bg-open:hover { background : #8899cc } `; document.head.appendChild(eleStyle); // 弹幕框上的 🐯 let div_sign = document.createElement('div'); div_sign.id = 'h2p-div-sign'; div_sign.style = 'margin: -8px 0 0 -3px;'; div_sign.title = '斗鱼脚本'; div_sign.innerHTML = `🐯`; // 整个面板 =============================================================== let div_DYScript = document.createElement('div'); div_DYScript.id = 'div-DYScript'; div_DYScript.style = 'display: none;'; // 检查弹幕面板挂载点(斗鱼弹幕显示区域)是否加载完成 // 检查弹幕图标挂载点(斗鱼弹幕输入框)是否加载完成 let check_mountPoint_barPanel = setInterval(() => { if ($H2P('div.layout-Player-asideMainTop') && $H2P('div.BarrageSuperLink') && $H2P('div.ChatToolBar')) { window.clearInterval(check_mountPoint_barPanel); check_mountPoint_barPanel = null; setTimeout(() => { $H2P('div.layout-Player-asideMainTop').appendChild(div_DYScript); $H2P('div.ChatToolBar').appendChild(div_sign); resolve(); }, 2000); } else if (!window.location.href.includes('douyu')) { window.clearInterval(check_mountPoint_barPanel); check_mountPoint_barPanel = null; document.body.appendChild(div_DYScript); document.body.appendChild(div_sign); resolve(); } }, 1000); }) .then(() => { $H2P('span#h2p-span-DYScript').addEventListener('click', () => { viewShow_script = !viewShow_script; $H2P('div#div-DYScript').style.display = viewShow_script ? '' : 'none'; }); }) .then(() => { let div_DYScriptTab = document.createElement('div'); div_DYScriptTab.id = 'div-DYScriptTab'; div_DYScriptTab.className = 'h2p-div-inlinetab'; div_DYScriptTab.style = 'order: 20;' div_DYScriptTab.innerHTML = `
📢
✡️
⏲️
`; $H2P('div#div-DYScript').appendChild(div_DYScriptTab); }) .then(() => { $H2P('div#div-DYScriptTab').addEventListener('click', (event) => { $H2P('div#h2p-div-bar').style.display = 'none'; $H2P('div#h2p-div-clear').style.display = 'none'; $H2P('div#h2p-div-config').style.display = 'none'; viewShow_bar = false; viewShow_clear = false; viewShow_config = false; Array.from(event.currentTarget.children).forEach(ele => { ele.style.backgroundColor = '#f5f5f5'; }); // 发弹幕 if (event.target.id === 'h2p-div-tab-bar') { viewShow_bar = true; $H2P('div#h2p-div-bar').style.display = ''; event.target.style.backgroundColor = '#DDDDDD'; } // 清爽模式 else if (event.target.id === 'h2p-div-tab-clear') { viewShow_clear = true; $H2P('div#h2p-div-clear').style.display = ''; event.target.style.backgroundColor = '#DDDDDD'; } // 自动化设置 else if (event.target.id === 'h2p-div-tab-config') { viewShow_config = true; $H2P('div#h2p-div-config').style.display = ''; event.target.style.backgroundColor = '#DDDDDD'; } }, false); }); // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 发弹幕 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // const LSChat = 'h2p-DY-config-chat'; let config_chat_pre = { invlStart : 3, invlEnd : 4, isLuck : false, isKeyRe : false, keyReBar : [], isCopy : false, copyInvl : 0, isLoop : false, loopBar : [], isSend : false, }; let config_chat = {}; Object.assign(config_chat, config_chat_pre); let config_chat_tmp = JSON.parse(localStorage.getItem(LSChat)) || {}; Object.assign(config_chat, config_chat_tmp); for (let key in config_chat) { if (!(key in config_chat_pre)) { delete config_chat[key]; } } localStorage.removeItem(LSChat); localStorage.setItem(LSChat, JSON.stringify(config_chat)); let [Chat, INVL_SendBar, INVL_ShowCD] = [undefined, undefined, undefined]; let luckBar = ''; // 抽奖弹幕内容 let luckCD = 0; // 弹幕抽奖活动倒计时 let luckTime = 0; // 抽奖弹幕发送次数 let Index_keyRe = 0; // 关键词回复弹幕列表已经检测的位置 let keyRes = []; // 已经回复的弹幕 ID // 初始化自动发弹幕界面 =============================================================== new Promise((resolve, reject) => { let eleStyle = document.createElement('style'); eleStyle.type = 'text/css'; eleStyle.innerHTML += ` #h2p-div-bar input[type="checkbox"] { margin : 3px; } #h2p-div-bar .h2p-input-invl { width : 23px; margin : 0 5px; } #h2p-div-bar .h2p-ta-bar-loopBar { width : 283px; height : 73px; padding : 0 5px; border : 1px solid #708090; border-radius : 5px; font-size : 13px; resize : none; } #h2p-div-bar .h2p-btn-keyRe { width : 16px; height : 16px; padding : 0; margin : 3px; border : 1px solid rgb(216, 216, 216); border-radius : 50%; background-color: white; text-align : center; } #h2p-div-bar #h2p-btn-bar-send { line-height: 18px; width: 100%; padding: 4px 0; border: none; border-radius: 5px; cursor: pointer; transition: all 0.5s } #h2p-div-bar .h2p-btn-active { background: #ffbb77!important; } .sendingDisabled {} `; document.head.appendChild(eleStyle); let div = document.createElement('div'); div.id = 'h2p-div-bar'; div.className = 'h2p-div-inlinepanel'; div.style = ''; div.innerHTML = `
~
/
`; let setINVL_wait_div_DYScript = setInterval(() => { if ($H2P('div#div-DYScript')) { window.clearInterval(setINVL_wait_div_DYScript); setINVL_wait_div_DYScript = null; $H2P('div#div-DYScript').appendChild(div); resolve(); } }, 500); }) // 元素绑定监听 .then(() => { let eleBar = $H2P('div#h2p-div-bar'); eleBar.addEventListener('click', (event) => { let target = event.target; if (target.id === 'h2p-input-bar-isCopy') { config_chat.isCopy = target.checked; } else if (target.id === 'h2p-input-bar-isLoop') { config_chat.isLoop = target.checked; } else if (target.id === 'h2p-input-bar-isKeyRe') { config_chat.isKeyRe = target.checked; } else if (target.id === 'h2p-input-bar-isLuck') { config_chat.isLuck = target.checked; } localStorage.setItem(LSChat, JSON.stringify(config_chat)); }, false) // 间隔最小值 let eleInvlStart = $H2P('input#h2p-input-bar-invl-start'); eleInvlStart.addEventListener('input', () => { eleInvlStart.value = eleInvlStart.value.replace(/[^\d]/g, '').slice(0, 3); }); eleInvlStart.addEventListener('focusout', () => { eleInvlStart.value = Math.max(eleInvlStart.value, 3); config_chat.invlStart = eleInvlStart.value; localStorage.setItem(LSChat, JSON.stringify(config_chat)); }); // 间隔最大值 let eleInvlEnd = $H2P('input#h2p-input-bar-invl-end'); eleInvlEnd.addEventListener('input', () => { eleInvlEnd.value = eleInvlEnd.value.replace(/[^\d]/g, '').slice(0, 3); }); eleInvlEnd.addEventListener('focusout', () => { eleInvlEnd.value = Math.max(eleInvlEnd.value, Number(eleInvlStart.value) + 1, 4); config_chat.invlEnd = eleInvlEnd.value; localStorage.setItem(LSChat, JSON.stringify(config_chat)); }); // 抽奖弹幕最大次数 let eleBarLuckTime = $H2P('input#h2p-input-bar-luck-time'); eleBarLuckTime.addEventListener('input', () => { eleBarLuckTime.value = eleBarLuckTime.value.replace(/[^\d]/g, '').slice(0, 2); }); eleBarLuckTime.addEventListener('focusout', () => { eleBarCopyInvl.value = Math.max(eleBarCopyInvl.value, 1); config_chat.luckTime = Number(eleBarLuckTime.value); localStorage.setItem(LSChat, JSON.stringify(config_chat)); }); // 添加关键词回复 let eleAddKeyRe = $H2P('button#h2p-btn-addKeyRe'); eleAddKeyRe.addEventListener('click', () => { config_chat.keyReBar.push({key: 'default', re: 'default'}); localStorage.setItem(LSChat, JSON.stringify(config_chat)); $H2P('select#h2p-select-keyRe').options.add(new Option('default', 'default')); $H2P('select#h2p-select-keyRe').selectedIndex = config_chat.keyReBar.length - 1; $H2P('input#h2p-input-key').value = $H2P('select#h2p-select-keyRe').selectedOptions[0].textContent; $H2P('input#h2p-input-re').value = $H2P('select#h2p-select-keyRe').selectedOptions[0].value; }); // 删除关键词回复 let eleDelKeyRe = $H2P('button#h2p-btn-delKeyRe'); eleDelKeyRe.addEventListener('click', () => { config_chat.keyReBar.splice($H2P('select#h2p-select-keyRe').selectedIndex, 1); localStorage.setItem(LSChat, JSON.stringify(config_chat)); $H2P('select#h2p-select-keyRe').options.remove($H2P('select#h2p-select-keyRe').selectedIndex); $H2P('input#h2p-input-key').value = $H2P('select#h2p-select-keyRe').selectedOptions[0].textContent; $H2P('input#h2p-input-re').value = $H2P('select#h2p-select-keyRe').selectedOptions[0].value; }); // 选择关键词回复 let eleSelectKeyRe = $H2P('select#h2p-select-keyRe'); eleSelectKeyRe.addEventListener('change', () => { $H2P('input#h2p-input-key').value = $H2P('select#h2p-select-keyRe').selectedOptions[0].textContent; $H2P('input#h2p-input-re').value = $H2P('select#h2p-select-keyRe').selectedOptions[0].value; }); // 修改关键词 let eleKey = $H2P('input#h2p-input-key'); eleKey.addEventListener('keyup', () => { config_chat.keyReBar[$H2P('select#h2p-select-keyRe').selectedIndex].key = eleKey.value; $H2P('select#h2p-select-keyRe').selectedOptions[0].textContent = eleKey.value; }); eleKey.addEventListener('focusout', () => { if (!eleKey.value) { eleKey.value = 'default'; config_chat.keyReBar[$H2P('select#h2p-select-keyRe').selectedIndex].key = eleKey.value; $H2P('select#h2p-select-keyRe').selectedOptions[0].textContent = eleKey.value; } localStorage.setItem(LSChat, JSON.stringify(config_chat)); }); // 修改回复 let eleRe = $H2P('input#h2p-input-re'); eleRe.addEventListener('keyup', () => { config_chat.keyReBar[$H2P('select#h2p-select-keyRe').selectedIndex].re = eleRe.value; $H2P('select#h2p-select-keyRe').selectedOptions[0].value = eleRe.value; }); eleRe.addEventListener('focusout', () => { if (!eleRe.value) { eleRe.value = 'default'; config_chat.keyReBar[$H2P('select#h2p-select-keyRe').selectedIndex].re = eleRe.value; $H2P('select#h2p-select-keyRe').selectedOptions[0].value = eleRe.value; } localStorage.setItem(LSChat, JSON.stringify(config_chat)); }); // 抄袭弹幕最大间隔 let eleBarCopyInvl = $H2P('input#h2p-input-bar-copy-invl'); eleBarCopyInvl.addEventListener('input', () => { eleBarCopyInvl.value = eleBarCopyInvl.value.replace(/[^\d]/g, '').slice(0, 3); }); eleBarCopyInvl.addEventListener('focusout', () => { eleBarCopyInvl.value = Math.min(eleBarCopyInvl.value, 200); config_chat.copyInvl = Number(eleBarCopyInvl.value); localStorage.setItem(LSChat, JSON.stringify(config_chat)); }); // 循环弹幕 let eleLoop = $H2P('textarea#h2p-ta-bar-loopBar'); eleLoop.addEventListener('focusout', () => { if (eleLoop.value && eleLoop.value.replace(/\s/g, '')) { config_chat.loopBar = eleLoop.value.split('\n'); localStorage.setItem(LSChat, JSON.stringify(config_chat)); } }); // 发送按钮 let eleSend = $H2P('button#h2p-btn-bar-send'); eleSend.addEventListener('click', () => { config_chat.isSend = !config_chat.isSend; $H2P('div#h2p-div-tab-bar').textContent = config_chat.isSend ? '🔥' : '📢'; $H2P('input.sendingDisabled', false).forEach(ele => { ele.classList.toggle('h2p-input-disable'); ele.disabled = !ele.disabled; }) if (config_chat.isSend) { setINVL_SendBar(); eleSend.classList.add('h2p-bg-open'); eleSend.textContent = "发送中"; } else { window.clearTimeout(INVL_SendBar); INVL_SendBar = null; window.clearInterval(INVL_ShowCD); INVL_ShowCD = null; $H2P('input#h2p-input-cd').value = ''; $H2P('input#h2p-input-bar-luck-time-now').value = ''; eleSend.classList.remove('h2p-bg-open'); eleSend.textContent = "发送"; } localStorage.setItem(LSChat, JSON.stringify(config_chat)); }, false) }) .catch(error => console.log(error)) // 读取配置参数 .then(() => { $H2P('input#h2p-input-bar-isLuck').checked = config_chat.isLuck || false; $H2P('input#h2p-input-bar-luck-time').value = config_chat.luckTime || 1; $H2P('input#h2p-input-bar-invl-start').value = config_chat.invlStart || ''; $H2P('input#h2p-input-bar-invl-end').value = config_chat.invlEnd || ''; $H2P('input#h2p-input-bar-isKeyRe').checked = config_chat.isKeyRe || false; if (!config_chat.keyReBar || !Array.isArray(config_chat.keyReBar)) { config_chat.keyReBar = []; } for (let {key, re} of config_chat.keyReBar) { $H2P('select#h2p-select-keyRe').options.add(new Option(key, re)); } $H2P('input#h2p-input-bar-isCopy').checked = config_chat.isCopy || false; $H2P('input#h2p-input-bar-copy-invl').value = config_chat.copyInvl || '', $H2P('input#h2p-input-bar-isLoop').checked = config_chat.isLoop || false; $H2P('textarea#h2p-ta-bar-loopBar').value = Array.isArray(config_chat.loopBar) ? config_chat.loopBar.join('\n') : ''; if (config_chat.isSend) { config_chat.isSend = false; $H2P('button#h2p-btn-bar-send').click(); } if (!Chat) { Chat = setBar(); } }) .then(() => { if (config_chat.keyReBar && config_chat.keyReBar.length > 0) { $H2P('input#h2p-input-key').value = $H2P('select#h2p-select-keyRe').selectedOptions[0].textContent; $H2P('input#h2p-input-re').value = $H2P('select#h2p-select-keyRe').selectedOptions[0].value; } }) .catch(error => { console.log(error); }) function getBar () { let barrage = undefined; // 抽奖弹幕 if (config_chat.isLuck && $H2P('div.LotteryDrawEnter-desc')) { // 计算目前倒计时 let luckCD_now = $H2P('div.LotteryDrawEnter-desc').textContent.split(':').reduce((m, s) => Number(m) * 60 + Number(s)); // 新一轮抽奖 if (luckCD_now > luckCD) { luckBar = undefined; luckTime = 0; // 显示抽奖内容 $H2P('div.LotteryDrawEnter-enter').click(); try { // 获取抽奖弹幕条件 let barREQM = $H2P('div.ULotteryStart-joinRule').textContent.split(':')[1]; const REQMs = ['发弹幕', '发弹幕+关注主播']; // 不是赠送、礼物、福袋、数字、盛典 let regex = /[\u8d60\u9001\u793c\u7269\u798f\u888b\d\u76db\u5178]+/g; if (barREQM.search(regex) < 0) { if (REQMs.indexOf(barREQM) > -1 || (userInfo.isAnchorFan && barREQM.includes('成为粉丝'))) { // 一键参与 $H2P('div.ULotteryStart-joinBtn').click(); // 获取抽奖弹幕内容 luckBar = $H2P('div.ULotteryStart-demandDanmu > span:nth-child(1)').textContent; luckBar = luckBar.split(' : ')[1] ? luckBar.split(' : ')[1] : luckBar.split(' : ')[0]; if (luckBar.includes('复制')) { luckBar = luckBar.slice(0, -2); } } } } catch (error) { console.log(error); } finally { $H2P('span.LotteryContainer-close').click(); } } barrage = luckTime < config_chat.luckTime ? luckBar : undefined; if (barrage) { luckTime++; $H2P('input#h2p-input-bar-luck-time-now').value = luckTime; console.log(`抽奖弹幕 : ${barrage}`); } luckCD = luckCD_now; } // 关键词弹幕回复 if (!barrage && config_chat.isKeyRe && Array.isArray(config_chat.keyReBar)) { let bars = $H2P('ul#js-barrage-list > li', false); for (let i = Index_keyRe; i < bars.length && !barrage; i++) { Index_keyRe++; let ele = bars[i]; try { let bar_check = ele.querySelector('span[class^="Barrage-content"]').textContent.replace(/\s/g, ''); if (ele.querySelector('span[class^="Barrage-nickName"]').title !== userInfo.nickName) { for (let j = 0; j < config_chat.keyReBar.length; j++) { let keyRe = config_chat.keyReBar[j]; if (bar_check.includes(keyRe.key)) { if (!keyRes.includes(ele.id)) { barrage = keyRe.re; keyRes.push(ele.id); while (keyRes.length > 200) { keyRes.shift; } console.log(`关键词弹幕回复 : ${barrage}`); break; } } } } } catch (error) { console.log(error); } } if (Index_keyRe >= bars.length) { Index_keyRe = 0; } } // 抄袭弹幕 if (!barrage && config_chat.isCopy) { let bars = $H2P('ul#js-barrage-list > li', false); let index = 0; if (config_chat.copyInvl) { if (config_chat.copyInvl < bars.length) { index = config_chat.copyInvl; } else { index = bars.length - 1; } } barrage = bars[index].querySelector('span[class^="Barrage-content"]').textContent.replace(/\s/g, ''); } // 循环弹幕 if (!barrage && config_chat.isLoop && Array.isArray(config_chat.loopBar)) { let index = Math.floor(Math.random() * (config_chat.loopBar.length)); barrage = config_chat.loopBar[index]; } return barrage ? barrage : ''; } function setINVL_SendBar () { let {invlStart = 2, invlEnd = 2} = config_chat; let [start, end] = [Number(invlStart), Number(invlEnd)]; let invl = Math.floor(Math.random() * (end - start)) + start; setINVL_ShowCD(invl); INVL_SendBar = setTimeout(() => { Chat.setMsg(getBar()); Chat.sendMsg(); setINVL_SendBar(); }, invl * 1000); } function setINVL_ShowCD (invl) { new Promise((resolve, reject) => { window.clearInterval(INVL_ShowCD); resolve(invl); }).then((invl)=> { let cd = invl + 0.3; INVL_ShowCD = setInterval(() => { cd = Math.max(Math.floor((cd - 0.1) * 10) / 10.0, 0); $H2P('input#h2p-input-cd').value = cd; }, 100); }) } function setBar () { let [eleSetBar, eleSendBar] = [undefined, undefined]; return { setMsg : (msg)=>{ if (!eleSetBar && $H2P('.ChatSend-txt')) { eleSetBar = $H2P('.ChatSend-txt'); } if (eleSetBar) { eleSetBar.value = msg; } }, sendMsg : ()=>{ if (!eleSendBar && $H2P('.ChatSend-button')) { eleSendBar = $H2P('.ChatSend-button'); } if (eleSendBar && eleSetBar.value) { eleSendBar.click(); } } } } // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 清爽模式 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // if (config_clear.clearMode) { clearMode(); } new Promise((resolve, reject) => { // 创建元素样式 =============================================================== let eleStyle = document.createElement('style'); eleStyle.type = 'text/css'; eleStyle.innerHTML += ` .h2p-btn { width : 100%; height : 100%; padding : 4px 0; border : none; border-radius : 5px; margin : 0; font-size : 13px; cursor : pointer; } .h2p-bg-red { background-color : #ff8899; } .h2p-bg-red:hover { background-color : #ff5566; } .h2p-top-0 { top: 0!important; } .h2p-top-50 { top: 50px!important; } .h2p-w-50p { width: 50%!important; } .h2p-w-96p { width: 96%!important; } .h2p-h-100p { height: 100%!important; } #h2p-div-clear-blackMode { cursor: pointer; } #h2p-div-clear button { height: 26px; } `; document.head.appendChild(eleStyle); // 初始化清爽模式界面 =============================================================== let div = document.createElement('div'); div.id = 'h2p-div-clear'; div.className = 'h2p-div-inlinepanel'; div.style = 'display: none;'; div.innerHTML = `
`; let setINVL_wait_div_DYScript = setInterval(() => { if ($H2P('div#div-DYScript')) { window.clearInterval(setINVL_wait_div_DYScript); setINVL_wait_div_DYScript = null; $H2P('div#div-DYScript').appendChild(div); resolve(); } }, 500); }) .then(() => { let eleVary = $H2P('div#h2p-div-clear-vary'); eleVary.addEventListener('click', (event) => { let target = event.target; if (target.tagName.toLowerCase() !== 'button') { return; } target.classList.toggle('h2p-bg-open'); if (target.id === 'h2p-btn-clear-nav') { config_clear.isClearNav = !config_clear.isClearNav; if (config_clear.clearMode) { clearNav(); } } else if (target.id === 'h2p-btn-clear-info') { config_clear.isClearInfo = !config_clear.isClearInfo; if (config_clear.clearMode) { clearInfo(); } } else if (target.id === 'h2p-btn-clear-aside') { config_clear.isClearAside = !config_clear.isClearAside; if (config_clear.clearMode) { clearAside(); } } else if (target.id === 'h2p-btn-clear-gift') { config_clear.isClearGift = !config_clear.isClearGift; if (config_clear.clearMode) { clearGift(); } } else if (target.id === 'h2p-btn-clear-bar') { config_clear.isClearBar = !config_clear.isClearBar; if (config_clear.clearMode) { clearBar(); } } else if (target.id === 'h2p-btn-clear-play') { config_clear.isClearPlay = !config_clear.isClearPlay; if (config_clear.clearMode) { clearPlay(); } } localStorage.setItem(LSClear, JSON.stringify(config_clear)); }, false); // 清爽模式 click 监听 let eleMode = $H2P('div#h2p-div-clear-mode'); eleMode.addEventListener('click', (event) => { let target = event.target; if (target.tagName.toLowerCase() !== 'button') { return; } if (target.id === 'h2p-btn-clear-delEle') { $H2P('button#h2p-btn-clear-delEle').classList.toggle('h2p-bg-open'); config_clear.delEle = !config_clear.delEle; localStorage.setItem(LSClear, JSON.stringify(config_clear)); deleteElement(); return; } target.classList.toggle('h2p-bg-open'); if (target.id === 'h2p-btn-clear-clearMode') { config_clear.clearMode = !config_clear.clearMode; clearMode(); } else if (target.id === 'h2p-btn-clear-wideMode') { config_clear.wideMode = !config_clear.wideMode; if (config_clear.fullMode) { config_clear.fullMode = false; $H2P('button#h2p-btn-clear-fullMode').classList.remove('h2p-bg-open'); } wideMode(); } else if (target.id === 'h2p-btn-clear-fullMode') { config_clear.fullMode = !config_clear.fullMode; if (config_clear.wideMode) { config_clear.wideMode = false; $H2P('button#h2p-btn-clear-wideMode').classList.remove('h2p-bg-open'); } fullMode(); } localStorage.setItem(LSClear, JSON.stringify(config_clear)); }, false); }) .then(() => { if (config_clear.isClearNav) { $H2P('button#h2p-btn-clear-nav').classList.add('h2p-bg-open'); } if (config_clear.isClearInfo) { $H2P('button#h2p-btn-clear-info').classList.add('h2p-bg-open'); } if (config_clear.isClearAside) { $H2P('button#h2p-btn-clear-aside').classList.add('h2p-bg-open'); } if (config_clear.isClearGift) { $H2P('button#h2p-btn-clear-gift').classList.add('h2p-bg-open'); } if (config_clear.isClearBar) { $H2P('button#h2p-btn-clear-bar').classList.add('h2p-bg-open'); } if (config_clear.isClearPlay) { $H2P('button#h2p-btn-clear-play').classList.add('h2p-bg-open'); } if (config_clear.clearMode) { $H2P('button#h2p-btn-clear-clearMode').classList.add('h2p-bg-open'); } if (config_clear.wideMode) { $H2P('button#h2p-btn-clear-wideMode').classList.add('h2p-bg-open'); } if (config_clear.fullMode) { $H2P('button#h2p-btn-clear-fullMode').classList.add('h2p-bg-open'); } if (config_clear.delEle) { $H2P('button#h2p-btn-clear-delEle').classList.add('h2p-bg-open'); } }) .catch(error => { console.log(error); }) new Promise((resolve, reject) => { // 主播热度、在线人数、直播时长 let divBar = document.createElement('div'); divBar.id = 'h2p-div-clear-anchorHot'; divBar.classList = 'h2p-flex-main-start h2p-h-100p'; divBar.style = 'padding: 3px 10px 0; margin: 0;'; divBar.innerHTML = `
0
0
0
`; let setINVL_wait_div_announce = setInterval(() => { if ($H2P('div.layout-Player-asideMainTop') && $H2P('div.BarrageSuperLink') && $H2P('div.ChatToolBar')) { window.clearInterval(setINVL_wait_div_announce); setINVL_wait_div_announce = null; setTimeout(() => { $H2P('div.layout-Player-announce').appendChild(divBar); resolve(); }, 2000); } }, 500); }) .then(() => { setTO_showAnchorHot(); }) function clearNav () { console.log(`${config_clear.isClearNav ? '启动' : '关闭'} : 清爽导航栏`); if (config_clear.isClearNav) { if ($H2P('style#h2p-style-clear-nav')) { return; } let eleStyle = document.createElement('style'); eleStyle.id = 'h2p-style-clear-nav'; // 斗鱼 logo、游戏、活动 eleStyle.innerHTML += ` a.Header-logo, div.public-DropMenu.Game, div.HeaderNav { display: none!important; } `; // 客户端、开播 eleStyle.innerHTML += ` div.Header-download-wrap, div.Header-broadcast-wrap { display: none!important; } `; // 用户头像 hover eleStyle.innerHTML += ` div.UserInfo div.Task, div.UserInfo div.CloudGameLink, div.Promotion { display: none!important; } `; document.body.appendChild(eleStyle); } else { $H2P('style#h2p-style-clear-nav').remove(); } } function clearInfo () { console.log(`${config_clear.isClearInfo ? '启动' : '关闭'} : 清爽主播信息`); if (config_clear.isClearInfo) { if ($H2P('style#h2p-style-clear-info')) { return; } let eleStyle = document.createElement('style'); eleStyle.id = 'h2p-style-clear-info'; eleStyle.innerHTML += ` div#js-player-title { min-height: auto!important; } div.Title { height: 100%!important; } `; // 头像、举报、友邻 eleStyle.innerHTML += ` div.Title-anchorPic, div.Title-roomInfo div.Title-col.is-left > div.Title-blockInline:nth-child(2), div.Title-roomInfo div.Title-col.is-right > div.Title-blockInline { display: none!important; } `; // 官方称号 eleStyle.innerHTML += ` div.Title-roomInfo > div.Title-row:nth-child(2) > div.Title-col:nth-child(1) > div.Title-blockInline:last-child { display: none!important; } `; // 友邻、工会、体重 eleStyle.innerHTML += ` div.Title-roomInfo > div.Title-row:nth-child(2) > div.Title-col:nth-child(2), div.Title-roomInfo > div.Title-row:nth-child(3) { display: none!important; } `; document.body.appendChild(eleStyle); } else { $H2P('style#h2p-style-clear-info').remove(); } } function clearAside () { console.log(`${config_clear.isClearAside ? '启动' : '关闭'} : 清爽侧边栏`); if (config_clear.isClearAside) { if ($H2P('style#h2p-style-clear-aside')) { return; } let eleStyle = document.createElement('style'); eleStyle.id = 'h2p-style-clear-aside'; eleStyle.innerHTML += ` aside#js-aside { display: none!important; } `; document.body.appendChild(eleStyle); } else { $H2P('style#h2p-style-clear-aside').remove(); } } function clearGift () { console.log(`${config_clear.isClearGift ? '启动' : '关闭'} : 清爽礼物栏`); if (config_clear.isClearGift) { if ($H2P('style#h2p-style-clear-gift')) { return; } let eleStyle = document.createElement('style'); eleStyle.id = 'h2p-style-clear-gift'; // 全民乐 PK、礼物 eleStyle.innerHTML += ` div.ToolbarActivityArea div.PlayerToolbar-Task, div.ToolbarActivityArea div.ActivityItem:last-child, div.ToolbarActivityArea div.ActivityItem:nth-last-child(2), div.SuperFansBubble, div.ToolbarActivityArea div.BattleShipEnter, div.ToolbarActivityArea div.RomanticDateComponent { display: none!important; } `; document.body.appendChild(eleStyle); } else { $H2P('style#h2p-style-clear-gift').remove(); } } function clearBar () { console.log(`${config_clear.isClearBar ? '启动' : '关闭'} : 清爽弹幕栏`); if (config_clear.isClearBar) { if ($H2P('style#h2p-style-clear-bar')) { return; } let eleStyle = document.createElement('style'); eleStyle.id = 'h2p-style-clear-bar'; eleStyle.innerHTML += ` div#js-player-barrage { top: 32px!important; } `; // 公告、开通贵族公告 // 聊天室、战队牌子 eleStyle.innerHTML += ` div.AnchorAnnounce, div.layout-Player-rankAll, div.layout-Player-rank { display: none!important; } div.BarrageBanner { display: none!important; } div.MatchSystemChatRoomEntry, div.MatchSystemTeamMedal { display: none!important; } `; // 弹幕标签 eleStyle.innerHTML += ` .FansMedal.is-made, .RoomLevel, .shark-webp .Motor, .Barrage-noble, .Medal, .BarrageTips { display: none!important; } .Barrage-notice--noble { background: transparent!important; border: none; } `; // 喇叭、贵族弹幕、超链弹幕 eleStyle.innerHTML += ` div.Horn4Category, div.ChatNobleBarrage, div.BarrageSuperLink, div.Barrage-firstCharge { display: none!important; } `; document.body.appendChild(eleStyle); } else { $H2P('style#h2p-style-clear-bar').remove(); } } function clearPlay () { console.log(`${config_clear.isClearPlay ? '启动' : '关闭'} : 清爽播放器`); if (config_clear.isClearPlay) { if ($H2P('style#h2p-style-clear-play')) { return; } let eleStyle = document.createElement('style'); eleStyle.id = 'h2p-style-clear-play'; // 悬浮广告、鱼吧 eleStyle.innerHTML += ` #js-room-activity, .layout-Bottom-mainEntity { display: none!important; } `; if (isDouyuTopic) { eleStyle.innerHTML += ` div#root > div.wm-general:nth-child(2), div#root > div.wm-general:nth-child(n+4), div.wm_footer { display: none!important; } div#root > div.wm-general:nth-child(3) { margin-top: 70px; } `; } document.body.appendChild(eleStyle); } else { $H2P('style#h2p-style-clear-play').remove(); } } function clearMode () { console.log(`${config_clear.clearMode ? '启动' : '关闭'} : 清爽模式`); if (config_clear.isClearNav) { if (config_clear.clearMode) { clearNav(); } else { config_clear.isClearNav = false; clearNav(); config_clear.isClearNav = true; } } if (config_clear.isClearInfo) { if (config_clear.clearMode) { clearInfo(); } else { config_clear.isClearInfo = false; clearInfo(); config_clear.isClearInfo = true; } } if (config_clear.isClearAside) { if (config_clear.clearMode) { clearAside(); } else { config_clear.isClearAside = false; clearAside(); config_clear.isClearAside = true; } } if (config_clear.isClearGift) { if (config_clear.clearMode) { clearGift(); } else { config_clear.isClearGift = false; clearGift(); config_clear.isClearGift = true; } } if (config_clear.isClearBar) { if (config_clear.clearMode) { clearBar(); } else { config_clear.isClearBar = false; clearBar(); config_clear.isClearBar = true; } } if (config_clear.isClearPlay) { if (config_clear.clearMode) { clearPlay(); } else { config_clear.isClearPlay = false; clearPlay(); config_clear.isClearPlay = true; } } } function wideMode () { if (config_clear.wideMode) { if ($H2P('div.wfs-2a8e83')) { $H2P('div.wfs-2a8e83').click(); } else { let start = new Date().getTime(); let setINVL_waitWideCoin = setInterval(() => { if ($H2P('div.wfs-2a8e83')) { window.clearInterval(setINVL_waitWideCoin); setINVL_waitWideCoin = null; $H2P('div.wfs-2a8e83').click(); } else { // 等待最长 2min if ((new Date().getTime() - start) / 1000 > 120) { window.clearInterval(setINVL_waitWideCoin); setINVL_waitWideCoin = null; } } }, 500); } } else { $H2P('div.wfs-exit-180268').click(); } } function fullMode () { if (config_clear.fullMode) { if ($H2P('div.fs-781153')) { $H2P('div.fs-781153').click(); } else { let start = new Date().getTime(); let setINVL_waitFullCoin = setInterval(() => { if ($H2P('div.fs-781153')) { window.clearInterval(setINVL_waitFullCoin); setINVL_waitFullCoin = null; $H2P('div.fs-781153').click(); } else { // 等待最长 2min if ((new Date().getTime() - start) / 1000 > 120) { window.clearInterval(setINVL_waitFullCoin); setINVL_waitFullCoin = null; } } }, 500); } } else { $H2P('div.fs-exit-b6e6a7').click(); } } function deleteElement () { if ($H2P('div#js-room-activity')) { $H2P('div#js-room-activity').remove(); } if ($H2P('div.layout-Bottom-mainEntity')) { $H2P('div.layout-Bottom-mainEntity').remove(); } } function setTO_showAnchorHot () { return setTimeout(() => { let anchorHot = Number($H2P('a.Title-anchorHot > div.Title-anchorText').textContent) || 0; let str_anchorHot = '' + anchorHot; if (anchorHot > 9999) { str_anchorHot = parseInt(anchorHot/10000) + 'w'; } $H2P('a#a-anchorHot > div.Title-anchorText').textContent = str_anchorHot; if (roomInfo.showT > 0) { let showT = Number.parseInt((new Date().getTime() / 1000) - roomInfo.showT) / 3600.0; let h = Number.parseInt(showT); let m = Number.parseInt((showT - h) * 60); let s = Number.parseInt(((showT - h) * 60 - m) * 60); // 设置直播时长 setInterval(() => { s += 1; if (s >= 60) { m += 1; s = 0; } if (m >= 60) { h += 1; m = 0; } let strShowT = `${h}:`; if (m >= 10) { strShowT += m + ':'; } else { strShowT += '0' + m + ':'; } if (s >= 10) { strShowT += s; } else { strShowT += '0' + s; } $H2P('a#a-anchorShowT > div.Title-anchorText').textContent = strShowT; }, 1000); } // 直播热度和在线人数 setInterval(() => { let anchorHot = Number($H2P('a.Title-anchorHot div.Title-anchorText').textContent) || 0; if (anchorHot > 9999) { anchorHot = Number.parseInt(anchorHot / 10000) + 'w'; } if ($H2P('a#a-anchorHot > div.Title-anchorText')) { $H2P('a#a-anchorHot > div.Title-anchorText').textContent = anchorHot; } let online = roomInfo.online; if (online > 9999) { online = Number.parseInt(online / 10000) + 'w'; } $H2P('div#div-online i.Title-row-text').textContent = online; }, 5000); }, 200); } // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 快捷键设置 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // document.addEventListener('keydown', (e) => { // ESC 按键 if (e.which === 27) { if (config_clear.wideMode) $H2P('button#h2p-btn-clear-wideMode').click(); else if (config_clear.fullMode) $H2P('button#h2p-btn-clear-fullMode').click(); } // shift a if (e.shiftKey && e.which == myKeyCode.a) { if ($H2P('span#h2p-span-DYScript')) { if (!viewShow_script) { $H2P('span#h2p-span-DYScript').click(); $H2P('div#h2p-div-tab-bar').click(); } else { if ( viewShow_bar ) { $H2P('span#h2p-span-DYScript').click(); } else { $H2P('div#h2p-div-tab-bar').click(); } } } } else if (e.shiftKey && e.which == myKeyCode.s) { if ($H2P('span#h2p-span-DYScript')) { if (!viewShow_script) { $H2P('span#h2p-span-DYScript').click(); $H2P('div#h2p-div-tab-clear').click(); } else { if (viewShow_clear) { $H2P('span#h2p-span-DYScript').click(); } else { $H2P('div#h2p-div-tab-clear').click(); } } } } else if (e.shiftKey && e.which == myKeyCode.d) { if ($H2P('span#h2p-span-DYScript')) { if (!viewShow_script) { $H2P('span#h2p-span-DYScript').click(); $H2P('div#h2p-div-tab-config').click(); } else { if (viewShow_config) { $H2P('span#h2p-span-DYScript').click(); } else { $H2P('div#h2p-div-tab-config').click(); } } } } // 清爽模式快捷键 else if (e.shiftKey && e.which == myKeyCode.i) { $H2P('button#h2p-btn-clear-clearMode').click(); } else if (e.shiftKey && e.which == myKeyCode.o) { $H2P('button#h2p-btn-clear-wideMode').click(); } else if (e.shiftKey && e.which == myKeyCode.p) { $H2P('button#h2p-btn-clear-fullMode').click(); } // 清空弹幕 else if (e.shiftKey && e.which == myKeyCode.c) { $H2P('a.Barrage-toolbarClear').click(); } }); // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 自动化设置 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 自动领取观看鱼丸 let auto_getFB = () => { let INVL_autoGetFB = setInterval(() => { // 观看鱼丸元素存在并且有未领取的鱼丸 if ($H2P('div.FishpondTreasure-num.is-entrance') && Number($H2P('div.FishpondTreasure-num.is-entrance').textContent) > 0) { for (let i = 0; i < 3; i++) { setTimeout(() => { // 打开领取鱼丸界面 $H2P('div.FishpondTreasure-icon').click(); // 每日活跃、每周活跃 $H2P('span[class^="FTP-btn"]', false)[i].click(); $H2P('div.FTP-singleTask-btn.is-finished', false).forEach( ele => ele.click()); // 鱼塘 $H2P('div.FTP-bubble-progressText.is-complete', false).forEach( ele => ele.click()); $H2P('span.FTP-close').click(); }, 1000 * i); } } }, 5000); }; // 默认画质 let auto_showDef = () => { let INVL_checkIconReady = setInterval(() => { if ($H2P('div.rate-5c068c')) { window.clearInterval(INVL_checkIconReady); INVL_checkIconReady = null; console(`启动完毕 : ${config_tool.isShow0 ? '最低' : '最高'}画质`); if (config_tool.isShow0) { $H2P('div.tip-e3420a > ul > li:last').click(); } else if (config_tool.isShow9) { $H2P('div.tip-e3420a > ul > li:first').click(); } } }, 500); } // 禁止弹幕 let auto_hideBar = () => { let INVL_checkIconReady = setInterval(() => { if ($H2P('div[class="showdanmu-42b0ac removed-9d4c42"]')) { window.clearInterval(INVL_checkIconReady); INVL_checkIconReady = null; } else if ($H2P('div[class="showdanmu-42b0ac"]')) { $H2P('div[class="showdanmu-42b0ac"]').click(); window.clearInterval(INVL_checkIconReady); INVL_checkIconReady = null; console.log('启动完毕 : 禁止弹幕'); } }, 500); } // 静音 let auto_hideSound = () => { let INVL_checkIconReady = setInterval(() => { if ($H2P('div[class="volume-silent-3eb726"]')) { window.clearInterval(INVL_checkIconReady); INVL_checkIconReady = null; } else if ($H2P('div[class="volume-8e2726"]')) { $H2P('div[class="volume-8e2726"]').click(); window.clearInterval(INVL_checkIconReady); INVL_checkIconReady = null; console.log('启动完毕 : 静音'); } }, 500); } // 暂停 let auto_pausePlay = () => { let INVL_checkIconReady = setInterval(() => { if ($H2P('div.pause-c594e8.removed-9d4c42')) { window.clearInterval(INVL_checkIconReady); INVL_checkIconReady = null; } else if ($H2P('div.pause-c594e8')) { $H2P('div.pause-c594e8').click(); window.clearInterval(INVL_checkIconReady); INVL_checkIconReady = null; console.log('启动完毕 : 暂停'); } }, 500); } // 自动签到 let auto_signIn = () => { let INVL_checkSignInIconReady = setInterval(() => { if ($H2P('div.RoomLevelDetail-level.RoomLevelDetail-level--no')) { window.clearInterval(INVL_checkSignInIconReady); INVL_checkSignInIconReady = null; console.log('启动完毕 : 签到'); $H2P('div.RoomLevelDetail-level.RoomLevelDetail-level--no').click(); setTimeout(() => { // 关闭签到弹出的框 $H2P('div.SSR-D-close').click(); }, 200); } }, 500); } // 自动赠送荧光棒 let auto_anchorUp = () => { function donateYGB(roomId){ let formData = new FormData(); formData.append("propId", "268"); formData.append("propCount", 1); formData.append("roomId", roomId); fetch('https://www.douyu.com/japi/prop/donate/mainsite/v1', { method: 'POST', body: formData }) .then(res => res.json()) .then(res => { if (res && 'error' in res && res.error === 0) { console.log('成功赠送主播 : '+ roomId + ' 一个荧光棒'); roomOfAnchorFan[roomId].anchorUp += 1; } else { console.log('赠送' + roomId + '失败 : ' + res.msg); } }); } let INVL_anchorUp = setInterval(() => { if (roomOfAnchorFan) { let roomIds = Object.keys(roomOfAnchorFan); for (let i = 0; i < roomIds.length; i++) { let roomId = roomIds[i]; if (roomOfAnchorFan[roomId].anchorUp === 0) { setTimeout(() => { donateYGB(roomId); }, (i+1) * 2000); } } window.clearInterval(INVL_anchorUp); INVL_anchorUp = null; console.log('启动完毕 : 赠送荧光棒'); } }, 1000); } // 检测是否出现 在电脑面前检测 setInterval(() => { if ($H2P('div.btn2-869c8d')) { $H2P('div.btn2-869c8d', false).forEach(ele => { ele.click() }); } }, 10000); // 检测是否出现 重新加载 setInterval(() => { if ($H2P('div.reload-0876b5') && $H2P('div.reload-0876b5').style.display != 'none') { $H2P('div.reload-0876b5', false).forEach(ele => { ele.click(); }); } }, 10000); // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // // 脚本自动化配置界面 // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // const LSConfig = 'h2p-DY-config-tool'; let config_tool_pre = { show0 : false, show9 : false, hideBar : false, hideSound : false, getFB : false, signIn : false, anchorUp : false, pausePlay : false, }; let config_tool = {}; Object.assign(config_tool, config_tool_pre); let config_tool_tmp = JSON.parse(localStorage.getItem(LSConfig)) || {}; Object.assign(config_tool, config_tool_tmp); for (let key in config_tool) { if (!(key in config_tool_pre)) { delete config_tool[key]; } } localStorage.removeItem(LSConfig); localStorage.setItem(LSConfig, JSON.stringify(config_tool)); if (config_tool.show0) { console.log('启动 : 最低画质'); auto_showDef(); } if (config_tool.show9) { console.log('启动 : 最高画质'); auto_showDef(); } if (config_tool.hideBar) { console.log('启动 : 自动禁止弹幕'); auto_hideBar(); } if (config_tool.hideSound) { console.log('启动 : 自动静音'); auto_hideSound(); } if (config_tool.getFB) { console.log('启动 : 自动领取观看鱼丸'); auto_getFB(); } if (config_tool.signIn) { console.log('启动 : 自动签到'); auto_signIn(); } if (config_tool.anchorUp) { console.log('启动 : 自动赠送荧光棒'); auto_anchorUp(); } if (config_tool.pausePlay) { console.log('启动 : 暂停播放'); auto_pausePlay(); } new Promise((resolve, reject) => { // 创建元素样式 =============================================================== let eleStyle = document.createElement('style'); eleStyle.type = 'text/css'; eleStyle.innerHTML += ` #h2p-div-config button { height: 25px; } `; document.head.appendChild(eleStyle); // 初始化配置界面 =============================================================== let div = document.createElement('div'); div.id = 'h2p-div-config'; div.className = 'h2p-div-inlinepanel'; div.style = 'display: none;'; div.innerHTML = `

`; let setINVL_wait_div_DYScript = setInterval(() => { if ($H2P('div#div-DYScript')) { window.clearInterval(setINVL_wait_div_DYScript); setINVL_wait_div_DYScript = null; $H2P('div#div-DYScript').appendChild(div); setTimeout(resolve, 250); } }, 500); }) .then(() => { let eleConfig = $H2P('div#h2p-div-config'); eleConfig.addEventListener('click', (event) => { let target = event.target; if (target.tagName.toLowerCase() !== 'button') { return; } target.classList.toggle('h2p-bg-open'); if (target.id === 'h2p-btn-config-show0') { config_tool.show0 = !config_tool.show0; config_tool.show9 = false; $H2P('button#h2p-btn-config-show9').classList.remove('h2p-bg-open'); } else if (target.id === 'h2p-btn-config-show9') { config_tool.show0 = false; $H2P('button#h2p-btn-config-show0').classList.remove('h2p-bg-open'); config_tool.show9 = !config_tool.show9; } else if (target.id === 'h2p-btn-config-hideBar') { config_tool.hideBar = !config_tool.hideBar; } else if (target.id === 'h2p-btn-config-hideSound') { config_tool.hideSound = !config_tool.hideSound; } else if (target.id === 'h2p-btn-config-getFB') { config_tool.getFB = !config_tool.getFB; } else if (target.id === 'h2p-btn-config-signIn') { config_tool.signIn = !config_tool.signIn; } else if (target.id === 'h2p-btn-config-anchorUp') { config_tool.anchorUp = !config_tool.anchorUp; } else if (target.id === 'h2p-btn-config-pausePlay') { config_tool.pausePlay = !config_tool.pausePlay; } localStorage.setItem(LSConfig, JSON.stringify(config_tool)); }, false); }) .then(() => { if (config_tool.show0) { $H2P('button#h2p-btn-config-show0').classList.add('h2p-bg-open'); } if (config_tool.show9) { $H2P('button#h2p-btn-config-show9').classList.add('h2p-bg-open'); } if (config_tool.hideBar) { $H2P('button#h2p-btn-config-hideBar').classList.add('h2p-bg-open'); } if (config_tool.hideSound) { $H2P('button#h2p-btn-config-hideSound').classList.add('h2p-bg-open'); } if (config_tool.getFB) { $H2P('button#h2p-btn-config-getFB').classList.add('h2p-bg-open'); } if (config_tool.signIn) { $H2P('button#h2p-btn-config-signIn').classList.add('h2p-bg-open'); } if (config_tool.anchorUp) { $H2P('button#h2p-btn-config-anchorUp').classList.add('h2p-bg-open'); } if (config_tool.pausePlay) { $H2P('button#h2p-btn-config-pausePlay').classList.add('h2p-bg-open'); } }) .catch(error => { console.log(error); }) })();