Greasy Fork

Greasy Fork is available in English.

H2P: 斗鱼小工具

抽奖弹幕、关键词回复、抄袭弹幕、循环弹幕 ________ 黑暗模式、清爽模式(显示直播时长,真实人数)、网页全屏、全屏 ________ 批量取关、自动签到、领取鱼塘、默认最低(高)画质、禁止滚动弹幕、自动静音、自动给有牌子的主播赠送一根荧光棒 ________ 开启快捷键

目前为 2020-05-05 提交的版本。查看 最新版本

// ==UserScript==
// @name			H2P: 斗鱼小工具
// @name:en        	tools for Douyu written by H2P
// @name:zh         H2P: 斗鱼小工具
// @namespace		http://tampermonkey.net/
// @version			1.5.9
// @icon			http://www.douyutv.com/favicon.ico
// @description		抽奖弹幕、关键词回复、抄袭弹幕、循环弹幕 ________ 黑暗模式、清爽模式(显示直播时长,真实人数)、网页全屏、全屏 ________ 批量取关、自动签到、领取鱼塘、默认最低(高)画质、禁止滚动弹幕、自动静音、自动给有牌子的主播赠送一根荧光棒 ________ 开启快捷键
// @description:en	lottery draw, keyword reply, copy barrage, loop barrage ________ dark mode, clear mdoe, full screen web page, full screen ________ batch cancellation of barrage、automatically check in、receive fishpond、default min(max) image quality, ban scrolling barrage、automatically mute、automatically present a fluorescent rod to anthor following ________ shortcut
// @description:zh	抽奖弹幕、关键词回复、抄袭弹幕、循环弹幕 ________ 黑暗模式、清爽模式(显示直播时长,真实人数)、网页全屏、全屏 ________ 批量取关、自动签到、领取鱼塘、默认最低(高)画质、禁止滚动弹幕、自动静音、自动给有牌子的主播赠送一根荧光棒 ________ 开启快捷键
// @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 黑暗模式需要手动开启
// @note			2020.04.30-V1.5.01 黑暗模式优化,且可以自动开启
// @note			2020.04.30-V1.5.02 网页打开就是黑暗模式,无需加载原来的样式
// @note			2020.04.30-V1.5.03 黑暗模式优化
// @note			2020.04.30-V1.5.04 黑暗模式优化
// @note			2020.04.30-V1.5.05 脚本清爽礼物栏优化
// @note			2020.04.30-V1.5.06 修复关键词回复 BUG
// @note			2020.04.30-V1.5.07 修复抽奖弹幕 BUG
// @note			2020.05.05-V1.5.08 清爽模式优化,页面加载过程中即可隐藏元素
// @note			2020.05.05-V1.5.09 清爽模式优化
// ==/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');

	localStorage.removeItem('h2p-DYScript-configPre');








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

	if (isFollowList){
		let anchorsSelected = [];
		
		new Promise((resolve, reject) => {
			let INVL_AddBtnCancelFollow = setInterval(() => {
				if ($H2P('div#filter-tab-expandable-wrapper') && !$H2P('a#h2p-a-cancelFollow')) {
					window.clearInterval(INVL_AddBtnCancelFollow);
					INVL_AddBtnCancelFollow = null;
					resolve();
				}
			}, 500);
		})
		.then(() => {
			let a_cancelFollow = document.createElement('a');
			a_cancelFollow.id = 'h2p-a-cancelFollow';
			a_cancelFollow.className = 'layout-Module-label';
			a_cancelFollow.innerHTML = `
				<strong>取消关注</strong>
			`;
			$H2P('div#filter-tab-expandable-wrapper').append(a_cancelFollow);
		})
		.then(() => {
			$H2P('a#h2p-a-cancelFollow').addEventListener('click', () => {
				let anchorSelected = $H2P('li.layout-Cover-item div.DyLiveCover-selectArea.is-active', false);
				anchorSelected.forEach(anchor => {
					let anchorHref = anchor.nextSibling.href;
					if (!anchorHref || anchorHref.length == 0) {
						anchorHref = anchor.parentNode.href;
					}
					let anchorId = anchorHref.split('/').pop();
					anchorsSelected.push(anchorId);
				});
				console.log(anchorsSelected);
				setTO_cancelFollow();
			});
		})
		.catch(error => { console.log(error); })
		
		function setTO_cancelFollow () {
			if (anchorsSelected && anchorsSelected.length > 0) {
				for (let i = 0; i < anchorsSelected.length; i++) {
					let anchorId = anchorsSelected[i];
					setTimeout(() => {
						cancelFollow(anchorId);
					}, (i + 1) * 1000);
				}
			}
		}

		function cancelFollow (anchorId) {
			fetch(`https://www.douyu.com/room/follow/cancel_confuse/${anchorId}`, {
				method: 'POST'
			})
			.then(res => res.json())
			.then(res => {
				if (res && 'error' in res && res.error === 0) {
					console.log(`成功取消关注主播 : ${anchorId}`);
					let parentEle = $H2P(`a[href="/${anchorId}"]`).parentNode;
					// 从主播 id 找到主播信息所在 ele 的根节点
					while (!parentEle.classList.contains('layout-Cover-item') && parentEle.tagName.toLowerCase() !== 'body') {
						parentEle = parentEle.parentNode;
					}
					if (parentEle.classList.contains('layout-Cover-item') && parentEle.tagName.toLowerCase() !== 'body') {
						parentEle.remove();
					}
				} else {
					console.log(`取消关注主播 : ${anchorId} 失败`);
				}
			});
		}
		return;
	}








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

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

	let BOOL_ok_config  = false;			// 斗鱼设置模块是否装载完毕

	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 LSInfo = 'h2p-DY-config-info';
	let config_info = JSON.parse(localStorage.getItem(LSInfo)) || {
		showTs: {},
	};

	// 获取 roomInfo.id
	let regNums = /\d+/;
	if (regNums.test($H2P('head > title').textContent)) {
		roomInfo.id = regNums.exec($H2P('head > title').textContent)[0];
	} else {
		roomInfo.id = regNums.exec(window.location.href)[0];
	}

	// 获取在线人数
	let urlId = isTopic ? window.location.href.split('=').pop() : window.location.pathname.split('/').pop();
	fetch(`https://bojianger.com/data/api/common/search.do?keyword=${urlId}`)
	.then(res => res.json())
	.then(res => {
		try {
			if (res.data) {
				if (res.data.online) { roomInfo.online = Number(res.data.online); }
				else if (res.data.anchorVo) { roomInfo.online = Number(res.data.anchorVo.audience_count); }
			} else {
				let res = JSON.parse(JSON.stringify(res));
				roomInfo.online = Number(res.split('online":')[1].split(',')[0]);
			}
			console.log(`Succeed getting online : ${roomInfo.online}.`);
		} catch (error) {
			console.log(error);
			console.log('Fail to get online');
		}
	});

	// 获取直播时间
	let showTs = {};
	if (Array.isArray(config_info.showTs)) {
		config_info.showTs = {};
		localStorage.setItem(LSInfo, JSON.stringify(config_info));
	} else { showTs = config_info.showTs || {}; }
	let [showT, getT] = [0, 0];
	if (showTs[roomInfo.id]) {
		showT = showTs[roomInfo.id].showT;
		getT = showTs[roomInfo.id].getT;
	}
	// 获取时间 < 6h
	if ((((new Date().getTime() / 1000) - getT) / 3600.0) < 6) {
		roomInfo.showT = showT;
		console.log(`Succeed getting anchor showTime : ${roomInfo.showT}.`);
	} else {
		fetch('https://www.douyu.com/betard/' + roomInfo.id)
		.then(res => res.json())
		.then(res => {
			try {
				if (res) {
					if (res.cache_time) {
						roomInfo.showT = Number.parseInt(res.cache_time);
					} else {
						let r = res.split('"cache_time":')[1];
						let l = r.substr(0, r.indexOf(','));
						roomInfo.showT = Number.parseInt(l);
					}
					config_info.showTs[roomInfo.id] = {
						'showT' : roomInfo.showT,
						"getT" : Number.parseInt(new Date().getTime() / 1000)
					};
					console.log(`Succeed getting anchor showTime : `);
					console.log(config_info.showTs[roomInfo.id]);
					localStorage.setItem(LSInfo, JSON.stringify(config_info));
				} else { console.log('Fail to get anchor showTime.') }
			} catch (error) {
				console.log(error);
				console.log('Fail to get anchor showTime.')
			}
		});
	}

    // 根据 cookie 获取用户昵称
	let cookies = document.cookie.split(/;\s/g);
	for (let i = 0; i < cookies.length; i++) {
		let cookie = cookies[i];
		let keyVal = cookie.split('=');
		if (keyVal && keyVal.length == 2 && keyVal[0] == 'acf_nickname') {
			userInfo.nickName = keyVal[1];
			break;
		}
	}

	// 自动获取已有徽章的主播
	new Promise((resolve, reject) => {
		$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 viewShow_bar	=  false;
	let viewShow_clear	=  false;
	let viewShow_config	=  false;
	let viewShow_script	=  false;

	new Promise((resolve, reject) => {
		// 创建元素样式
		let eleStyle = document.createElement('style');
		eleStyle.type = 'text/css';
		eleStyle.innerHTML = `
			#h2p-div-sign {
				width			: 18px;
				height			: 18px;
				display			: inline-block;
				vertical-align 	: middle;
			}
			#h2p-div-sign span {
				font-size		: 18px;
				cursor			: pointer;
			}

			#div-DYScript input, #div-DYScript button, #div-DYScript select {
				outline			: none;
				line-height		: 10px;
			}
			#div-DYScript {
				position 		: absolute;
				bottom 			: 1px;
				min-width 		: 335px;
				max-width 		: 335px;
				border 			: none;
				margin 			: 0 0 0 -1px;
				box-shadow		: #c7c7c7 0 -5px 5px 0;
				display         : flex;
				flex-flow       : row wrap;
				z-index 		: 999;
			}
			#div-DYScript .h2p-div-inlinepanel {
				min-width 		: 315px;
				max-width 		: 315px;
				padding 		: 10px;
				border-width	: 0 0 1px 0;
				font-family		: WeibeiSC-Bold, STKaiti;
				font-size		: 16px;
				background		: #f5f5f5;
			}

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

			.h2p-item-100p {
				width           : 100%;
			}
			.h2p-item-75p {
				width           : 75%;
			}
			.h2p-item-50p {
				width           : 50%;
			}
			.h2p-item-33p {
				width           : 33.33%;
			}
			.h2p-item-25p {
				width           : 25%;
			}

			#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 = JSON.parse(localStorage.getItem(LSChat)) || {};
	if (config_chat.loopChat) { delete config_chat.loopChat; }
	localStorage.removeItem(LSChat);
	localStorage.setItem(LSChat, JSON.stringify(config_chat));
	let [Chat, INVL_SendBar, INVL_ShowCD] = [undefined, undefined, undefined];

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

	// 初始化自动发弹幕界面  ===============================================================
	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 = '';
		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 id="h2p-input-bar-luck-time-now" 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('div#h2p-div-tab-bar').textContent = config_chat.isSend ? '🔥' : '📢';
			$H2P('input.sendingDisabled', false).forEach(ele => {
				ele.classList.toggle('h2p-input-disable');
				ele.disabled = !ele.disabled;
			})
            if (config_chat.isSend) {
                setINVL_SendBar();
                eleSend.classList.add('h2p-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 = '';
				$H2P('input#h2p-input-bar-luck-time-now').value = '';
                eleSend.classList.remove('h2p-btn-active');
                eleSend.firstElementChild.textContent = "发送";
            }
            localStorage.setItem(LSChat, JSON.stringify(config_chat));
        }, false)
	})
	.catch(error => console.log(error))
	// 读取配置参数
    .then(() => {
		$H2P('input#h2p-input-bar-isLuck').checked = config_chat.isLuck || false;
		$H2P('input#h2p-input-bar-luck-time').value = config_chat.luckTime || 1;

        $H2P('input#h2p-input-bar-invl-start').value = config_chat.invlStart || '';
		$H2P('input#h2p-input-bar-invl-end').value = config_chat.invlEnd || '';
		
		$H2P('input#h2p-input-bar-isKeyRe').checked = config_chat.isKeyRe || false;
		if (!config_chat.keyReBar || !Array.isArray(config_chat.keyReBar)) { config_chat.keyReBar = []; }
		for (let {key, re} of config_chat.keyReBar) { $H2P('select#h2p-select-keyRe').options.add(new Option(key, re)); }

		$H2P('input#h2p-input-bar-isCopy').checked = config_chat.isCopy || false;
		$H2P('input#h2p-input-bar-copy-invl').value = config_chat.copyInvl || '',

		$H2P('input#h2p-input-bar-isLoop').checked = config_chat.isLoop || false;
		$H2P('textarea#h2p-ta-bar-loopBar').value = Array.isArray(config_chat.loopBar) ? config_chat.loopBar.join('\n') : '';
		
        if (config_chat.isSend) {
            config_chat.isSend = false;
            $H2P('button#h2p-btn-bar-send').click();
        }
        if (!Chat) { Chat = setBar(); }
	})
	.then(() => {
		if (config_chat.keyReBar && config_chat.keyReBar.length > 0) {
			$H2P('input#h2p-input-key').value = $H2P('select#h2p-select-keyRe').selectedOptions[0].textContent;
			$H2P('input#h2p-input-re').value = $H2P('select#h2p-select-keyRe').selectedOptions[0].value;
		}
	})
    .catch(error => { console.log(error); })
	
	function getBar () {
		let barrage = undefined;

		// 抽奖弹幕
		if (config_chat.isLuck && $H2P('div.LotteryDrawEnter-desc')) {
			// 计算目前倒计时
			let luckCD_now = $H2P('div.LotteryDrawEnter-desc').textContent.split(':').reduce((m, s) => Number(m) * 60 + Number(s));
			// 新一轮抽奖
			if (luckCD_now > luckCD) {
				luckBar = undefined;
				luckTime = 0;
				// 显示抽奖内容
				$H2P('div.LotteryDrawEnter-enter').click();
				try {
					// 获取抽奖弹幕条件
					let barREQM = $H2P('div.ULotteryStart-joinRule').textContent.split(' : ')[1];
					const REQMs = ['发弹幕', '发弹幕+关注主播'];
					// 不是赠送、礼物、福袋、数字、盛典
					let regex = /[\u8d60\u9001\u793c\u7269\u798f\u888b\d\u76db\u5178]+/g;
					if (barREQM.search(regex) < 0) {
						if (REQMs.indexOf(barREQM) > -1 || (userInfo.isAnchorFan && barREQM.includes('成为粉丝'))) {
							// 一键参与
							$H2P('div.ULotteryStart-joinBtn').click();										
							// 获取抽奖弹幕内容
							luckBar = $H2P('div.ULotteryStart-demandDanmu > span:nth-child(1)').textContent;
							luckBar = luckBar.split(' : ')[1] ? luckBar.split(' : ')[1] : luckBar.split(' : ')[0];
							if (luckBar.includes('复制')) { luckBar = luckBar.slice(0, -2); }
						}
					}
				} catch (err) { console.log('不是弹幕抽奖'); }
				finally { $H2P('span.LotteryContainer-close').click(); }
			}

			barrage = luckTime < config_chat.luckTime ? luckBar : undefined;
			if (barrage) {
				luckTime++;
				$H2P('input#h2p-input-bar-luck-time-now').value = luckTime;
				console.log(`抽奖弹幕 : ${barrage}`);
			}
			luckCD = luckCD_now;
		}

		// 关键词弹幕回复
		if (!barrage && config_chat.isKeyRe && Array.isArray(config_chat.keyReBar)) {
			let bars = $H2P('ul#js-barrage-list > li', false);
			for (let i = Index_keyRe; i < bars.length && !barrage; i++) {
				Index_keyRe++;
				let ele = bars[i];
				try {
					let bar_check = ele.querySelector('span[class^="Barrage-content"]').textContent.replace(/\s/g, '');
					if (ele.querySelector('span[class^="Barrage-nickName"]').title !== userInfo.nickName) {
						for (let j = 0; j < config_chat.keyReBar.length; j++) {
							let keyRe = config_chat.keyReBar[j];
							if (bar_check.includes(keyRe.key)) {
								barrage = keyRe.re;
								console.log(`关键词弹幕回复 : ${barrage}`);
								break;
							}
						}
					}
				} catch (error) { console.log(error); }
			}
			if (Index_keyRe >= bars.length) { Index_keyRe = 0; }
		}

		// 抄袭弹幕
		if (!barrage && config_chat.isCopy) {
			let bars = $H2P('ul#js-barrage-list > li', false);
			let index = 0;
			if (config_chat.copyInvl) {
				if (config_chat.copyInvl < bars.length) { index = config_chat.copyInvl; }
				else { index = bars.length - 1; }
			}
			barrage = bars[index].querySelector('span[class^="Barrage-content"]').textContent.replace(/\s/g, '');
		}

		// 循环弹幕
		if (!barrage && config_chat.isLoop && Array.isArray(config_chat.loopBar)) {
			let index = Math.floor(Math.random() * (config_chat.loopBar.length));
			barrage = config_chat.loopBar[index];
		}

		return barrage ? barrage : '';
	}

	function setINVL_SendBar () {
		let {invlStart = 2, invlEnd = 2} = config_chat;
		let [start, end] = [Number(invlStart), Number(invlEnd)];
		let invl = Math.floor(Math.random() * (end - start)) + start;
		setINVL_ShowCD(invl);
		INVL_SendBar = setTimeout(() => {
			Chat.setMsg(getBar());
			Chat.sendMsg();
			setINVL_SendBar();
		}, invl * 1000);
	}

	function setINVL_ShowCD (invl) {
		new Promise((resolve, reject) => {
			window.clearInterval(INVL_ShowCD);
			resolve(invl);
		}).then((invl)=> {
			let cd = invl + 0.3;
			INVL_ShowCD = setInterval(() => {
				cd = Math.max(Math.floor((cd - 0.1) * 10) / 10.0, 0);
				$H2P('input#h2p-input-cd').value = cd;
			}, 100);
		})
	}

	function setBar () {
		let [eleSetBar, eleSendBar] = [undefined, undefined];
		return {
			setMsg : (msg)=>{
				if (!eleSetBar && $H2P('.ChatSend-txt')) { eleSetBar = $H2P('.ChatSend-txt'); }
				if (eleSetBar) { eleSetBar.value = msg; }
			},
			sendMsg : ()=>{
				if (!eleSendBar && $H2P('.ChatSend-button')) { eleSendBar = $H2P('.ChatSend-button'); }
				if (eleSendBar && eleSetBar.value) { eleSendBar.click(); }
			}
		}
	}








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

	let LSClear = 'h2p-DY-config-clear';
	let config_clear = JSON.parse(localStorage.getItem(LSClear)) || {};
	if (config_clear.clearInfo) { delete config_clear.clearInfo; }
	localStorage.removeItem(LSClear);
	localStorage.setItem(LSClear, JSON.stringify(config_clear));

	if (config_clear.blackMode) { blackMode(); }
	if (config_clear.clearMode) { clearMode(); }
	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-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; }
			#h2p-div-clear-blackMode 	{ cursor: pointer; }
			#h2p-div-clear button { height: 26px; }
		`;
		document.head.appendChild(eleStyle);
		
		// 初始化清爽模式界面  ===============================================================
		let div = document.createElement('div');
		div.id = 'h2p-div-clear';
		div.className = 'h2p-div-inlinepanel';
		div.style = 'display: none;';
		div.innerHTML = `
			<div id="h2p-div-clear-vary" class="h2p-flex-main-start h2p-item-100p" style="height: 74px;">
				<!-- 导航栏、侧边栏、删除元素 -->
				<div class="h2p-flex-main-start h2p-item-75p" style="order: 0">
					<div class="h2p-flex-main-start h2p-item-33p">
						<button id="h2p-btn-clear-nav" class="h2p-btn h2p-w-96p h2p-bg-close">导航栏</button>
					</div>
					<div class="h2p-flex-main-start h2p-item-33p">
						<button id="h2p-btn-clear-info" class="h2p-btn h2p-w-96p h2p-bg-close">信息栏</button>
					</div>
					<div class="h2p-flex-main-start h2p-item-33p">
						<button id="h2p-btn-clear-aside" class="h2p-btn h2p-w-96p h2p-bg-close">侧边栏</button>
					</div>
				</div>
				<div class="h2p-flex-main-center h2p-item-25p" style="order: 1">
					<div id="h2p-div-clear-blackMode">
						<span id="h2p-span-clear-blackMode" style="font-size: 40px;" @click="hideBM" title="黑暗模式">☀️</span>
					</div>
				</div>
				<!-- 信息栏、弹幕栏、礼物栏、鱼吧 -->
				<div class="h2p-flex-main-start h2p-item-75p" style="order: 2">
					<div class="h2p-flex-main-start h2p-item-33p">
						<button id="h2p-btn-clear-gift" class="h2p-btn h2p-w-96p h2p-bg-close">礼物栏</button>
					</div>
					<div class="h2p-flex-main-start h2p-item-33p">
						<button id="h2p-btn-clear-bar" class="h2p-btn h2p-w-96p h2p-bg-close">弹幕栏</button>
					</div>
					<div class="h2p-flex-main-start h2p-item-33p">
						<button id="h2p-btn-clear-play" class="h2p-btn h2p-w-96p h2p-bg-close">播放器</button>
					</div>
				</div>
			</div>
			<!-- 清爽模式、宽屏模式、网页全屏 -->
			<div id="h2p-div-clear-mode">
				<div class="h2p-flex-main-start h2p-item-100p">
					<div class="h2p-flex-main-start h2p-item-50p">
						<button id="h2p-btn-clear-clearMode" class="h2p-btn h2p-w-96p h2p-bg-close">清爽模式</button>
					</div>
					<div class="h2p-flex-main-start h2p-item-50p">
						<button id="h2p-btn-clear-delEle" class="h2p-btn h2p-w-96p h2p-bg-red">删除元素</button>
					</div>
				</div>
				<div class="h2p-flex-main-start h2p-item-100p">
					<div class="h2p-flex-main-start h2p-item-50p">
						<button id="h2p-btn-clear-wideMode" class="h2p-btn h2p-w-96p h2p-bg-close">宽屏模式</button>
					</div>
					<div class="h2p-flex-main-start h2p-item-50p">
						<button id="h2p-btn-clear-fullMode" class="h2p-btn h2p-w-96p h2p-bg-close">网页全屏</button>
					</div>
				</div>
			</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 eleVary = $H2P('div#h2p-div-clear-vary');
		eleVary.addEventListener('click', (event) => {
			let target = event.target;
			if (target.tagName.toLowerCase() !== 'button') { return; }
			target.classList.toggle('h2p-bg-open');
			if (target.id === 'h2p-btn-clear-nav') {
				config_clear.isClearNav = !config_clear.isClearNav;
				if (config_clear.clearMode) { clearNav(); }
			}
			else if (target.id === 'h2p-btn-clear-info') {
				config_clear.isClearInfo = !config_clear.isClearInfo;
				if (config_clear.clearMode) { clearInfo(); }
			}
			else if (target.id === 'h2p-btn-clear-aside') {
				config_clear.isClearAside = !config_clear.isClearAside;
				if (config_clear.clearMode) { clearAside(); }
			}
			else if (target.id === 'h2p-btn-clear-gift') {
				config_clear.isClearGift = !config_clear.isClearGift;
				if (config_clear.clearMode) { clearGift(); }
			}
			else if (target.id === 'h2p-btn-clear-bar') {
				config_clear.isClearBar = !config_clear.isClearBar;
				if (config_clear.clearMode) { clearBar(); }
			}
			else if (target.id === 'h2p-btn-clear-play') {
				config_clear.isClearPlay = !config_clear.isClearPlay;
				if (config_clear.clearMode) { clearPlay(); }
			}
			localStorage.setItem(LSClear, JSON.stringify(config_clear));
		}, false);

		// 黑暗模式 click 监听
		let eleBM = $H2P('span#h2p-span-clear-blackMode');
		eleBM.addEventListener('click', () => {
			config_clear.blackMode = !config_clear.blackMode;
			localStorage.setItem(LSClear, JSON.stringify(config_clear));
			$H2P('span#h2p-span-clear-blackMode').textContent = config_clear.blackMode ? '🌑' : '☀️';
			blackMode();
		})

		// 清爽模式 click 监听
		let eleMode = $H2P('div#h2p-div-clear-mode');
		eleMode.addEventListener('click', (event) => {
			let target = event.target;
			if (target.tagName.toLowerCase() !== 'button') { return; }
			if (target.id === 'h2p-btn-clear-delEle') {
				$H2P('button#h2p-btn-clear-delEle').classList.toggle('h2p-bg-open');
				config_clear.delEle = !config_clear.delEle;
				localStorage.setItem(LSClear, JSON.stringify(config_clear));
				deleteElement();
				return;
			}

			target.classList.toggle('h2p-bg-open');
			if (target.id === 'h2p-btn-clear-clearMode') {
				config_clear.clearMode = !config_clear.clearMode;
				clearMode();
			} else if (target.id === 'h2p-btn-clear-wideMode') {
				config_clear.wideMode = !config_clear.wideMode;
				if (config_clear.fullMode) {
					config_clear.fullMode = false;
					$H2P('button#h2p-btn-clear-fullMode').classList.remove('h2p-bg-open');
				}
				wideMode();
			} else if (target.id === 'h2p-btn-clear-fullMode') {
				config_clear.fullMode = !config_clear.fullMode;
				if (config_clear.wideMode) {
					config_clear.wideMode = false;
					$H2P('button#h2p-btn-clear-wideMode').classList.remove('h2p-bg-open');
				}
				fullMode();
			}
			localStorage.setItem(LSClear, JSON.stringify(config_clear));
		}, false);
	})
	.then(() => {
		if (config_clear.isClearNav) { $H2P('button#h2p-btn-clear-nav').classList.add('h2p-bg-open'); }
		if (config_clear.isClearInfo) { $H2P('button#h2p-btn-clear-info').classList.add('h2p-bg-open'); }
		if (config_clear.isClearAside) { $H2P('button#h2p-btn-clear-aside').classList.add('h2p-bg-open'); }
		if (config_clear.isClearGift) { $H2P('button#h2p-btn-clear-gift').classList.add('h2p-bg-open'); }
		if (config_clear.isClearBar) { $H2P('button#h2p-btn-clear-bar').classList.add('h2p-bg-open'); }
		if (config_clear.isClearPlay) { $H2P('button#h2p-btn-clear-play').classList.add('h2p-bg-open'); }

		if (config_clear.blackMode) { $H2P('span#h2p-span-clear-blackMode').textContent = config_clear.blackMode ? '🌑' : '☀️'; }

		if (config_clear.clearMode) { $H2P('button#h2p-btn-clear-clearMode').classList.add('h2p-bg-open'); }
		if (config_clear.wideMode) { $H2P('button#h2p-btn-clear-wideMode').classList.add('h2p-bg-open'); }
		if (config_clear.fullMode) { $H2P('button#h2p-btn-clear-fullMode').classList.add('h2p-bg-open'); }
		if (config_clear.delEle) { $H2P('button#h2p-btn-clear-delEle').classList.add('h2p-bg-open'); }
	})
	.catch(error => { console.log(error); })

	new Promise((resolve, reject) => {
		// 主播热度、在线人数、直播时长
		let divBar = document.createElement('div');
		divBar.id = 'h2p-div-clear-anchorHot';
		divBar.classList = 'h2p-flex-main-start h2p-h-100p';
		divBar.style = 'padding: 3px 10px 0; margin: 0;';
		divBar.innerHTML = `
			<div class="Title-blockInline h2p-item-33p">
				<a id="a-anchorHot" class="Title-anchorHot" title="直播热度">
					<i class="Title-anchorHotIcon" style="margin-top: -4px">
						<svg style="width: 16px; height: 16px;">
							<use xlink:href="#hot_84f8212"></use>
						</svg>
					</i>
					<div class="Title-anchorText" style="margin-left: 2px;">0</div>
				</a>
			</div>
			<div class="Title-blockInline h2p-item-33p">
				<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" style="margin-left: 2px;">0</i>
						</div>
					</div>
				</div>
			</div>
			<div class="Title-blockInline h2p-item-33p">
				<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" style="margin-left: 2px;">0</div>
				</a>
			</div>
		`;

		let setINVL_wait_div_announce = setInterval(() => {
			if ($H2P('div.layout-Player-asideMainTop') && $H2P('div.BarrageSuperLink') && $H2P('div.ChatToolBar')) {
				window.clearInterval(setINVL_wait_div_announce);
				setINVL_wait_div_announce = null;
				setTimeout(() => {
					$H2P('div.layout-Player-announce').appendChild(divBar);
					resolve();
				}, 2000);
			}
		}, 500);
	})
	.then(() => {
		setTO_showAnchorHot();
	})

	function blackMode () {
		console.log(`${config_clear.blackMode ? '启动' : '关闭'} : 黑暗模式`);
		if (config_clear.blackMode) {
			if ($H2P('style#h2p-style-blackMode')) { return; }
			let eleStyle = document.createElement('style');
			eleStyle.id = 'h2p-style-blackMode';
			eleStyle.innerHTML = `
				body, div.Header-wrap, main.layout-Main, div.FishpondTreasure-v4-area { background-color: #2d2e37; }
			`;
			// header 左边
			eleStyle.innerHTML += `
				div.Header-wrap { border-bottom-color: #2d2e37; }
				header#js-header div.HeaderNav a.EntryNav-desc, header#js-header ul.Header-menu > li a,
				svg.Header-icon use { color: #a7a7a7 }
			`;
			// header 右边
			eleStyle.innerHTML += `
				header#js-header div.Header-right div.Search { background-color: #444455; border: 1px solid #444455; }
				header#js-header div.Header-right div.Search svg.Header-icon,
				header#js-header div.Header-right a.public-DropMenu-link { color: #a7a7a7; }
			`;
			// 主播信息
			eleStyle.innerHTML += `
				div#js-player-title { background-color: #2d2e37; border-color: #444455; border-bottom-color: #2d2e37; }
				div.Title-roomInfo div.Title-row h3.Title-header, div.Title-roomInfo div.Title-row h2.Title-anchorNameH2,
				div.Title-roomInfo div.Title-row a.Title-anchorHot div.Title-anchorText, div.Title-roomInfo div.Title-anchorLocation span,
				div.Title-roomInfo div.Title-sharkWeight span, div.Title-roomInfo div.Title-row div.Title-blockInline span { color: #a7a7a7; }
			`;
			// 礼物栏
			eleStyle.innerHTML += `
				div#js-player-toolbar { background-color: #2d2e37; border-color: #444455; }
				div#js-player-toolbar div.PlayerToolbar-ywInfo span,
				div#js-player-toolbar div.PlayerToolbar-ycInfo span { color: #a7a7a7; }
				div#js-player-toolbar div.PlayerToolbar-Content:nth-child(2) div.PlayerToolbar-ContentCell:nth-child(1) { visibility: hidden; }
			`;
			// 弹幕栏
			eleStyle.innerHTML += `
				div#js-player-asideMain { background-color: #2d2e37; border-color: #444455; }
			`;
			// 弹幕栏 - 公告
			eleStyle.innerHTML += `
				div.layout-Player-announce { background-color: #2d2e37; border-bottom-color: #444455; }
				div.layout-Player-rank ul.ChatTabContainer-titleWraper--tabTitle li { background-color: #2d2e37; border-color: #2d2e37; }
			`;
			// 弹幕栏 - 周榜
			eleStyle.innerHTML += `div.ChatRankWeek-headerContent { background-color: #2d2e37; }`;
			// 弹幕栏 - 贵宾
			eleStyle.innerHTML += `div.NobleRank, div.NobleRankTips { background-color: #2d2e37; }`;
			// 弹幕栏 - 粉丝团
			eleStyle.innerHTML += `
				div.FansRankInfo, div.ChatTabContainer { background-color: #2d2e37; }
				div.FansRankInfo span { color: #a7a7a7; }
			`;
			// 弹幕栏 - 主体
			eleStyle.innerHTML += `
				div#js-player-barrage, div.Barrage-main { background-color: #2d2e37; }
				span.Barrage-content { color: #a7a7a7; }
				div.Barrage { border-color: #444455; }
			`;
			// 弹幕栏 - 聊天框
			eleStyle.innerHTML += `
				div.layout-Player-chat { background-color: #2d2e37; }
				div.layout-Player-chat textarea.ChatSend-txt { background-color: #2d2e37; color: #a7a7a7!important; }
			`;
			// 弹幕栏脚本面板
			eleStyle.innerHTML += `
				div#h2p-div-clear-anchorHot { background-color: #2d2e37; border-bottom: 1px solid #2d2e37}
				div#h2p-div-clear-anchorHot div.Title-anchorText,
				div#h2p-div-clear-anchorHot div.Title-blockInline:nth-child(2) span.Title-row-icon,
				div#h2p-div-clear-anchorHot div.Title-blockInline:nth-child(2) i.Title-row-text { color: #a7a7a7; }
			`;
			// 互动预言
			eleStyle.innerHTML += `
				div#guess-main-panel { background: #2d2e37; border-color: #444455; }
				div.GuessMainPanelHeader-panelLeft span.GuessMainPanelHeader-slogon { color: #a7a7a7; }
				div.GuessGameBox, div.GuessReturnYwFdSlider-numIptWrap { background: #2d2e37; border-color: #2d2e37; }
				div.GuessGameBox-header div.boxLeft, div.GuessReturnYwFdSlider-giftName { color: #a7a7a7; }
				div.GuessReturnYwFdSlider-numIptWrap, 
				input.GuessReturnYwFdSlider-numIpt { background-color: #444455; border-color: #444455; color: #a7a7a7; }
				a.GuessGuideList-itemBox { background-color: #444455; }
				h2.guessGame--ell { color: #a7a7a7; }
			`;
			// 友邻
			eleStyle.innerHTML += `
				div#js-bottom-right { background-color: #2d2e37; }
				div.AnchorFriendPane-title { border-bottom-color: #444455!important }
				div.AnchorFriendPane-title h3 { color: #a7a7a7!important; }
				div.AnchorLike-ItemBox { border-color: #444455; }
				div.AnchorFriend-footer { border-top-color: #444455; }
				div.AnchorFriend-footer a { background-color: #2d2e37; color: #a7a7a7 }
				div.GuessReturnYwFdSlider { background-color: #2d2e37; border-color: #2d2e37;}
			`;
			document.body.append(eleStyle);
		} else { $H2P('style#h2p-style-blackMode').remove(); }
	}

	function clearNav () {
		console.log(`${config_clear.isClearNav ? '启动' : '关闭'} : 清爽导航栏`);
		if (config_clear.isClearNav) {
			if ($H2P('style#h2p-style-clear-nav')) { return; }
			let eleStyle = document.createElement('style');
			eleStyle.id = 'h2p-style-clear-nav';
			// 斗鱼 logo、游戏、活动
			eleStyle.innerHTML = `
				a.Header-logo, div.public-DropMenu.Game, div.HeaderNav { display: none!important; }
			`;
			// 客户端、开播
			eleStyle.innerHTML += `
				div.Header-download-wrap, div.Header-broadcast-wrap { display: none!important; }
			`;
			// 用户头像 hover
			eleStyle.innerHTML += `
				div.UserInfo div.Task, div.UserInfo div.CloudGameLink, div.Promotion { display: none!important; }
			`;
			document.body.append(eleStyle);
		} else { $H2P('style#h2p-style-clear-nav').remove(); }
	}

	function clearInfo () {
		console.log(`${config_clear.isClearInfo ? '启动' : '关闭'} : 清爽主播信息`);
		if (config_clear.isClearInfo) {
			if ($H2P('style#h2p-style-clear-info')) { return; }
			let eleStyle = document.createElement('style');
			eleStyle.id = 'h2p-style-clear-info';
			eleStyle.innerHTML = `
				div#js-player-title { min-height: auto!important; }
				div.Title { height: 100%!important; }
			`;
			// 头像、举报、友邻
			eleStyle.innerHTML += `
				div.Title-anchorPic, div.Title-roomInfo div.Title-col.is-left > div.Title-blockInline:nth-child(2),
				div.Title-roomInfo div.Title-col.is-right > div.Title-blockInline { display: none!important; }
			`;
			// 官方称号
			eleStyle.innerHTML += `
				div.Title-roomInfo > div.Title-row:nth-child(2) > div.Title-col:nth-child(1) > div.Title-blockInline:last-child { display: none!important; }
			`;
			// 友邻、工会、体重
			eleStyle.innerHTML += `
				div.Title-roomInfo > div.Title-row:nth-child(2) > div.Title-col:nth-child(2),
				div.Title-roomInfo > div.Title-row:nth-child(3) { display: none!important; }
			`;
			document.body.append(eleStyle);
		} else { $H2P('style#h2p-style-clear-info').remove(); }
	}

	function clearAside () {
		console.log(`${config_clear.isClearAside ? '启动' : '关闭'} : 清爽侧边栏`);
		if (config_clear.isClearAside) {
			if ($H2P('style#h2p-style-clear-aside')) { return; }
			let eleStyle = document.createElement('style');
			eleStyle.id = 'h2p-style-clear-aside';
			eleStyle.innerHTML = `
				aside#js-aside { display: none!important; }
			`;
			document.body.append(eleStyle);
		} else { $H2P('style#h2p-style-clear-aside').remove(); }
	}

	function clearGift () {
		console.log(`${config_clear.isClearGift ? '启动' : '关闭'} : 清爽礼物栏`);
		if (config_clear.isClearGift) {
			if ($H2P('style#h2p-style-clear-gift')) { return; }
			let eleStyle = document.createElement('style');
			eleStyle.id = 'h2p-style-clear-gift';
			// 全民乐 PK、礼物
			eleStyle.innerHTML = `
				div.ToolbarActivityArea div.ActivityItem, div#js-player-toolbar div.PlayerToolbar-GiftWrap,
				div.ToolbarActivityArea div.BattleShipEnter, div.ToolbarActivityArea div.RomanticDateComponent { display: none!important; }
			`;
			document.body.append(eleStyle);
		} else { $H2P('style#h2p-style-clear-gift').remove(); }
	}

	function clearBar () {
		console.log(`${config_clear.isClearBar ? '启动' : '关闭'} : 清爽弹幕栏`);
		if (config_clear.isClearBar) {
			if ($H2P('style#h2p-style-clear-bar')) { return; }
			let eleStyle = document.createElement('style');
			eleStyle.id = 'h2p-style-clear-bar';
			eleStyle.innerHTML = `
				div#js-player-barrage { top: 32px!important; }
			`;
			// 公告、开通贵族公告
			eleStyle.innerHTML += `
				div.AnchorAnnounce, div.layout-Player-rankAll, div.layout-Player-rank { display: none!important; }
				div.BarrageBanner { display: none!important; }
			`;
			// 弹幕标签
			eleStyle.innerHTML += `
				.FansMedal.is-made, .RoomLevel, .shark-webp .Motor, .Barrage-noble, .Medal { display: none!important; }
				.Barrage-notice--noble { background: transparent!important; border: none; }
			`;
			// 喇叭、贵族弹幕、超链弹幕
			eleStyle.innerHTML += `
				div.Horn4Category, div.ChatNobleBarrage, div.BarrageSuperLink { display: none!important; }
			`;
			document.body.append(eleStyle);
		} else {
			$H2P('style#h2p-style-clear-bar').remove();
		}
	}

	function clearPlay () {
		console.log(`${config_clear.isClearPlay ? '启动' : '关闭'} : 清爽播放器`);
		if (config_clear.isClearPlay) {
			if ($H2P('style#h2p-style-clear-play')) { return; }
			let eleStyle = document.createElement('style');
			eleStyle.id = 'h2p-style-clear-play';
			// 悬浮广告、鱼吧
			eleStyle.innerHTML = `
				#js-room-activity, .layout-Bottom-mainEntity { display: none!important; }
			`;
			document.body.append(eleStyle);
		} else { $H2P('style#h2p-style-clear-play').remove(); }
	}

	function clearMode () {
		console.log(`${config_clear.clearMode ? '启动' : '关闭'} : 清爽模式`);
		if (config_clear.isClearNav) {
			if (config_clear.clearMode) { clearNav(); }
			else {
				config_clear.isClearNav = false;
				clearNav();
				config_clear.isClearNav = true;
			}
		}
		if (config_clear.isClearInfo) {
			if (config_clear.clearMode) { clearInfo(); }
			else {
				config_clear.isClearInfo = false;
				clearInfo();
				config_clear.isClearInfo = true;
			}
		}
		if (config_clear.isClearAside) {
			if (config_clear.clearMode) { clearAside(); }
			else {
				config_clear.isClearAside = false;
				clearAside();
				config_clear.isClearAside = true;
			}
		}
		if (config_clear.isClearGift) {
			if (config_clear.clearMode) { clearGift(); }
			else {
				config_clear.isClearGift = false;
				clearGift();
				config_clear.isClearGift = true;
			}
		}
		if (config_clear.isClearBar) {
			if (config_clear.clearMode) { clearBar(); }
			else {
				config_clear.isClearBar = false;
				clearBar();
				config_clear.isClearBar = true;
			}
		}
		if (config_clear.isClearPlay) {
			if (config_clear.clearMode) { clearPlay(); }
			else {
				config_clear.isClearPlay = false;
				clearPlay();
				config_clear.isClearPlay = true;
			}
		}
	}

	function wideMode () {
		if (config_clear.wideMode) {
			if ($H2P('div.wfs-2a8e83')) { $H2P('div.wfs-2a8e83').click(); }
			else {
				let start = new Date().getTime();
				let setINVL_waitWideCoin = setInterval(() => {
					if ($H2P('div.wfs-2a8e83')) {
						window.clearInterval(setINVL_waitWideCoin);
						setINVL_waitWideCoin = null;
						$H2P('div.wfs-2a8e83').click();
					} else {
						// 等待最长 2min
						if ((new Date().getTime() - start) / 1000 > 120) {
							window.clearInterval(setINVL_waitWideCoin);
							setINVL_waitWideCoin = null;
						}
					}
				}, 500);
			}
		} else {
			$H2P('div.wfs-exit-180268').click();
		}
	}

	function fullMode () {
		if (config_clear.fullMode) {
			if ($H2P('div.fs-781153')) { $H2P('div.fs-781153').click(); }
			else {
				let start = new Date().getTime();
				let setINVL_waitFullCoin = setInterval(() => {
					if ($H2P('div.fs-781153')) {
						window.clearInterval(setINVL_waitFullCoin);
						setINVL_waitFullCoin = null;
						$H2P('div.fs-781153').click();
					} else {
						// 等待最长 2min
						if ((new Date().getTime() - start) / 1000 > 120) {
							window.clearInterval(setINVL_waitFullCoin);
							setINVL_waitFullCoin = null;
						}
					}
				}, 500);
			}
		} else {
			$H2P('div.fs-exit-b6e6a7').click();
		}
	}

	function deleteElement () {
		if ($H2P('div#js-room-activity')) { $H2P('div#js-room-activity').remove(); }
		if ($H2P('div.layout-Bottom-mainEntity')) { $H2P('div.layout-Bottom-mainEntity').remove(); }
	}

	function setTO_showAnchorHot () {
		return setTimeout(() => {
			let anchorHot = Number($H2P('a.Title-anchorHot > div.Title-anchorText').textContent) || 0;
			let str_anchorHot = '' + anchorHot;
			if (anchorHot > 9999) { str_anchorHot = parseInt(anchorHot/10000) + 'w'; }
			$H2P('a#a-anchorHot > div.Title-anchorText').textContent = str_anchorHot;
			
			if (roomInfo.showT > 0) {
				let showT = Number.parseInt((new Date().getTime() / 1000) - roomInfo.showT) / 3600.0;
				let h = Number.parseInt(showT);
				let m = Number.parseInt((showT - h) * 60);
				let s = Number.parseInt(((showT - h) * 60 - m) * 60);
				// 设置直播时长
				setInterval(() => {
					s += 1;
					if (s >= 60) { m += 1; s = 0; }
					if (m >= 60) { h += 1; m = 0; }
					let strShowT = `${h}:`;
					if (m >= 10) { strShowT += m + ':'; }
					else { strShowT += '0' + m + ':'; }
					if (s >= 10) { strShowT += s; }
					else { strShowT += '0' + s; }
					$H2P('a#a-anchorShowT > div.Title-anchorText').textContent = strShowT;
				}, 1000);
			}
			// 直播热度和在线人数
			setInterval(() => {
				let anchorHot = Number($H2P('a.Title-anchorHot div.Title-anchorText').textContent) || 0;
				if (anchorHot > 9999) { anchorHot = Number.parseInt(anchorHot / 10000) + 'w'; }
				if ($H2P('a#a-anchorHot > div.Title-anchorText')) { $H2P('a#a-anchorHot > div.Title-anchorText').textContent = anchorHot; }

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








// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 
// 																快捷键设置
// 
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //

	document.addEventListener('keydown', (e) => {
		// ESC 按键
		if (e.which === 27) {
			if (config_clear.clearMode) $H2P('button#h2p-btn-clear-clearMode').click();
			else if (config_clear.wideMode) $H2P('button#h2p-btn-clear-wideMode').click();
			else if (config_clear.fullMode) $H2P('button#h2p-btn-clear-fullMode').click();
		}
		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('span#h2p-span-DYScript').click();
					$H2P('div#h2p-div-tab-bar').click();
				} else {
					if ( viewShow_bar ) { $H2P('span#h2p-span-DYScript').click(); }
					else { $H2P('div#h2p-div-tab-bar').click(); }
				}
			}
		}
		else if (e.shiftKey && e.which == myKeyCode.s) {
			if ($H2P('span#h2p-span-DYScript')) {
				if (!viewShow_script) {
					$H2P('span#h2p-span-DYScript').click();
					$H2P('div#h2p-div-tab-clear').click();
				} else {
					if (viewShow_clear) { $H2P('span#h2p-span-DYScript').click(); }
					else { $H2P('div#h2p-div-tab-clear').click(); }
				}
			}
		}
		else if (e.shiftKey && e.which == myKeyCode.d) {
			if ($H2P('span#h2p-span-DYScript')) {
				if (!viewShow_script) {
					$H2P('span#h2p-span-DYScript').click();
					$H2P('div#h2p-div-tab-config').click();
				} else {
					if (viewShow_config) { $H2P('span#h2p-span-DYScript').click(); }
					else { $H2P('div#h2p-div-tab-config').click(); }
				}
			}
		}
		// 清爽模式快捷键
		else if (e.shiftKey && e.which == myKeyCode.u) { $H2P('button#h2p-btn-clear-clearMode').click(); }
		else if (e.shiftKey && e.which == myKeyCode.i) { $H2P('span#h2p-span-clear-blackMode').click(); }
		else if (e.shiftKey && e.which == myKeyCode.o) { $H2P('button#h2p-btn-clear-wideMode').click(); }
		else if (e.shiftKey && e.which == myKeyCode.p) { $H2P('button#h2p-btn-clear-fullMode').click(); }
		// 清空弹幕
		else if (e.shiftKey && e.which == myKeyCode.c) { $H2P('a.Barrage-toolbarClear').click(); }
	});








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

	// 自动领取观看鱼丸
	let auto_getFB = () => {
		let INVL_autoGetFB = setInterval(() => {
			// 观看鱼丸元素存在并且有未领取的鱼丸
			if ( $h2p_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 );

	// 脚本清爽
	(() => {
		if (false) {
			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; }
			`;
			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);
		}
	})();








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

	const LSConfig = 'h2p-DYScript-config';
	let h2p_DYScript_configPre = {
		isShow0		: false,
		isShow9		: false,
		isHideBar	: false,
		isHideSound	: false,
		getFB		: false,
		signIn		: false,
		anchorUp    : false,
	};
	let h2p_DYScript_config = {};
	Object.assign(h2p_DYScript_config, h2p_DYScript_configPre);
	let configTmp = JSON.parse(localStorage.getItem(LSConfig)) || {};
	Object.assign(h2p_DYScript_config, configTmp);
	for (let key in h2p_DYScript_config) {
		if (!(key in h2p_DYScript_configPre)) { delete h2p_DYScript_config[key]; }
	}
	localStorage.removeItem(LSConfig);
	localStorage.setItem(LSConfig, JSON.stringify(h2p_DYScript_config));

	new Promise((resolve, reject) => {
		// 初始化配置界面
		let div = document.createElement('div');
		div.id = 'h2p-div-config';
		div.className = 'h2p-div-inlinepanel';
		div.style = 'display: none;';
		div.innerHTML = `
			<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;">
				<!-- 画质选项 -->
				<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>
		`;

		let setINVL_wait_div_DYScript = setInterval(() => {
			if ($H2P('div#div-DYScript')) {
				window.clearInterval(setINVL_wait_div_DYScript);
				setINVL_wait_div_DYScript = null;
				$H2P('div#div-DYScript').appendChild(div);
				setTimeout(() => {
					BOOL_ok_config = true;
					resolve();
				}, 500);
			}
		}, 500);
	})
	.then(() => {})

	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_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();
					},
					// 保存画质设置
					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 auto_anchorUp = () => {
		function donateYGB(roomId){
			let formData = new FormData();
			formData.append("propId", "268");
			formData.append("propCount", 1);
			formData.append("roomId", roomId);
			fetch('https://www.douyu.com/japi/prop/donate/mainsite/v1', {
				method: 'POST',
				body: formData
			}).then(res => res.json())
			.then(res => {
				if (res && 'error' in res && res.error === 0) {
					console.log('成功赠送主播 : '+ roomId + ' 一个荧光棒');
					roomOfAnchorFan[roomId].anchorUp += 1;
				} else {
					console.log('赠送' + roomId + '失败 : ' + res.msg);
				}
			});
		}

		let INVL_anchorUp = setInterval(() => {
			if (roomOfAnchorFan) {
				let roomIds = Object.keys(roomOfAnchorFan);
				for (let i = 0; i < roomIds.length; i++) {
					let roomId = roomIds[i];
					if (roomOfAnchorFan[roomId].anchorUp === 0) { setTimeout(() => { donateYGB(roomId); }, (i+1) * 2000); }
				}
				window.clearInterval(INVL_anchorUp);
				INVL_anchorUp = null;
			}
		}, 1000);
	}








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

	(() => {
		// 最低(高)画质自动化设置生效
		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);
	})();
})();