Greasy Fork is available in English.

斗鱼自动发送弹幕、领取鱼丸、清爽模式、调节画质、保持亲密度

抄袭弹幕、循环弹幕、关键词回复、抽奖弹幕 ________ 黑暗模式、清爽模式(显示直播时长,真实人数,去除弹幕标签) ________ 自动签到、领取鱼丸、批量取关、默认最低(高)画质、禁止滚动弹幕、自动静音、自动给有牌子的主播赠送一根荧光棒 ________ 设置界面功能自动化开启

Versão de: 29/04/2020. Veja: a última versão.

// ==UserScript==
// @name			斗鱼自动发送弹幕、领取鱼丸、清爽模式、调节画质、保持亲密度
// @namespace		http://tampermonkey.net/
// @version			1.4.10
// @icon			http://www.douyutv.com/favicon.ico
// @description		抄袭弹幕、循环弹幕、关键词回复、抽奖弹幕 ________ 黑暗模式、清爽模式(显示直播时长,真实人数,去除弹幕标签) ________ 自动签到、领取鱼丸、批量取关、默认最低(高)画质、禁止滚动弹幕、自动静音、自动给有牌子的主播赠送一根荧光棒 ________ 设置界面功能自动化开启
// @author			H2P
// @compatible		chrome
// @require			https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// @require			https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js
// @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
// @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 黑暗模式需要手动开启
// ==/UserScript==

(() => {
	'use strict';

	const $H2P = function (xpath, one = true) {
        if (one) { return document.querySelector(xpath); }
        else { return Array.from(document.querySelectorAll(xpath)); }
    }

	const isTopic = window.location.href.startsWith('https://www.douyu.com/topic/');
	const isFollowList = window.location.href.startsWith('https://www.douyu.com/directory/myFollow');

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 
// 															取消关注
// 
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //

	if (isFollowList){
		let anchorsSelected = [];
		
		new Promise((resolve, reject) => {
			let INVL_AddBtnCancelFollow = setInterval(() => {
				if ($H2P('div#filter-tab-expandable-wrapper') && !$H2P('a#a-cancelFollow')) {
					window.clearInterval(INVL_AddBtnCancelFollow);
					INVL_AddBtnCancelFollow = null;
					resolve();
				}
			}, 500);
		})
		.then(() => {
			let btn_cancelFollow = document.createElement('a');
			btn_cancelFollow.id = 'a-cancelFollow';
			btn_cancelFollow.className = 'layout-Module-label';
			btn_cancelFollow.innerHTML = `
				<strong>取消关注</strong>
			`;
			$H2P('div#filter-tab-expandable-wrapper').append(btn_cancelFollow);
		})
		.then(() => {
			$H2P('a#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;
	}








// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 
// 															全局变量
// 
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //








	// 解决 jQuery $ 符号冲突
	let $h2p_j = jQuery.noConflict();

	let BOOL_ok_clear   = false;			// 自动清理模块是否装载完毕
	let BOOL_ok_config  = false;			// 斗鱼设置模块是否装载完毕
	let BOOL_ok_localS  = false;			// localStorage 是否读取完毕

	let BOOL_vue_clear	= false;			// 自动清爽模式 Vue 是否构建完毕
	let BOOL_vue_config = false;			// 自动配置模块 Vue 是否构建完毕

	// 用户拥有牌子的主播信息
	let roomOfAnchorFan = undefined;

	let userInfo = {
		nickName	: '',				// 昵称
		isAnchorFan : false,			// 是否拥有主播的粉丝牌
	};	

	let roomInfo = {
		id		: '',
		showT	: 0,
		online	: 0,
		kind1	: '',
		kind2	: '',
	}

	const LSPre = 'h2p-DYScript-config';
	let h2p_DYScript_configPre = {};








// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 
// 															🐯和面板初始化
// 
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //










	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;
				border-radius	: 2px;
				margin 			: 0 0 0 -1px;
				box-shadow		: #c7c7c7 0 -10px 10px 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;
				border-radius	: 2px;
				font-family		: WeibeiSC-Bold, STKaiti;
				font-size		: 16px;
				background		: #f5f5f5;
			}

			#div-DYScript .h2p-flex-main-center {
				height          : 22px;
				margin          : 0 0 14px 0;
				display         : flex;
				flex-flow       : row wrap;
				justify-content : center;
				align-items     : center;
			}
			#div-DYScript .h2p-flex-main-start {
				height          : 22px;
				margin          : 0 0 15px 0;
				display         : flex;
				justify-content : flex-start;
				align-items     : center;
			}
			#div-DYScript .h2p-flex-main-end {
				height          : 22px;
				margin          : 0 0 15px 0;
				display         : flex;
				justify-content : flex-end;
				align-items     : center;
			}

			#div-DYScript .h2p-item-100p {
				width           : 100%;
			}
			#div-DYScript .h2p-item-50p {
				width           : 50%;
			}
			#div-DYScript .h2p-item-33p {
				width           : 33.33%;
			}

			#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;
			}
			#div-DYScript .h2p-bg-close	{ background : #00ddbb }
			#div-DYScript .h2p-bg-close:hover{ background : #00ccaa }
			#div-DYScript .h2p-bg-open	{ background : #99aaff }
			#div-DYScript .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 = `<span id="h2p-span-DYScript">🐯</span>`;
		
		
		// 整个面板 ===============================================================
		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 = `
			<div id="h2p-div-tab-bar" class="h2p-div-tab" style="background: #DDDDDD;" title="发弹幕">📢</div>
			<div id="h2p-div-tab-clear" class="h2p-div-tab" style="width: 33.4%" title="清爽模式">✡️</div>
			<div id="h2p-div-tab-config" class="h2p-div-tab" title="自动化设置">⏲️</div>
		`;
		$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 = undefined;
	let [Chat, INVL_SendBar, INVL_ShowCD] = [undefined, undefined, undefined];

	let luckBar	= '';				// 抽奖弹幕内容
	let CD_luckDraw	= 0;			// 弹幕抽奖活动倒计时
	let CNT_luckDraw = 0;			// 抽奖弹幕发送次数
	let Index_keyRe = 0;			// 关键词回复弹幕列表已经检测的位置

	// 初始化自动发弹幕界面  ===============================================================
	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;
				background: #66ddcc;
				cursor: pointer;
				transition: all 0.5s
			}

			#h2p-div-bar #h2p-btn-bar-send:hover {
				background: #55ccaa;
			}
			#h2p-div-bar #h2p-btn-bar-send span {
				display: inline-block;
				position: relative;
				transition: all 0.5s
			}
			#h2p-div-bar #h2p-btn-bar-send span:after {
				content: '🔥';
				position: absolute;
				opacity: 0;
				top: -2px;
				right: -20px;
				transition: 0.5s;
			}
			#h2p-div-bar #h2p-btn-bar-send:hover span {
				padding-right: 20px;
			}  
			#h2p-div-bar #h2p-btn-bar-send:hover span:after {
				opacity: 1;
				right: 0;
			}
			#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 = 'order: 0;';
		div.innerHTML = `
			<!-- 发送弹幕的速度 And 倒计时 -->
			<div class="h2p-flex-main-center">
				<div class="h2p-flex-main-start h2p-item-50p">
					<label>间隔</label>
					<input id="h2p-input-bar-invl-start" class="h2p-input-normal h2p-input-invl sendingDisabled" placeholder="≥3" />
					<span>~</span>
					<input id="h2p-input-bar-invl-end" class="h2p-input-normal h2p-input-invl sendingDisabled" />
					<label>秒</label>
				</div>
				<div class="h2p-flex-main-end h2p-item-50p">
					<input id="h2p-input-cd" class="h2p-input-normal h2p-input-disable" style="width: 32px;" disabled/>
				</div>
			</div>

			<!-- 是否参加弹幕抽奖 -->
			<div class="h2p-flex-main-center">
				<div class="h2p-flex-main-start h2p-item-50p">
					<input id="h2p-input-bar-isLuck" type="checkbox" />
					<label>抽奖弹幕</label>
				</div>
				<div class="h2p-flex-main-end h2p-item-50p">
					<label>抽奖发送</label>
					<input class="h2p-input-normal h2p-input-invl h2p-input-disable" disabled />
					<span>/</span>
					<input id="h2p-input-bar-luck-time" class="h2p-input-normal h2p-input-invl sendingDisabled" style="margin-right: 0;" placeholder="≥1" value="1" />
				</div>
			</div>

			<!-- 是否使用关键词自动回复 -->
			<div class="h2p-flex-main-center" style="margin: 0 0 8px 0;">
				<div class="h2p-flex-main-start h2p-item-50p">
					<input id="h2p-input-bar-isKeyRe" type="checkbox" />
					<label>关键词回复</label>
					<button id="h2p-btn-addKeyRe" class="h2p-btn-keyRe h2p-hover-pointer" title="添加关键词">+</button>
				</div>
				<div class="h2p-flex-main-end h2p-item-50p">
					<select id="h2p-select-keyRe" style="width: 100%; height: 24px;">
					</select>
				</div>
			</div>

			<div class="h2p-flex-main-center">
				<div class="h2p-flex-main-start h2p-item-50p">
					<button id="h2p-btn-delKeyRe" class="h2p-btn-keyRe h2p-hover-pointer" title="删除关键词">-</button>
					<input id="h2p-input-key" class="h2p-input-normal" style="width: 70%;" placeholder="关键词" />
				</div>
				<div class="h2p-flex-main-end h2p-item-50p">
					<input id="h2p-input-re" class="h2p-input-normal" style="width: 90%; padding: 0 4.2%;" placeholder="自动回复弹幕" />
				</div>
			</div>

			<!-- 是否发送抄袭弹幕 -->
			<div class="h2p-flex-main-center">
				<div class="h2p-flex-main-start h2p-item-50p">
					<input id="h2p-input-bar-isCopy" type="checkbox" />
					<label>抄袭弹幕</label>
				</div>
				<div class="h2p-flex-main-end h2p-item-50p">
					<label>抄袭间隔</label>
					<input id="h2p-input-bar-copy-invl" class="h2p-input-normal" style="margin-left: 5px; width: 48px;" placeholder="0 ~ 200" value="0"/>
				</div>
			</div>

			<!-- 是否发送循环弹幕 -->
			<div class="h2p-flex-main-center" style="height: 75px;">
				<input id="h2p-input-bar-isLoop" type="checkbox" />
				<textarea id="h2p-ta-bar-loopBar" class="h2p-ta-bar-loopBar" placeholder="循环弹幕"></textarea>
			</div>

			<!-- 开启弹幕发送按钮 -->
			<div class="h2p-flex-main-center" style="margin: 0 0 5px 0;">
				<button id="h2p-btn-bar-send">
					<span>发送</span>
				</button>
			</div>
		`;

		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.slice(0, 3); });
		eleInvlStart.addEventListener('keyup', () => { eleInvlStart.value = eleInvlStart.value.replace(/[^\d]/g, ''); });
		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.slice(0, 3); });
		eleInvlEnd.addEventListener('keyup', () => { eleInvlEnd.value = eleInvlEnd.value.replace(/[^\d]/g, ''); });
		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.slice(0, 2); });
		eleBarLuckTime.addEventListener('keyup', () => { eleBarLuckTime.value = eleBarLuckTime.value.replace(/[^\d]/g, ''); });
		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.slice(0, 3); });
		eleBarCopyInvl.addEventListener('keyup', () => { eleBarCopyInvl.value = eleBarCopyInvl.value.replace(/[^\d]/g, ''); });
		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('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-btn-active');
				eleSend.firstElementChild.textContent = "发送中";
            }
            else {
                window.clearTimeout(INVL_SendBar);
                INVL_SendBar = null;
                window.clearInterval(INVL_ShowCD);
				INVL_ShowCD = null;
				$H2P('input#h2p-input-cd').value = '';
                eleSend.classList.remove('h2p-btn-active');
                eleSend.firstElementChild.textContent = "发送";
            }
            localStorage.setItem(LSChat, JSON.stringify(config_chat));
        }, false)
	})
	.catch(error => console.log(error))
	// 读取配置参数
    .then(() => {
		if (!config_chat) { config_chat = JSON.parse(localStorage.getItem(LSChat)); }
		if (!config_chat) {
			let config = JSON.parse(localStorage.getItem(LSPre));
			if (config) {
				config_chat = {
					invlStart	: Math.floor(config.speedMin / 1000),
					invlEnd		: Math.floor(config.speedMax / 1000),
					luckTime	: config.CNT_luckDraw,
					isLuck		: config.isLuckDraw,
					isKeyRe		: config.isKeyReply,
					isCopy		: config.isCopy,
					copyInvl	: config.INVL_copy,
					isLoop		: config.isLoop,
					keyReBar	: config.keyReplys,
					loopBar		: config.loopBarCon,
				}
			}
			localStorage.setItem(LSChat, JSON.stringify(config_chat));
		}

		$H2P('input#h2p-input-bar-isLuck').checked = config_chat.isLuck || false;
		$H2P('input#h2p-input-bar-luck-time').value = config_chat.luckTim || 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 => {
        // 判断 localStorage 是否能够读取 h2p-DY-config-chat
        console.log(error);
        config_chat = config_chat || {};
        localStorage.removeItem(LSChat);
        localStorage.setItem(LSChat, JSON.stringify(config_chat));
	})
	
	function getBar () {
		let barrage = undefined;

		// 抽奖弹幕
		if (config_chat.isLuck && $H2P('div.LotteryDrawEnter-desc')) {
			// 计算目前倒计时
			let CD_luckDraw_now = $H2P('div.LotteryDrawEnter-desc').textContent.split(':').reduce((m, s) => Number(m) * 60 + Number(s));

			// 判断是否是新一轮抽奖
			if (CD_luckDraw_now > CD_luckDraw) {
				// 清除上一轮抽奖内容
				luckBar = undefined;
				// 新一轮抽奖弹幕
				CNT_luckDraw = 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 && (barREQM in REQMs || (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];
						luckBar = luckBar.slice(0, -2);
					}
				} catch (err) { console.log('不是弹幕抽奖'); }
				finally { $H2P('span.LotteryContainer-close').click(); }
			}

			barrage = CNT_luckDraw < config_chat.luckTime ? luckBar : undefined;
			if (barrage) { CNT_luckDraw++; }
			CD_luckDraw = CD_luckDraw_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];
				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; j++) {
						let keyRe = config_chat.keyReBar[j];
						if (bar_check.includes(keyRe.key)) {
							barrage = keyRe.re;
						}
					}
				}
			}
			if (Index_keyRe >= bars.length) { Index_keyRe = 0; }
		}

		// 抄袭弹幕
		if (!barrage && config_chat.isKeyRe && Array.isArray(config_chat.keyReBar)) {
			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(); }
			}
		}
	}








// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 
// 															清爽模式
// 
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //









	new Promise((resolve, reject) => {
		// 创建元素样式
		let eleStyle = document.createElement('style');
		eleStyle.type = 'text/css';
		eleStyle.innerHTML = `
			.h2p-btn-hideAll-back {
				position 		: fixed;
				right			: 0;
				bottom			: 0;
				width			: 55px;
				height			: 55px;
				padding			: 10px;
				border			: none;
				font-size		: 13px;
				background		: transparent;
				cursor			: pointer;
				display			: none;
			}
			.h2p-btn {
				width			: 100%;
				height			: 100%;
				padding			: 4px 0;
				border			: none;
				border-radius	: 5px;
				margin			: 0;
				font-size		: 13px;
				cursor			: pointer;
			}
			.h2p-tag		{}
			.h2p-bg-red	{ background-color : #ff8899; }
			.h2p-bg-red:hover	{ background-color : #ff5566; }
			.h2p-bg-bm		{ background-color: #2d2e37!important; }
			.h2p-top-0		{ top: 0!important; }
			.h2p-top-32		{ top: 32px!important; }
			.h2p-top-50		{ top: 50px!important; }
			.h2p-top-f-10	{ top: -10px!important; }
			.h2p-w-50p		{ width: 50%!important; }
			.h2p-w-96p		{ width: 96%!important; }
			.h2p-h-100p 	{ height: 100%!important; }
			.h2p-bg-black	{ background: black!important; }
			.h2p-padding-15 { padding: 15px!important; }
			.h2p-bottom-f-71{ bottom: -71px!important; }
			.h2p-bottom-f-315 { bottom: -315px!important; }
			.h2p-toolBar	{
				height: 70px!important;
				position: absolute!important;
				right: 0!important;
				bottom: -71px!important;
				left: 0!important;
			}
			.h2p-toolBar-Wealth	{
				width: auto!important;
				margin-top: 10px!important;
				margin-right: 10px!important;
			}
			.h2p-dp-inline-b{ display: inline-block!important; }
			.h2p-float-r	{ float: right!important; }
		`;
		document.head.appendChild(eleStyle);
		resolve()
	})
	// 初始化自动发弹幕界面  ===============================================================
	.then(() => {
		let str_div_light = `
			<div id="h2p-div-clear" class="h2p-div-inlinepanel" style="display: none">
				<hr style="margin: 6px; border: 1px solid transparent;">

				<!-- 导航栏、侧边栏、删除元素 -->
				<div class="h2p-div-layer" style="height: 27px;">
					<div class="h2p-div-layer-half" style="height: 100%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%">
							<div class="h2p-div-layer-half" style="height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':isClearHead, 'h2p-bg-close':!isClearHead}" @click="clearHead(false)">导航栏</button>
							</div>
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':isClearInfo, 'h2p-bg-close':!isClearInfo}" style="float: right" @click="clearInfo(false)">信息栏</button>
							</div>
						</div>
					</div>
					<div class="h2p-div-layer-half" style="height: 100%; left: 50%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%; float: right">
							<div class="h2p-div-layer-half" style="height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':isClearAside, 'h2p-bg-close':!isClearAside}" @click="clearAside(false)">侧边栏</button>
							</div>
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
							</div>
						</div>
					</div>
				</div>

				<hr style="margin: 2px 6px; border: 1px solid transparent;">

				<!-- 信息栏、弹幕栏、礼物栏、鱼吧 -->
				<div class="h2p-div-layer" style="height: 27px;">
					<div class="h2p-div-layer-half" style="height: 100%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%">
							<div class="h2p-div-layer-half" style="height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':isClearGift, 'h2p-bg-close':!isClearGift}" @click="clearGift(false)">礼物栏</button>
							</div>
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':isClearBar, 'h2p-bg-close':!isClearBar}" style="float: right" @click="clearBar(false)">弹幕栏</button>
							</div>
						</div>
					</div>
					<div class="h2p-div-layer-half" style="height: 100%; left: 50%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%; float: right">
							<div class="h2p-div-layer-half" style="height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':isClearPlay, 'h2p-bg-close':!isClearPlay}" @click="clearPlay(false)">播放器</button>
							</div>
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
								
							</div>
						</div>
					</div>
				</div>

				<hr style="margin: 6px; border: 1px solid transparent;">

				<!-- 删除元素 -->
				<div class="h2p-div-layer" style="height: 27px;">
					<div class="h2p-div-layer-half" style="height: 100%">
						<button class="h2p-btn h2p-w-96p h2p-bg-red" @click="cleanEle">删除元素</button>
					</div>
					<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
					</div>
				</div>
				
				<hr style="margin: 6px; border: 1px solid transparent;">

				<!-- 清爽模式、黑暗模式 -->
				<div class="h2p-div-layer" style="height: 27px;">
					<div class="h2p-div-layer-half" style="height: 100%">
						<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':isHideCM, 'h2p-bg-close':!isHideCM}" @click="hideCM">清爽模式</button>
					</div>
					<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
						<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':ishideBM, 'h2p-bg-close':!ishideBM}" style="float: right" @click="hideBM">黑暗模式</button>
					</div>
				</div>
				
				<hr style="margin: 6px; border: 1px solid transparent;">

				<!-- 宽屏模式、网页全屏 -->
				<div class="h2p-div-layer" style="height: 27px;">
					<div class="h2p-div-layer-half" style="height: 100%">
						<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':isHideWS, 'h2p-bg-close':!isHideWS}" @click="hideWS">宽屏模式</button>
					</div>
					<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
						<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':isHideFS, 'h2p-bg-close':!isHideFS}" style="float: right" @click="hideFS">网页全屏</button>
					</div>
				</div>

				<hr style="margin: 6px; border: 1px solid transparent;">
			</div>
		`;
		let div_light = $h2p_j(str_div_light);

		let setINVL_wait_div_DYScript = setInterval(() => {
			if ($H2P('div#div-DYScript')) {
				window.clearInterval(setINVL_wait_div_DYScript);
				setINVL_wait_div_DYScript = null;
				$h2p_j('div#div-DYScript').append(div_light);
				setTimeout(() => { BOOL_ok_clear = true; }, 500);
			}
		}, 500);
	});

	let vue_light = undefined;
	// 清爽模式组件构建 Vue
	let startPS = 0;
	let startWS = 0;
	let startFS = 0;
	let waitMin = 3;
	let waitSec = 3;

	let INVL_createVue_clear = setInterval(() => {
		if (BOOL_ok_clear) {
			window.clearInterval(INVL_createVue_clear);
			INVL_createVue_clear = null;

			// 在弹幕栏上添加热度
			if (!$H2P('div.layout-Player-announce > div#div-anchorHot')) {
				let ele = $h2p_j(`
					<div id="div-anchorHot" class="AnchorAnnounce h2p-h-100p" style="padding: 5px 7px 0; display: none;">
						<div class="Title-blockInline">
							<a id="a-anchorHot" class="Title-anchorHot" title="直播热度">
								<i class="Title-anchorHotIcon" style="margin-top: -4px">
									<svg style="width: 15px; height: 15px;">
										<use xlink:href="#hot_84f8212"></use>
									</svg>
								</i>
								<div class="Title-anchorText">0</div>
							</a>
						</div>
						<div class="Title-blockInline">
							<div id="div-online" title="真实人数" style="margin-top: -7px">
								<div class="Title-anchorFriendWrapper">
									<div class="Title-row-span">
										<span class="Title-row-icon">
											<svg style="width:15px; height:15px">
												<use xlink:href="#friend_b0b6380"></use>
											</svg>
										</span>
										<i class="Title-row-text">0</i>
									</div>
								</div>
							</div>
						</div>
						<div class="Title-blockInline">
							<a id="a-anchorShowT" class="Title-anchorHot" title="直播时长">
								<div class="AnchorFriendCard-avatar is-live" style="height: 19px; border: none; margin: 2px 5px 0 -4px;"></div>
								<div class="Title-anchorText">0</div>
							</a>
						</div>
					</div>
				`);
				$h2p_j('div.layout-Player-announce').append(ele);

				setTimeout(() => {
					let anchorHot = parseInt( $h2p_j('div.Title-anchorInfo.clearFix > a.Title-anchorHot > div.Title-anchorText').text() );
					let str_anchorHot = '';
					if ( anchorHot > 9999 ) { str_anchorHot = parseInt(anchorHot/10000) + 'w'; }
					if ( !anchorHot ){  str_anchorHot = '0'; }
					$h2p_j('a#a-anchorHot > div.Title-anchorText').text(str_anchorHot);
					let start_INVL = new Date().getTime() / 1000;
					let INVL_waitAnchorShowT = setInterval(() => {
						if ( roomInfo.showT > 0 ) {
							window.clearInterval(INVL_waitAnchorShowT);
							let showT = parseInt( (new Date().getTime() / 1000) - roomInfo.showT) / 3600.0;
							let h = parseInt( showT );
							let m = parseInt( ( showT - h ) * 60 );
							let s = 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_j('a#a-anchorShowT > div.Title-anchorText').text(strShowT);
							}, 1000);
						} else {
							if (((new Date().getTime() / 1000) - start_INVL) > 15) {
								window.clearInterval(INVL_waitAnchorShowT);
								console.log(`直播间信息 ${JSON.stringify(roomInfo)}`)
							}
						}
					}, 1000);
					// 直播热度和在线人数
					setInterval(() => {
						let anchorHot = parseInt($h2p_j('div.Title-roomInfo a.Title-anchorHot div.Title-anchorText').text());
						let str_anchorHot = '' + anchorHot;
						if ( anchorHot > 9999 ) { str_anchorHot = parseInt(anchorHot/10000) + 'w'; }
						$h2p_j('a#a-anchorHot > div.Title-anchorText').text(str_anchorHot);

						let online = roomInfo.online;
						let str_online = '' + online;
						if ( online > 9999 ) { str_online = parseInt(online/10000) + 'w'; }
						$h2p_j('div#div-online i.Title-row-text').text(str_online);
					}, 5000);
				}, 200);
			}

			vue_light = new Vue({
				el		: '#h2p-div-clear',
				data	: {
					isClearHead	: false,
					isClearAside: false,
					isClearInfo	: false,
					isClearBar	: false,
					isClearGift	: false,
					isClearPlay	: false,
					isCleanEle	: false,
					isHideCM	: false,		// clear mode
					ishideBM	: false,		// part screen
					isHideWS	: false,		// wide screen
					isHideFS	: false,		// full screen
					topicBG		: '',
					topicH		: 0,
				},
				methods	: {
					clearHead	: (notChangelocalStorage)=>{
						// 斗鱼 logo、粉丝节、客户端、开播、创世幻神
						let eles = ['a.Header-logo', 'div.HeaderNav', 'div.Header-download-wrap', 'div.Header-broadcast-wrap', 'span.HeaderGif-left', 'span.HeaderGif-right', 'ul.Header-menu > li:eq(1)', 'ul.Header-menu > li:gt(2)'];
						eles.forEach( ele => { $h2p_j(ele).toggle(); } );
						vue_light.isClearHead = !vue_light.isClearHead;
						if (vue_light.isHideCM && !notChangelocalStorage){
							h2p_DYScript_config.isClearHead = vue_light.isClearHead;
							localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
						}
					},
					clearAside	: (notChangelocalStorage)=>{
						$h2p_j('aside#js-aside').toggle();
						vue_light.isClearAside = !vue_light.isClearAside;
						if (vue_light.isHideCM && !notChangelocalStorage){
							h2p_DYScript_config.isClearAside = vue_light.isClearAside;
							localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
						}
					},
					clearInfo	: (notChangelocalStorage)=>{
						$h2p_j('div#js-player-title').css('min-height', 'auto');
						// 头像、举报、分区、友邻、主播等级、主播体重、公会
						let eles = ['div.Title-anchorPic', 'div.Title-roomInfo > div.Title-row:nth-child(1) div.Title-blockInline:nth-child(2)',
									'div.Title-addFriend', 'div.Title-row:nth-child(3)', 'div.Title-AnchorLevel', 'div.Title-sharkWeight',
									'div.SociatyLabel'];
						eles.forEach(ele => { $h2p_j(ele).toggle(); });
						$h2p_j('div.Title').toggleClass('h2p-h-100p');
						vue_light.isClearInfo = !vue_light.isClearInfo;
						if (vue_light.isHideCM && !notChangelocalStorage){
							h2p_DYScript_config.isClearInfo = vue_light.isClearInfo;
							localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
						}
					},
					clearBar	: (notChangelocalStorage)=>{
						$h2p_j('div[class="AnchorAnnounce"]').toggle();
						$h2p_j('div.MatchSystemChatRoomEntry').toggle();
						$h2p_j('div.layout-Player-rank').toggle();
						$h2p_j('div#js-player-barrage').toggleClass('h2p-top-32');
						// 弹幕输入框
						$h2p_j('div.Horn4Category').toggle();
						$h2p_j('div.ChatNobleBarrage').toggle();
						$h2p_j('div.BarrageSuperLink').toggle();
						$h2p_j('div#div-anchorHot').toggle();
						// 直播热度和真实人数
						$h2p_j('div.Title-anchorInfo.clearFix a.Title-anchorHot').toggle();
						$h2p_j('div#div-online-1').toggle();
						vue_light.isClearBar = !vue_light.isClearBar;
						if (vue_light.isHideCM && !notChangelocalStorage){
							h2p_DYScript_config.isClearBar = vue_light.isClearBar;
							localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
						}
					},
					clearGift	: (notChangelocalStorage)=>{
						// 弹幕抽奖
						$H2P('div.ToolbarActivityArea > div:nth-child(2)').style = 'display: inline-block;';

						$H2P('div.layout-Player-toolbar').classList.toggle('h2p-toolBar');
						// 礼物、任务大厅、点击展开、玩游戏豪送、抢位英雄
						let eles = ['div.PlayerToolbar-GiftWrap', 'div.PlayerToolbar-Task', 'div.ExpandWrap', 'div.PlayerToolbar-signCont', 'div.ActivityItem[data-flag=""]'];
						eles.forEach( ele => { $h2p_j(ele).toggle(); } );
						setTimeout(() => {
							let eleHides = ['div.ActivityList > div', 'div.ActivityList > div[data-flag="grab_hero"]', 'div.TurntableLottery', 'div.BattleShipEnter', 'div.RomanticDateComponent']
							eleHides.forEach( ele => { $h2p_j(ele).hide(); } );
							let eleShows = ['div.ActivityList > div[data-flag="anchor_quiz"]', 'div.ActivityList > div[data-flag="room_level"]']
							eleShows.forEach( ele => { $h2p_j(ele).show(); } );
							$h2p_j('div.PlayerToolbar > div.PlayerToolbar-Content').toggleClass('h2p-dp-inline-b');
							$h2p_j('div.PlayerToolbar > div.PlayerToolbar-Content').toggleClass('h2p-w-50p');
							$h2p_j('div.PlayerToolbar > div.PlayerToolbar-Content:last > div.PlayerToolbar-ContentRow').toggleClass('h2p-float-r');
						}, 500);
						// $h2p_j('div.PlayerToolbar').toggleClass('h2p-padding-15');
						$h2p_j('div.PlayerToolbar-Wealth').toggleClass('h2p-toolBar-Wealth');
						$h2p_j('div.layout-Player-asideMain').toggleClass('h2p-bottom-f-71');

						let INVL_waitGuessMain = setInterval(() => {
							if ($h2p_j('div#guess-main-panel').length > 0){
								// 竞猜面板
								$h2p_j('div.guessGameContainer.is-normalRoom').toggleClass('h2p-bottom-f-315');
								$h2p_j('div#guess-main-panel').toggleClass('h2p-top-f-10');
								window.clearInterval(INVL_waitGuessMain);
							}
						}, 200);

						vue_light.isClearGift = !vue_light.isClearGift;
						if (vue_light.isHideCM && !notChangelocalStorage){
							h2p_DYScript_config.isClearGift = vue_light.isClearGift;
							localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
						}
					},
					clearPlay	: (notChangelocalStorage)=>{
						// topic
						if (!vue_light.isCleanEle) {
							$h2p_j('video.video-header').toggle();
							$h2p_j('div.bc-wrapper:first').toggle();
							if ( !vue_light.isClearPlay ) {
								let distance = $h2p_j('header#js-header').height() + 10;
								$h2p_j('div.bc-wrapper:eq(1)').css('margin-top', distance + 'px');
							} else {
								$h2p_j('div.bc-wrapper:eq(1)').css('margin-top', '');
							}
						}
						$h2p_j('div.bc-wrapper:gt(1)').toggle();
						$h2p_j('div.MatchSystemGuide').toggle();

						let eles = ['div#js-bottom', 'div.guessGameContainer.is-normalRoom', 'div.ActivityList > div.ActivityItem:gt(0)', 'div#js-room-activity'];
						eles.forEach( ele => { $h2p_j(ele).toggle(); } );

						vue_light.isClearPlay = !vue_light.isClearPlay;
						if (vue_light.isHideCM && !notChangelocalStorage){
							h2p_DYScript_config.isClearPlay = vue_light.isClearPlay;
							localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
						}
					},
					clearAll	: () => {
						if (!vue_light.isClearHead) { vue_light.clearHead(); }
						if (!vue_light.isClearAside) { vue_light.clearAside(); }
						if (!vue_light.isClearPlay) { vue_light.clearPlay(); }
						if (!vue_light.isClearBar) { vue_light.clearBar(); }
						if (!vue_light.isClearInfo) { vue_light.clearInfo(); }
						if (!vue_light.isClearGift) { vue_light.clearGift(); }
					},
					clearCancel	: () => {
						if (vue_light.isClearHead) { vue_light.clearHead(); }
						if (vue_light.isClearAside) { vue_light.clearAside(); }
						if (vue_light.isClearPlay) { vue_light.clearPlay(); }
						if (vue_light.isClearBar) { vue_light.clearBar(); }
						if (vue_light.isClearInfo) { vue_light.clearInfo(); }
						if (vue_light.isClearGift) { vue_light.clearGift(); }
					},
					cleanEle: () => {
						console.log('删除元素');
						// topic
						if (!vue_light.isCleanEle) {
							$h2p_j('video.video-header').remove();
							$h2p_j('div.wm-h5-view').remove();
							setTimeout(() => { $h2p_j('div.bc-wrapper:first').remove(); }, 1000);
						}
						$h2p_j('div.bc-wrapper:gt(1)').remove();
						$h2p_j('div.MatchSystemGuide').remove();
						let distance = $h2p_j('header#js-header').height() + 10;
						$h2p_j('div.bc-wrapper:eq(1)').css({
							'margin-top'		: distance + 'px',
							'background-color'	: '',
							'background-image'	: '',
						});

						let eles = ['div#js-bottom', 'div.guessGameContainer.is-normalRoom', 'div#js-room-activity'];
						eles.forEach( ele => { $h2p_j(ele).remove(); } );

						if (!vue_light.isClearBar) { vue_light.clearBar(); }

						vue_light.isCleanEle = true;
					},
					hideCM	: () => {
						if (vue_light.isHideWS) { vue_light.hideWS(); }
						if (vue_light.isHideFS) { vue_light.hideFS(); }

						if (vue_light.isHideCM) { 
							if ( vue_light.isClearHead && h2p_DYScript_config.isClearHead ) { vue_light.clearHead(true); }
							if ( vue_light.isClearAside && h2p_DYScript_config.isClearAside ) { vue_light.clearAside(true); }
							if ( vue_light.isClearPlay && h2p_DYScript_config.isClearPlay ) { vue_light.clearPlay(true); }
							if ( vue_light.isClearBar && h2p_DYScript_config.isClearBar ) { vue_light.clearBar(true); }
							if ( vue_light.isClearInfo && h2p_DYScript_config.isClearInfo ) { vue_light.clearInfo(true); }
							if ( vue_light.isClearGift && h2p_DYScript_config.isClearGift ) { vue_light.clearGift(true); }
						}
						else {
							if ( !vue_light.isClearHead && h2p_DYScript_config.isClearHead ) { vue_light.clearHead(true); }
							if ( !vue_light.isClearAside && h2p_DYScript_config.isClearAside ) { vue_light.clearAside(true); }
							if ( !vue_light.isClearPlay && h2p_DYScript_config.isClearPlay ) { vue_light.clearPlay(true); }
							if ( !vue_light.isClearBar && h2p_DYScript_config.isClearBar ) { vue_light.clearBar(true); }
							if ( !vue_light.isClearInfo && h2p_DYScript_config.isClearInfo ) { vue_light.clearInfo(true); }
							if ( !vue_light.isClearGift && h2p_DYScript_config.isClearGift ) { vue_light.clearGift(true); }
						}
						vue_light.isHideCM = !vue_light.isHideCM;
					},
					hideBM		: () => {
						vue_light.ishideBM = !vue_light.ishideBM;
						console.log(vue_light.ishideBM ? '开启黑暗模式' : '关闭黑暗模式');

						let headerFontLeft = $H2P('header#js-header ul.Header-menu > li a', false).filter(ele => !ele.classList.contains('Category-item') && !ele.parentNode.classList.contains('active'));
						let headerFontRight = $H2P('header#js-header div.Header-right a', false).filter(ele => ele.classList.contains('public-DropMenu-link'));

						if (vue_light.ishideBM) {
							$H2P('div.Header-wrap').classList.add('h2p-bg-bm');
							$H2P('main.layout-Main').classList.add('h2p-bg-bm');
							$H2P('div.FishpondTreasure-v4-area').classList.add('h2p-bg-bm');
							// header 左边
							$H2P('div.Header-wrap').style.borderBottomColor = '#2d2e37';
							headerFontLeft.forEach(ele => { ele.style.color = '#a7a7a7'; });
							// header 右边
							$H2P('header#js-header div.Header-right div.Search').style = 'background-color: #2d2e37; border: 1px solid #444455;';
							$H2P('header#js-header div.Header-right div.Search svg.Header-icon').style.color = '#a7a7a7';
							headerFontRight.forEach(ele => { ele.style.color = '#a7a7a7'; });
							// 主播信息
							$H2P('div#js-player-title').style = 'background-color: #2d2e37; border-color: #444455; border-bottom-color: #2d2e37;';
							$H2P('div.Title-roomInfo div.Title-row h3.Title-header').style.color = '#a7a7a7';
							$H2P('div.Title-roomInfo div.Title-row h2.Title-anchorNameH2').style.color = '#a7a7a7';
							$H2P('div.Title-roomInfo div.Title-row a.Title-anchorHot div.Title-anchorText').style.color = '#a7a7a7';
							$H2P('div.Title-roomInfo div.Title-anchorLocation span', false).forEach(ele => { ele.style.color = '#a7a7a7'; });
							$H2P('div.Title-roomInfo div.Title-sharkWeight span', false).forEach(ele => { ele.style.color = '#a7a7a7'; });
							$H2P('div.Title-roomInfo div.Title-row div.Title-blockInline span', false).forEach(ele => { ele.style.color = '#a7a7a7'; });
							// 礼物栏
							$H2P('div#js-player-toolbar').style = 'background-color: #2d2e37; border-color: #444455;';
							$H2P('div#js-player-toolbar div.PlayerToolbar-ywInfo span', false).forEach(ele => { ele.style.color = '#a7a7a7'; });
							$H2P('div#js-player-toolbar div.PlayerToolbar-ycInfo span', false).forEach(ele => { ele.style.color = '#a7a7a7'; });
							$H2P('div#js-player-toolbar div.RoomText-wrap').style.backgroundColor = '#2d2e37';
							// 弹幕栏
							$H2P('div.layout-Player-announce').style = 'background-color: #2d2e37; border-bottom-color: #444455;';
							$H2P('div.layout-Player-rank ul.ChatTabContainer-titleWraper--tabTitle li', false).forEach(ele => { ele.style = 'background-color: #2d2e37; border-color: #444455;'; });
							// 弹幕栏 - 周榜
							$H2P('div.ChatRankWeek-headerContent').style.backgroundColor = '#2d2e37';
							// 弹幕栏 - 贵宾
							$H2P('div.NobleRank').style.backgroundColor = '#2d2e37';
							$H2P('div.NobleRankTips').style.backgroundColor = '#2d2e37';
							// 弹幕栏 - 粉丝团
							$H2P('div.FansRankInfo').style.backgroundColor = '#2d2e37';
							$H2P('div.FansRankInfo span').style.color = '#a7a7a7';
							$H2P('div.ChatTabContainer').style.backgroundColor = '#2d2e37';
							// 弹幕栏 - 主体
							$H2P('div#js-player-asideMain').style = 'background-color: #2d2e37; border-color: #444455;';
							$H2P('div.Barrage-main').style.backgroundColor = '#2d2e37';
							if ($H2P('style#h2p-style-bar')) {
								document.body.append($H2P('style#h2p-style-bar'));
							} else {
								let barStyle = document.createElement('style');
								barStyle.id = 'h2p-style-bar';
								barStyle.innerHTML = `.Barrage-content{ color: #a7a7a7; }`;
								document.body.append(barStyle);
							}
							$H2P('div.Barrage').style.borderColor = '#444455';
							// 弹幕栏 - 聊天框
							$H2P('div.layout-Player-chat').style.backgroundColor = '#2d2e37';
							$H2P('div.layout-Player-chat textarea.ChatSend-txt').style = 'background-color: #2d2e37; color: #a7a7a7;';
							// 弹幕栏脚本面板
							$H2P('div#div-anchorHot').style.backgroundColor = '#2d2e37';
							$H2P('div#div-anchorHot').style.borderBottom = '1px solid #444455';
							$H2P('div#div-anchorHot div.Title-anchorText', false).forEach(ele => { ele.style.color = '#a7a7a7'; });
							$H2P('div#div-anchorHot div.Title-blockInline:nth-child(2) span.Title-row-icon').style.color = '#a7a7a7';
							$H2P('div#div-anchorHot div.Title-blockInline:nth-child(2) i.Title-row-text').style.color = '#a7a7a7';
							// 脚本面板
							$H2P('div#div-DYScript > div', false).forEach(ele => { ele.style.backgroundColor = '#2d2e37'; });
							$H2P('div#h2p-div-bar').style.color = '#a7a7a7';
							// 互动预言
							$H2P('div#guess-main-panel').style = 'background: #2d2e37; border-color: #444455;';
							$H2P('div.GuessMainPanelHeader-panelLeft span.GuessMainPanelHeader-slogon').style.color = '#a7a7a7';
							// 友邻
							$H2P('div.AnchorFriendPane-title h3').style.color = '#a7a7a7';
							$H2P('div.AnchorLike-ItemBox').style.borderColor = '#444455';
							$H2P('div.AnchorFriendPane-title').style.borderBottomColor = '#444455';
							$H2P('div.AnchorFriend-footer').style.borderTopColor = '#444455';
							$H2P('div.AnchorFriend-footer a', false).forEach(ele => { ele.style = 'background: #2d2e37, color: #a7a7a7'; });
							}
						else {
							$H2P('div.Header-wrap').classList.remove('h2p-bg-bm');
							$H2P('main.layout-Main').classList.remove('h2p-bg-bm');
							$H2P('div.FishpondTreasure-v4-area').classList.remove('h2p-bg-bm');
							// header 左边
							$H2P('div.Header-wrap').style.borderBottomColor = '';
							headerFontLeft.forEach(ele => { ele.style.color = ''; });
							// header 右边
							$H2P('header#js-header div.Header-right div.Search').style = '';
							$H2P('header#js-header div.Header-right div.Search svg.Header-icon').style.color = '';
							headerFontRight.forEach(ele => { ele.style.color = ''; });
							// 主播信息
							$H2P('div#js-player-title').style = '';
							$H2P('div.Title-roomInfo div.Title-row h3.Title-header').style.color = '';
							$H2P('div.Title-roomInfo div.Title-row h2.Title-anchorNameH2').style.color = '';
							$H2P('div.Title-roomInfo div.Title-row a.Title-anchorHot div.Title-anchorText').style.color = '';
							$H2P('div.Title-roomInfo div.Title-anchorLocation span', false).forEach(ele => { ele.style.color = ''; });
							$H2P('div.Title-roomInfo div.Title-sharkWeight span', false).forEach(ele => { ele.style.color = ''; });
							$H2P('div.Title-roomInfo div.Title-row div.Title-blockInline span', false).forEach(ele => { ele.style.color = ''; });
							// 礼物栏
							$H2P('div#js-player-toolbar').style = '';
							$H2P('div#js-player-toolbar div.PlayerToolbar-ywInfo span', false).forEach(ele => { ele.style.color = ''; });
							$H2P('div#js-player-toolbar div.PlayerToolbar-ycInfo span', false).forEach(ele => { ele.style.color = ''; });
							$H2P('div#js-player-toolbar div.RoomText-wrap').style.backgroundColor = '';
							// 弹幕栏
							$H2P('div.layout-Player-announce').style = '';
							$H2P('div.layout-Player-rank ul.ChatTabContainer-titleWraper--tabTitle li', false).forEach(ele => { ele.style.backgroundColor = ''; });
							// 弹幕栏 - 周榜
							$H2P('div.ChatRankWeek-headerContent').style.backgroundColor = '';
							// 弹幕栏 - 贵宾
							$H2P('div.NobleRank').style.backgroundColor = '';
							$H2P('div.NobleRankTips').style.backgroundColor = '';
							// 弹幕栏 - 粉丝团
							$H2P('div.FansRankInfo').style.backgroundColor = '';
							$H2P('div.FansRankInfo span').style.color = '';
							$H2P('div.ChatTabContainer').style.backgroundColor = '';
							// 弹幕栏 - 主体
							$H2P('div#js-player-asideMain').style = '';
							$H2P('div.Barrage-main').style.backgroundColor = '';
							document.head.insertBefore($H2P('style#h2p-style-bar'), $H2P('head > title'));
							$H2P('div.Barrage').style.borderColor = '';
							// 弹幕栏 - 聊天框
							$H2P('div.layout-Player-chat').style.backgroundColor = '';
							$H2P('div.layout-Player-chat textarea.ChatSend-txt').style = 'color: rgb(169, 169, 169);';
							// 弹幕栏脚本面板
							$H2P('div#div-anchorHot').style.backgroundColor = '';
							$H2P('div#div-anchorHot').style.borderBottom = '';
							$H2P('div#div-anchorHot div.Title-anchorText', false).forEach(ele => { ele.style.color = ''; });
							$H2P('div#div-anchorHot div.Title-blockInline:nth-child(2) span.Title-row-icon').style.color = '';
							$H2P('div#div-anchorHot div.Title-blockInline:nth-child(2) i.Title-row-text').style.color = '';
							// 脚本面板
							$H2P('div#div-DYScript > div', false).forEach(ele => { ele.style.backgroundColor = ''; });
							$H2P('div#h2p-div-bar').style.color = '';
							// 互动预言
							$H2P('div#guess-main-panel').style = '';
							$H2P('div.GuessMainPanelHeader-panelLeft span.GuessMainPanelHeader-slogon').style.color = '';
							// 友邻
							$H2P('div.AnchorFriendPane-title h3').style.color = '';
							$H2P('div.AnchorLike-ItemBox').style.borderColor = '';
							$H2P('div.AnchorFriendPane-title').style.borderBottomColor = '';
							$H2P('div.AnchorFriend-footer').style.borderTopColor = '';
							$H2P('div.AnchorFriend-footer a', false).forEach(ele => { ele.style = ''; });
						}
					},
					hideWS		: () => {
						if (vue_light.isHideCM) { vue_light.hideCM(); }
						if (vue_light.isHideFS) { vue_light.hideFS(); }
						vue_light.clearCancel();

						$h2p_j('div#js-room-activity').toggle();				// 分区冠军赛

						setTimeout(() => {
							let eles = ['div.PlayerToolbar-GiftWrap', 'div.PlayerToolbar-Task'];
							eles.forEach( ele => { $h2p_j(ele).toggle(); } );
							let eleHides = ['div.ActivityList > div', 'div.ActivityList > div[data-flag="grab_hero"']
							eleHides.forEach( ele => { $h2p_j(ele).hide(); } );
							let eleShows = ['div.ActivityList > div[data-flag="anchor_quiz"]', 'div.ActivityList > div[data-flag="room_level"]']
							eleShows.forEach( ele => { $h2p_j(ele).show(); } );
						}, 350);

						if (!vue_light.isHideWS) {
							vue_light.isHideWS = true;
							vue_light.clearBar();

							$h2p_j('div.PlayerToolbar-reactGroup').css('display', 'block');

							startWS = new Date().getTime();
							let setINVL_waitWS = setInterval(() => {
								if ( $h2p_j('div.wfs-2a8e83').length > 0 ) {
									$h2p_j('div.wfs-2a8e83').click();
									window.clearInterval(setINVL_waitWS);
									setINVL_waitWS = null;
								} else if ((new Date().getTime() - startWS) > waitSec) {
									window.clearInterval(setINVL_waitWS);
									setINVL_waitWS = null;
								}
							}, 200);

							// 放大弹幕栏
							$h2p_j('div#js-player-barrage').css('top', '0');
						}
						else {
							vue_light.isHideWS = false;

							$h2p_j('div.PlayerToolbar-reactGroup').css('display', '');

							startWS = new Date().getTime();
							let setINVL_waitWS = setInterval(() => {
								if ($H2P('div.wfs-exit-180268')) {
									$H2P('div.wfs-exit-180268').click();
									window.clearInterval(setINVL_waitWS);
									setINVL_waitWS = null;
								} else if ( (new Date().getTime() - startWS) > waitSec ) {
									window.clearInterval(setINVL_waitWS);
									setINVL_waitWS = null;
								}
							}, 200);

							// 还原弹幕栏
							$h2p_j('div#js-player-barrage').css('top', '256px');
						}
					},
					hideFS		: () => {
						if (vue_light.isHideCM) { vue_light.hideCM(); }
						if (vue_light.isHideWS) { vue_light.hideWS(); }

						$h2p_j('div#js-room-activity').toggle();				// 分区冠军赛

						if (!vue_light.isHideFS) {
							vue_light.isHideFS = true;

							startFS = new Date().getTime();
							let setINVL_waitFS = setInterval(() => {
								if ( $h2p_j('div.wfs-2a8e83').length > 0 ) {
									$h2p_j('div.wfs-2a8e83').click();
									// 隐藏弹幕框
									setTimeout(() => { $h2p_j('label.layout-Player-asidetoggleButton').click(); }, 200);
									window.clearInterval(setINVL_waitFS);
									setINVL_waitFS = null;
								} else if ( (new Date().getTime() - startFS) > waitSec ) {
									window.clearInterval(setINVL_waitFS);
									setINVL_waitFS = null;
								}
							}, 200);
						}
						else {
							vue_light.isHideFS = false;
							
							startFS = new Date().getTime();
							let setINVL_waitFS = setInterval(() => {
								if ($H2P('div.wfs-exit-180268')) {
									// 显示弹幕框
									$H2P('label.layout-Player-asidetoggleButton').click();
									setTimeout(() => { $H2P('div.wfs-exit-180268').click(); }, 200);
									window.clearInterval(setINVL_waitFS);
									setINVL_waitFS = null;
								} else if ( (new Date().getTime() - startFS) > waitSec ) {
									window.clearInterval(setINVL_waitFS);
									setINVL_waitFS = null;
								}
							}, 200);
						}
					},
				},
			});
			
			BOOL_vue_clear = true;
		}
	}, 500 );

	$h2p_j(document).ready().keydown(function (e) {
		// ESC 按键
		if (e.which === 27) {
			if (vue_light.isHideCM) vue_light.hideCM();
			else if (vue_light.isHideWS) vue_light.hideWS();
			else if (vue_light.isHideFS) vue_light.hideFS();
		}
		let myKeyCode = { 'a':65, 's':83, 'c': 67, 'd':68, 'u': 85, 'i': 73, 'o': 79, 'p': 80, }
		// shift a
		if (e.shiftKey && e.which == myKeyCode.a) {
			if ($H2P('span#h2p-span-DYScript')) {
				if (!viewShow_script) {
					$h2p_j('span#h2p-span-DYScript').click();
					$h2p_j('div#h2p-div-tab-bar').click();
				} else {
					if ( viewShow_bar ) { $h2p_j('span#h2p-span-DYScript').click(); }
					else { $h2p_j('div#h2p-div-tab-bar').click(); }
				}
			}
		}
		else if (e.shiftKey && e.which == myKeyCode.s) {
			if ($H2P('span#h2p-span-DYScript')) {
				if (!viewShow_script) {
					$h2p_j('span#h2p-span-DYScript').click();
					$h2p_j('div#h2p-div-tab-clear').click();
				} else {
					if (viewShow_clear) { $h2p_j('span#h2p-span-DYScript').click(); }
					else { $h2p_j('div#h2p-div-tab-clear').click(); }
				}
			}
		}
		else if (e.shiftKey && e.which == myKeyCode.d) {
			if ($H2P('span#h2p-span-DYScript')) {
				if (!viewShow_script) {
					$h2p_j('span#h2p-span-DYScript').click();
					$h2p_j('div#h2p-div-tab-config').click();
				} else {
					if (viewShow_config) { $h2p_j('span#h2p-span-DYScript').click(); }
					else { $h2p_j('div#h2p-div-tab-config').click(); }
				}
			}
		}
		// 清爽模式快捷键
		else if (e.shiftKey && e.which == myKeyCode.u) {
			if (vue_light){ vue_light.hideCM(); }
		}
		else if (e.shiftKey && e.which == myKeyCode.i) {
			if (vue_light){ vue_light.hideBM(); }
		}
		else if (e.shiftKey && e.which == myKeyCode.o) {
			if (vue_light){ vue_light.hideWS(); }
		}
		else if (e.shiftKey && e.which == myKeyCode.p) {
			if (vue_light){ vue_light.hideFS(); }
		}
		else if (e.shiftKey && e.which == myKeyCode.c) {
			// 清空弹幕
			if (document.getElementsByClassName('Barrage-toolbarText').length > 0) {
				document.getElementsByClassName('Barrage-toolbarText')[1].click();
			}
		}
	});







	
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 
// 																自动化设置
// 
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //








	// 自动领取观看鱼丸
	let auto_getFB = () => {
		let INVL_autoGetFB = setInterval(() => {
			// 观看鱼丸元素存在并且有未领取的鱼丸
			if ( $h2p_j('div.FishpondTreasure-num.is-entrance').length > 0 && $h2p_j('div.FishpondTreasure-num.is-entrance').text().length > 0 ) {
				// 打开领取鱼丸界面
				$h2p_j('div.FishpondTreasure-icon').click();

				// 每日活跃、每周活跃
				$h2p_j('span[class^="FTP-btn"]').toArray().forEach( (span) => {
					span.click();
					$h2p_j('div.FTP-singleTask-btn.is-finished').toArray().forEach( ele => ele.click() );
				} );
				// 鱼塘
				$h2p_j('div.FTP-bubble-progressText.is-complete').toArray().forEach( ele => ele.click() );

				$h2p_j('span.FTP-close').click();
			}
		}, 5000);
	};

	// 默认画质
	let auto_showDef = () => {
		let INVL_checkDefIconReady = setInterval(() => {
			if ( $h2p_j('div.rate-5c068c').length > 0 ) {
				window.clearInterval(INVL_checkDefIconReady);
				INVL_checkDefIconReady = null;
				if ( h2p_DYScript_config.isShow0 ) {
					$h2p_j('div.tip-e3420a > ul > li:last').click();
				} else if ( h2p_DYScript_config.isShow9 ) {
					$h2p_j('div.tip-e3420a > ul > li:first').click();					
				}
			}
		}, 500 );
	}

	// 禁止弹幕
	let auto_hideBar = () => {
		let INVL_checkDefIconReady = setInterval(() => {
			if ( $h2p_j('div[class="showdanmu-42b0ac removed-9d4c42"]').length > 0 ) {
				window.clearInterval(INVL_checkDefIconReady);
			} else if ( $h2p_j('div[class="showdanmu-42b0ac"]').length > 0 ) {
				$h2p_j('div[class="showdanmu-42b0ac"]').click();
				window.clearInterval(INVL_checkDefIconReady);
			}
		}, 500 );
	}

	// 静音
	let auto_hideSound = () => {
		let INVL_checkDefIconReady = setInterval(() => {
			if ( $h2p_j('div[class="volume-silent-3eb726"]').length > 0 ) {
				window.clearInterval(INVL_checkDefIconReady);
			} else if ( $h2p_j('div[class="volume-8e2726"]').length > 0 ) {
				$h2p_j('div[class="volume-8e2726"]').click();
				window.clearInterval(INVL_checkDefIconReady);
			}
		}, 500 );
	}

	// 自动签到
	let auto_signIn = () => {
		let INVL_checkSignInIconReady = setInterval(() => {
			if ( $h2p_j('div.RoomLevelDetail-level.RoomLevelDetail-level--no').length > 0 ) {
				window.clearInterval(INVL_checkSignInIconReady);
				INVL_checkSignInIconReady = null;
				$h2p_j('div.RoomLevelDetail-level.RoomLevelDetail-level--no').click();
				setTimeout(() => {
					// 关闭签到弹出的框
					$h2p_j('div.SSR-D-close').click();
				}, 200);
			}
		}, 500);
	}

	// 检测是否出现 在电脑面前检测
	setInterval(() => { $h2p_j('div.btn2-869c8d').toArray().forEach( ele => ele.click() ); }, 10000 );
	// 检测是否出现 重新加载
	setInterval(() => {
		if ( $h2p_j('div.reload-0876b5').css('display') != 'none' ) { $h2p_j('div.reload-0876b5').toArray().forEach( ele => ele.click() );  }
	}, 10000 );

	h2p_DYScript_configPre = JSON.parse(localStorage.getItem('h2p-DYScript-configPre')) || {};

	// 脚本清爽
	(() => {
		if ( h2p_DYScript_configPre && 'isHideSM' in h2p_DYScript_configPre && h2p_DYScript_configPre.isHideSM ) {
			let h2p_style_clean = document.createElement('style');
			h2p_style_clean.type = 'text/css';
			h2p_style_clean.innerHTML = `
				.Header-logo { display : none!important; }
				.DropMenuList-name { display : none!important; }
				.DropMenuList-list { display : none!important; }
				.Game { display : none!important; }
				.Header-broadcast-wrap { display : none!important; }
				.Header-download-wrap { display : none!important; }

				.Title-anchorPic { display : none!important; }
				.Title-headline { display : none!important; }
				.Title-roomOtherBottom { display : none!important; }
				.ComSuperscript { display : none!important; }
				.Title-impress { display : none!important; }
				.Title-addFriend { display : none!important; }
				.SociatyLabel { display : none!important; }
				.Title { height : 100%!important; }
				.layout-Player-title { min-height : 0!important; }
				
				.MotorcadeEntry-wrapper { display : none!important; }

				.ActSuperFansGroup-switchWrap { display: none!important; }
				.ActSuperFansGroup-logo { display: none!important; }
				.ActSuperFansGroup-bar { display: none!important; }

				.layout-Player-rank { display: none!important; }
				.layout-Player-barrage { top : 0!important; }
				.Barrage-noble { display: none!important; }

				.layout-Player-guessgame { display: none!important; }
				.layout-Bottom { display: none!important; }

				.RoomLevel { display: none!important; }
				.Motor { display: none!important; }
				.MatchSystemTeamMedal { display: none!important; }
				.MatchSystemChatRoomEntry { display: none!important; }
				.MatchSystemMedalPanel-container { display: none!important; }
				.BarrageBanner { display: none!important; }
				.Barrage-notice--noble {
					background : transparent!important;
					border : none!important
				}
				.Barrage-topFloater { display: none!important; }

				.PlayerToolbar-signCont { background: transparent!important; }
			`;
			document.head.appendChild(h2p_style_clean);

			let h2p_topic_style_clean = document.createElement('style');
			h2p_topic_style_clean.type = 'text/css';
			h2p_topic_style_clean.innerHTML = `
				.bc-wrapper-2 { display : none!important; }
				.bc-wrapper-3 {
					margin-top		: 78px;
					background-color: transparent!important;
					background-image: none!important;
				}
				.bc-wrapper-4 {
					background-color: transparent!important;
					background-image: none!important;
				}
				.bc-wrapper-6 { display : none!important; }
				.bc-wrapper-10 { display : none!important; }
				.bc-wrapper-11 { display : none!important; }
				.bc-wrapper-12 { display : none!important; }
				.bc-wrapper-13 { display : none!important; }
				.bc-wrapper-14 {
					background-color: transparent!important;
					background-image: none!important;
				}
				.bc-wrapper-15 { display : none!important; }
				.bc-wrapper-16 {
					background-color: transparent!important;
					background-image: none!important;
				}
				.bc-wrapper-17 { display : none!important; }
				.bc-wrapper-18 { display : none!important; }

				.video-header { display : none!important; }
				.wm-h5-view { display : none!important; }
				.wm-h6-view { display : none!important; }
				.wm_footer { display : none!important; }
				.MatchSystemGuide { display : none!important; }

				.ToolbarActivityArea { display : none!important; }
			`;
			document.head.appendChild(h2p_topic_style_clean);

			let INVL_autoCleanEle = setInterval(() => {
				if ( BOOL_vue_clear ) {
					vue_light.cleanEle();
					window.clearInterval(INVL_autoCleanEle);
					INVL_autoCleanEle = null;
				}
			}, 1000);
		}
	})();








// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 
// 															脚本自动化配置界面
// 
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //









	// 初始化配置界面
	(() => {
		let str_div_config = `
			<div id="h2p-div-config" class="h2p-div-inlinepanel" style="display: none">

				<div class="h2p-div-layer" style="height: 27px;">
					<div class="h2p-div-layer-half" style="height: 100%">
						<button class="h2p-btn h2p-w-96p h2p-bg-close">关闭状态</button>
					</div>
					<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
						<button class="h2p-btn h2p-w-96p h2p-bg-open">开启状态</button>
					</div>
				</div>

				<hr style="margin: 6px; border: 1px solid transparent;">
				<hr style="margin: 6px -9px; border: 1px solid #DCDCDC;">
				<hr style="margin: 6px; border: 1px solid transparent;">

				<div class="h2p-div-layer" style="height: 27px;">
					<!-- 清爽模式 and 黑暗模式 -->
					<div class="h2p-div-layer-half" style="height: 100%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%">
							<div class="h2p-div-layer-half" style="height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_isHideCM, 'h2p-bg-close':!auto_isHideCM}" @click="click_hideCM">清爽模式</button>
							</div>
							<!--
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_ishideBM, 'h2p-bg-close':!auto_ishideBM}" style="float: right" @click="click_hideBM">黑暗模式</button>
							</div>
							-->
						</div>
					</div>
					
					<!-- 宽屏模式 and 网页全屏 -->
					<div class="h2p-div-layer-half" style="height: 100%; left: 50%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%; float: right">
							<div class="h2p-div-layer-half" style="height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_isHideWS, 'h2p-bg-close':!auto_isHideWS}" @click="click_hideWS">宽屏模式</button>
							</div>
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_isHideFS, 'h2p-bg-close':!auto_isHideFS}" style="float: right" @click="click_hideFS">网页全屏</button>
							</div>
						</div>
					</div>
				</div>
				<hr style="margin: 2px 6px; border: 1px solid transparent;">
				<div class="h2p-div-layer" style="height: 27px;">
					<!-- 脚本清爽 -->
					<div class="h2p-div-layer-half" style="height: 100%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%">
							<div class="h2p-div-layer-half" style="height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_isHideSM, 'h2p-bg-close':!auto_isHideSM}" @click="click_hideSM">脚本清爽</button>
							</div>
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
							</div>
						</div>
					</div>
				</div>

				<hr style="margin: 6px; border: 1px solid transparent;">

				<div class="h2p-div-layer" style="height: 27px;">
					<!-- 画质选项 -->
					<div class="h2p-div-layer-half" style="height: 100%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%">
							<div class="h2p-div-layer-half" style="height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_isShow0, 'h2p-bg-close':!auto_isShow0}" @click="click_showDef0">最低画质</button>
							</div>
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_isShow9, 'h2p-bg-close':!auto_isShow9}" style="float: right" @click="click_showDef9">最高画质</button>
							</div>
						</div>
					</div>

					<div class="h2p-div-layer-half" style="height: 100%; left: 50%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%; float: right">
							<div class="h2p-div-layer-half" style="height: 100%">
								<!--  -->
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_isHideBar, 'h2p-bg-close':!auto_isHideBar}" @click="click_hideBar">关闭弹幕</button>
							</div>
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
								<!--  -->
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_isHideSound, 'h2p-bg-close':!auto_isHideSound}" @click="click_hideSound">静音</button>
							</div>
						</div>
					</div>
				</div>

				<hr style="margin: 6px; border: 1px solid transparent;">

				<div class="h2p-div-layer" style="height: 27px;">
					<div class="h2p-div-layer-half" style="height: 100%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%">
							<div class="h2p-div-layer-half" style="height: 100%">
								<!-- 是否自动领取鱼丸 -->
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_getFB, 'h2p-bg-close':!auto_getFB}" @click="click_autoGetFB">领取鱼丸</button>
							</div>
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
								<!-- 是否自动签到 -->
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_signIn, 'h2p-bg-close':!auto_signIn}" style="float: right" @click="click_autoSignIn">签到</button>
							</div>
						</div>
					</div>
					
					<div class="h2p-div-layer-half" style="height: 100%; left: 50%">
						<div class="h2p-div-layer h2p-w-96p" style="height: 100%; float: right">
							<div class="h2p-div-layer-half" style="height: 100%">
								<!--  -->
								<button class="h2p-btn h2p-w-96p" :class="{'h2p-bg-open':auto_anchorUp, 'h2p-bg-close':!auto_anchorUp}" @click="click_autoAnchorUp">赠送荧光棒</button>
							</div>
							<div class="h2p-div-layer-half" style="left: 50%; height: 100%">
								<!--  -->
							</div>
						</div>
					</div>
				</div>
			</div>
		`;
		let div_config = $h2p_j(str_div_config);

		let setINVL_wait_div_DYScript = setInterval(() => {
			if ($H2P('div#div-DYScript')) {
				$h2p_j('div#div-DYScript').append(div_config);

				window.clearInterval(setINVL_wait_div_DYScript);
				setINVL_wait_div_DYScript = null;
				setTimeout(() => { BOOL_ok_config = true; }, 500);
			}
		}, 500);
	})();

	let vue_config = undefined;
	// 发送弹幕组件构建 Vue
	let INVL_createVue_config = setInterval(() => {
		if (BOOL_ok_config) {
			window.clearInterval(INVL_createVue_config);
			INVL_createVue_config = null;

			vue_config = new Vue({
				el		: '#h2p-div-config',
				data	: {
					auto_isHide		: false,
					auto_isHideCM	: false,		// clear mode
					auto_ishideBM	: false,		// part screen
					auto_isHideWS	: false,		// wide screen
					auto_isHideFS	: false,		// full screen
					auto_isHideSM	: false,		// script mode
					auto_isShow0	: false,		// 最低画质
					auto_isShow9	: false,		// 最高画质
					auto_isHideBar	: false,		// 滚动弹幕
					auto_isHideSound: false,		// 静音
					auto_getFB		: false,		// 自动获取鱼丸(fish ball)
					auto_signIn		: false,
					auto_anchorUp   : false,		// 自动赠送荧光棒
				},
				methods	: {
					click_autoHideMode	: () => {
						vue_config.auto_isHide = !vue_config.auto_isHide;
						vue_config.click_selectHideMode();
					},
					// 选择隐藏模式
					set_hideMode		: () => {
						h2p_DYScript_config.isHideCM = vue_config.auto_isHideCM;
						h2p_DYScript_config.isHideWS = vue_config.auto_isHideWS;
						h2p_DYScript_config.isHideFS = vue_config.auto_isHideFS;
						localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
					},
					click_hideCM		: () => {
						vue_config.auto_isHideCM = !vue_config.auto_isHideCM;
						vue_config.auto_isHideWS = false;
						vue_config.auto_isHideFS = false;
						vue_config.set_hideMode();
					},
					click_hideBM		: () => {
						vue_config.auto_ishideBM = !vue_config.auto_ishideBM;
						h2p_DYScript_config.ishideBM = vue_config.auto_ishideBM;
						localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
					},
					click_hideWS		: () => {
						vue_config.auto_isHideCM = false;
						vue_config.auto_isHideWS = !vue_config.auto_isHideWS;
						vue_config.auto_isHideFS = false;
						vue_config.set_hideMode();
					},
					click_hideFS		: () => {
						vue_config.auto_isHideCM = false;
						vue_config.auto_isHideWS = false;
						vue_config.auto_isHideFS = !vue_config.auto_isHideFS;
						vue_config.set_hideMode();
					},
					click_hideSM		: () => {
						vue_config.auto_isHideSM = !vue_config.auto_isHideSM;
						h2p_DYScript_configPre.isHideSM = vue_config.auto_isHideSM;
						localStorage.setItem('h2p-DYScript-configPre', JSON.stringify(h2p_DYScript_configPre) );
					},
					// 保存画质设置
					click_setShowDef	: () => {
						h2p_DYScript_config.isShow0 = vue_config.auto_isShow0;
						h2p_DYScript_config.isShow9 = vue_config.auto_isShow9;
						localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
					},
					click_showDef0		: () => {
						vue_config.auto_isShow0 = !vue_config.auto_isShow0;
						vue_config.auto_isShow9 = false;
						vue_config.click_setShowDef();
					},
					click_showDef9		: () => {
						vue_config.auto_isShow0 = false;
						vue_config.auto_isShow9 = !vue_config.auto_isShow9;
						vue_config.click_setShowDef();
					},
					click_hideBar		: () => {
						vue_config.auto_isHideBar = !vue_config.auto_isHideBar;
						h2p_DYScript_config.isHideBar = vue_config.auto_isHideBar;
						localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
					},
					click_hideSound		: () => {
						vue_config.auto_isHideSound = !vue_config.auto_isHideSound;
						h2p_DYScript_config.isHideSound = vue_config.auto_isHideSound;
						localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
					},
					click_autoGetFB	: () => {
						vue_config.auto_getFB = !vue_config.auto_getFB;
						h2p_DYScript_config.getFB = vue_config.auto_getFB;
						localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
					},
					click_autoSignIn: () => {
						vue_config.auto_signIn = !vue_config.auto_signIn;
						h2p_DYScript_config.signIn = vue_config.auto_signIn;
						localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
					},
					click_autoAnchorUp: () => {
						vue_config.auto_anchorUp = !vue_config.auto_anchorUp;
						h2p_DYScript_config.anchorUp = vue_config.auto_anchorUp;
						localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
					}
				}
			});

			BOOL_vue_config = true;
		}
	}, 500);









// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 																获取自动化配置
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //








	// 斗鱼功能自动化配置
	let h2p_DYScript_config = {};
	let h2p_DYScript_config_def = {
		isClearHead : false,
		isClearAside: false,
		isClearInfo : false,
		isClearBar	: false,
		isClearGift : false,
		isClearPlay : false,
		isHideCM 	: false,
		ishideBM 	: false,
		isHideWS	: false,
		isHideFS 	: false,
		isShow0		: false,
		isShow9		: false,
		isHideBar	: false,
		isHideSound	: false,
		getFB		: false,
		signIn		: false,
		anchorUp    : false,
		showTs		: [],
	};

	
	(() => {
		let start_INVL_waitRoomID = new Date().getTime() / 1000;
		let INVL_waitRoomID = setInterval(() => {
			if ( $H2P('div.Title-anchorPicBack > a') && $H2P('div.Title-anchorPicBack > a').href.length > 0 ) {
				roomInfo.id = $H2P('div.Title-anchorPicBack > a').href.split('room_id=')[1];
				window.clearInterval(INVL_waitRoomID);
				INVL_waitRoomID = null;
			} else {
				if ( ((new Date().getTime() / 1000) - start_INVL_waitRoomID) > 15 ) {
					window.clearInterval(INVL_waitRoomID);
					console.log('获取房间 ID 超时')
				}
			}
		}, 500);
		let INVL_getAnchorShowT = setInterval(() => {
			if ( h2p_DYScript_config ) {
				let showTs = h2p_DYScript_config.showTs;
				let showT = 0;
				let getT = 0;
				let isStore = false;
				let index = 0;
				for ( ; index < showTs.length; index++ ) {
					if ( roomInfo.id == showTs[index].id ) {
						showT = parseInt( showTs[index].showT );
						getT = parseInt( showTs[index].getT );
						isStore = true;
						break;
					}
				}
				let INVL = ((new Date().getTime() / 1000) - getT) / 3600.0;
				if ( INVL < 6 ) {
					roomInfo.showT = showT;
					console.log(`Succeed getting anchor showTime : ${roomInfo.showT}.`);
					window.clearInterval(INVL_getAnchorShowT);
					INVL_getAnchorShowT = null;
				} else if ( roomInfo.id.length > 0 ) {
					fetch('https://www.douyu.com/betard/' + roomInfo.id)
						.then(response => response.json())
						.then((res) => {
							try {
								if (res) {
									if (res.cache_time) {
										roomInfo.showT = parseInt(res.cache_time);
									} else {
										let r = res.split('"cache_time":')[1];
										let l = r.substr(0, r.indexOf(','));
										roomInfo.showT = parseInt(l);
									}
									console.log(`Succeed getting anchor showTime : ${roomInfo.showT}.`);
									let info = { 'id' : roomInfo.id, 'showT' : roomInfo.showT, "getT" : parseInt( new Date().getTime() / 1000 ) };
									if ( isStore ) { h2p_DYScript_config.showTs.splice(index, 1, info); }
									else { h2p_DYScript_config.showTs.push(info); }
									localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
								} else { console.log('Fail to get anchor showTime.') }
							} catch(e){ console.log('获取播放时间失败。') }
						});

					window.clearInterval(INVL_getAnchorShowT);
					INVL_getAnchorShowT = null;
				}
			}
		}, 500);

		let INVL_getOnline = setInterval(() => {
			if ( roomInfo.online <= 0 ) {
				let urlId = ''
				if ( isTopic ) {
					urlId = window.location.href.split('=').pop();
				} else {
					urlId = window.location.pathname.split('/').pop();
				}
				$h2p_j.ajax({
					// url		: 'https://www.douyu.com/swf_api/h5room/' + urlId,
					url		: 'https://bojianger.com/data/api/common/search.do?keyword=' + urlId,
					success	: (response)=>{
						try {
							if ( response ) {
								console.log(response);
								let data = {}
								if ( 'data' in response ) {
									if ( 'online' in response.data ) {
										roomInfo.online = parseInt(response.data.online);
									}
									else if ( 'anchorVo' in response.data ) {
										roomInfo.online = parseInt(response.data.anchorVo.audience_count);
									}
								} else {
									let res = JSON.parse(JSON.stringify(response));
									roomInfo.online = parseInt(res.split('online":')[1].split(',')[0]);
								}
								console.log(`Succeed getting online : ${roomInfo.online}.`);
							} else { console.log('Fail to get online.'); }
						}
						catch(e) {
							console.log(e);
							console.log('获取在线人数失败。');
						}
						finally {
							window.clearInterval(INVL_getOnline);
							INVL_getOnline = null;
						}
					},
				});
			}
		}, 5000);

		try {
			// 获取本地用户配置
			let config = JSON.parse(localStorage.getItem(LSPre));
			if (!config) {
				config = JSON.parse(localStorage.getItem('h2p-DYScript-setting'));
				localStorage.removeItem('h2p-DYScript-setting');
			}
			Object.assign(h2p_DYScript_config, h2p_DYScript_config_def)

			for (let attr in config) {
				if (attr in h2p_DYScript_config) {
					h2p_DYScript_config[attr] = config[attr];
				}
			}
			localStorage.setItem(LSPre, JSON.stringify(h2p_DYScript_config));
		} catch (error) {
			console.log(error);
			console.log('重置本地配置');
			localStorage.removeItem(LSPre);
			h2p_DYScript_config = h2p_DYScript_config_def;
			localStorage.setItem(LSPre, JSON.stringify(h2p_DYScript_config) );
        }

        // 根据 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;
			}
		}

		BOOL_ok_localS = true;
	})();

	// 自动获取已有徽章的主播
	new Promise((resolve, reject) => {
		$h2p_j('html').append('<div id="FansBadgeList" style="display: none"></div>');
		$h2p_j('div#FansBadgeList').load('/member/cp/getFansBadgeList [class="aui_room_table fans-badge-list"]');
		setTimeout(resolve, 3000);
	})
	.then(() => {
		// 获取有粉丝牌的主播房间号
		roomOfAnchorFan = {};
		let ele_anchors = $h2p_j('div#FansBadgeList > table > tbody > tr');
		for ( let i = 0; i < ele_anchors.length; i++ ) {
			let ele = ele_anchors[i];
			let anchorURL = $h2p_j(ele).children('td:eq(1)').children('a:eq(0)').attr('href');
			let anchorName = $h2p_j(ele).children('td:eq(1)').children('a:eq(0)').text();
			let anchorRoom = $h2p_j(ele).attr('data-fans-room');
			let anchorUp = Number($h2p_j(ele).children('td:eq(3)').children('span').text());
			roomOfAnchorFan[anchorRoom] = {anchorName, anchorURL, anchorUp};
		}
		console.log('有粉丝牌的主播房间号');
		console.log(roomOfAnchorFan);
		let anchorRoom= window.location.href.split('/').pop();
		userInfo.isAnchorFan = anchorRoom in roomOfAnchorFan;
		setTimeout(() => { $h2p_j('div#FansBadgeList').remove(); }, 1000)
	})
	.catch(error => console.log(error));

	// 自动赠送荧光棒
	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(response => response.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;
			}
		}, 1000);
	}








// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 	
// 															应用自动化配置
//
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //









	(() => {
		// 清爽模式自动化设置生效
		let INVL_config_clear_work = setInterval(() => {
			if (BOOL_vue_clear && BOOL_ok_localS) {
				window.clearInterval(INVL_config_clear_work);
				INVL_config_clear_work = null;

				try {
					if (h2p_DYScript_config.ishideBM) {
						vue_config.auto_isHide = true;
						vue_config.auto_ishideBM = true;
						vue_light.hideBM();
						console.log('启动:黑暗模式');
					}
				} catch (error) { console.log(error); }

				try {
					if (h2p_DYScript_config.isHideCM) {
						vue_config.auto_isHide = true;
						vue_config.auto_isHideCM = true;
						vue_light.hideCM();
						console.log('启动:清爽模式');
					}
					else if (h2p_DYScript_config.isHideWS) {
						vue_config.auto_isHide = true;
						vue_config.auto_isHideWS = true;
						vue_light.hideWS();
						console.log('启动:宽屏模式');
					}
					else if (h2p_DYScript_config.isHideFS) {
						vue_config.auto_isHide = true;
						vue_config.auto_isHideFS = true;
						vue_light.hideFS();
						console.log('启动:网页全屏');
					}
				} catch (error) { console.log(error); }

				if (h2p_DYScript_configPre && h2p_DYScript_configPre.isHideSM) {
					vue_config.auto_isHideSM = true;
					console.log('启动:脚本清爽');
				}
			}
		}, 500);

		// 最低(高)画质自动化设置生效
		let INVL_config_showDef_work = setInterval(() => {
			if (BOOL_vue_config) {
				window.clearInterval(INVL_config_showDef_work);
				INVL_config_showDef_work = null;
				if (h2p_DYScript_config.isShow0 || h2p_DYScript_config.isShow9) {
					auto_showDef();
					vue_config.auto_isShow0 = h2p_DYScript_config.isShow0;
					vue_config.auto_isShow9 = h2p_DYScript_config.isShow9;
					console.log('启动:自动' + ( h2p_DYScript_config.isShow0 ? '最低画质' : '最高画质' ) );
				} else {
					console.log('自动画质 启动程序 已关闭');
				}
			}
		}, 500);

		// 弹幕自动化设置生效
		let INVL_config_showBar_work = setInterval(() => {
			if (BOOL_vue_config) {
				window.clearInterval(INVL_config_showBar_work);
				INVL_config_showBar_work = null;
				if (h2p_DYScript_config.isHideBar) {
					auto_hideBar();
					vue_config.auto_isHideBar = true;
					console.log('启动:自动禁止弹幕' );
				} else {
					console.log('自动禁止弹幕 启动程序 已关闭');
				}
			}
		}, 500);

		// 静音自动化设置生效
		let INVL_config_showSound_work = setInterval(() => {
			if (BOOL_vue_config) {
				window.clearInterval(INVL_config_showSound_work);
				INVL_config_showSound_work = null;
				if (h2p_DYScript_config.isHideSound) {
					auto_hideSound();
					vue_config.auto_isHideSound = true;
					console.log('启动:自动静音' );
				} else {
					console.log('自动静音 启动程序 已关闭');
				}
			}
		}, 500);

		// 领取鱼丸自动化设置生效
		let INVL_config_getFB_work = setInterval(() => {
			if (BOOL_vue_config) {
				window.clearInterval(INVL_config_getFB_work);
				INVL_config_getFB_work = null;
				if (h2p_DYScript_config.getFB) {
					auto_getFB();
					vue_config.auto_getFB = true;
					console.log('启动:自动领取观看鱼丸');
				} else {
					console.log('自动领取观看鱼丸 启动程序 已关闭');
				}
			}
		}, 500);

		// 签到自动化设置生效
		let INVL_config_signIn_work = setInterval(() => {
			if (BOOL_vue_config) {
				window.clearInterval(INVL_config_signIn_work);
				INVL_config_signIn_work = null;
				if (h2p_DYScript_config.signIn) {
					auto_signIn();
					vue_config.auto_signIn = true;
					console.log('启动:自动签到');
				} else {
					console.log('自动签到 启动程序 已关闭');
				}
			}
		}, 500);

		// 赠送荧光棒自动化设置生效
		let INVL_config_anchorUp_work = setInterval(() => {
			if (BOOL_vue_config) {
				window.clearInterval(INVL_config_anchorUp_work);
				INVL_config_anchorUp_work = null;
				if (h2p_DYScript_config.anchorUp) {
					auto_anchorUp();
					vue_config.auto_anchorUp = true;
					console.log('启动:自动赠送荧光棒');
				} else {
					console.log('自动赠送荧光棒 启动程序 已关闭');
				}
			}
		}, 500);
	})();
})();