// ==UserScript==
// @name 斗鱼自动发弹幕、领取观看鱼丸、清爽模式
// @namespace http://tampermonkey.net/
// @version 1.0.0
// @icon http://www.douyutv.com/favicon.ico
// @description 默认弹幕(够长、够骚、够引人注目,你就是弹幕 Gai 最靓的仔)、抄袭弹幕(每次抄袭都是未知的体验,谁知道抄过来的是好是坏)、循环弹幕(DIY 彰显个性)、关键词回复弹幕(设定关键词和回复,帮你自动聊天)、抽奖弹幕(限定发送次数;自动检测新一轮抽奖;检测是否拥有粉丝牌;虽然中不了,但也要试试)、动态弹幕发送时间(想检测我?门都没有) ________ 清爽模式,隐藏部分或全部无关元素(针对大屏优化,大屏看直播更爽!屏幕贵族弹幕) ________ 自动签到和领取每天观看鱼丸(我的鱼丸怎么就默默变多了呢) ________ 设置界面可以设定以上功能默认开启(彻底解放你的双手)
// @author H2P
// @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/*
// @note 2019.03.18-V0.2.0 循环弹幕可以设置多条,随机发送;新增弹幕倒计时;界面美化一下?抽奖弹幕新增一种查询类型
// @note 2019.03.18-V0.3.0 界面修改;界面可隐藏;可以设置是否发送默认弹幕
// @note 2019.03.18-V0.3.1 小 BUG 修复
// @note 2019.03.19-V0.4.0 引入 JQuery 改写,还没改完;更新了弹幕抽奖元素获取(因为斗鱼改了);增加设置抽奖弹幕次数;发送弹幕时可以修改循环弹幕
// @note 2019.03.23-V0.4.1 完善了一下代码;完善了界面;修改了字体
// @note 2019.03.23-V0.5.0 添加了斗鱼清爽模式:隐藏部分、隐藏全部、删除元素
// @note 2019.03.23-V0.5.1 修缮清爽模式;添加自动领取观看鱼丸(不是鱼秀宝箱)
// @note 2019.03.24-V0.5.2 修缮自动领取观看鱼丸;修缮隐藏全部元素的返回按钮
// @note 2019.03.24-V0.5.3 修改介绍。。。
// @note 2019.03.26-V0.5.4 修缮自动领取观看鱼丸,如果无法领取则清除循环
// @note 2019.03.28-V0.5.5 解决 jQuery $ 冲突;清爽模式处理粉丝节
// @note 2019.03.31-V0.6.0 添加“功能自动化”设置面板
// @note 2019.03.31-V0.6.1 修改介绍
// @note 2019.04.02-V0.6.2 代码重写
// @note 2019.04.04-V0.6.3 添加抄袭弹幕;完善设置信息存储
// @note 2019.05.25-V0.6.4 完善清爽模式退出
// @note 2019.06.11-V0.6.5 更新斗鱼领取宝箱
// @note 2019.07.04-V0.7.0 聚合脚本图标;删去抽奖弹幕
// @note 2019.07.05-V0.7.1 添加抽奖弹幕;发送时间设定改为间隔时间,单位改为毫秒;修改循环弹幕会自动保存
// @note 2019.07.06-V0.7.2 小小修缮
// @note 2019.07.06-V0.7.3 发送弹幕时间在间隔内随机
// @note 2019.07.06-V0.7.4 更新介绍(我觉得我输在介绍不够长、不够骚)
// @note 2019.07.06-V0.7.5 自动领鱼丸更新;抽奖弹幕更新(感谢 beacoolguy 的反馈)
// @note 2019.07.06-V0.7.6 自动点击抽奖弹幕“一键参与”(仅限发弹幕抽奖);清爽模式屏蔽贵族弹幕
// @note 2019.07.09-V0.7.7 抽奖弹幕“一键参与”(仅限条件:发弹幕和关注主播);样式修改;新功能(关键词自动回复展望)
// @note 2019.07.09-V0.7.8 清爽模式针对“topic”直播间和大屏幕优化
// @note 2019.07.11-V0.7.9 添加关键词回复(目前只能设置关键词和回复,无法使用)
// @note 2019.07.14-V0.8.0 关键词回复可以使用啦!!!(最多五条关键词)
// @note 2019.07.22-V0.8.1 修复关键词回复
// @note 2019.08.02-V0.8.2 弹幕抽奖增加拥有粉丝牌的抽奖条件
// @note 2019.08.12-V0.8.3 弹幕抽奖完善拥有粉丝牌的抽奖条件;部分清爽模式修改
// @note 2019.08.13-V0.8.4 清爽模式部分隐藏修缮
// @note 2019.08.16-V0.8.5 清爽模式修缮
// @note 2019.08.17-V0.8.6 清爽模式部分隐藏修缮
// @note 2019.08.26-V0.8.7 清爽模式添加宽屏模式;ESC 快捷退出清爽模式
// @note 2019.08.26-V0.8.8 清爽模式位置更换
// @note 2019.09.05-V0.8.9 修缮关键词回复对于有粉丝牌无效的问题
// @note 2019.09.08-V0.9.0 关键词回复可以添加和删除;新一轮抽奖开启后清除上一轮抽奖弹幕内容
// @note 2019.09.10-V0.9.1 解决初始化失败的问题
// @note 2019.09.10-V0.9.2 解决关键词回复自己弹幕的问题
// @note 2019.09.10-V0.9.3 解决初始化失败的问题
// @note 2019.09.12-V0.9.4 在主播公司旁显示直播时长
// @note 2019.09.14-V1.0.0 Vue 重写自动发送弹幕和自动化配置界面;取消默认弹幕,抄袭弹幕增加抄袭间隔;取消显示直播时长
// @grant none
// ==/UserScript==
(()=>{
'use strict';
// 解决 jQuery $ 符号冲突
var $h2p_j = jQuery.noConflict();
var BOOL_ok_sendBar = false; // 自动弹幕模块是否装载完毕
var BOOL_ok_clear = false; // 自动清理模块是否装载完毕
var BOOL_ok_config = false; // 斗鱼设置模块是否装载完毕
var BOOL_ok_localS = false; // localStorage 是否读取完毕
var BOOL_vue_sendBar= false; // 自动弹幕模块 Vue 是否构建完毕
var BOOL_vue_clear = false; // 自动清爽模式 Vue 是否构建完毕
var BOOL_vue_config = false; // 自动配置模块 Vue 是否构建完毕
const MAX_barList = 120; // 弹幕列表最多弹幕条数
const MAX_DYWidth = 1200;
var userInfo = {
nickName : '', // 昵称
isAnchorFan : false, // 是否拥有主播的粉丝牌
};
// 创建元素样式
var h2p_DYScript_style_sendBar = document.createElement('style');
h2p_DYScript_style_sendBar.type = 'text/css';
h2p_DYScript_style_sendBar.innerHTML = (()=>{/*
.h2p-div-panel {
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 : none;
z-index : 999;
}
.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;
}
.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;
}
.h2p-div-layer {
position : relative;
width : 100%;
height : 24px;
}
.h2p-div-layer-half {
position : absolute;
width : 50%;
height : 24px;
}
.h2p-checkbox-left {
position : absolute;
top : 0;
bottom : 0;
left : 0;
margin : auto;
}
.h2p-input-normal {
position : relative;
height : 22px;
padding : 0px 5px;
border : 1px solid #708090;
border-radius : 5px;
font-size : 13px;
}
.h2p-input-disable {
background : #DCDCDC;
cursor : default;
}
.h2p-input-able {
background : white;
cursor : text;
}
.h2p-textarea-loopBarrage {
width : 287px;
height : 90px;
padding : 3px;
border : 1px solid #708090;
border-radius : 5px;
margin : 0 0 0 20px;
font-size : 13px;
resize : none;
}
.h2p-btn-sendBar {
width : 100%;
height : 100%;
padding : 4px 0;
border : none;
border-radius : 5px;
margin : 0;
font-size : 13px;
background : #00ddbb;
cursor : pointer;
}
.h2p-div-sign {
width : 18px;
height : 18px;
display : inline-block;
vertical-align : middle;
}
.h2p-div-tab {
width : 33.3%;
max-height : 29px;
padding : 2px 0;
text-align : center;
display : inline-block;
}
.h2p-div-tab:hover {
cursor : pointer;
background : #DDDDDD;
}
.h2p-span-sign {
font-size : 18px;
cursor : pointer;
}
.h2p-label-checkbox-left { margin : 0 0 0 20px }
.h2p-color-font-green { color : #228B22 }
.h2p-hover-pointer:hover {
cursor : pointer;
background : #DDDDDD;
}
*/}).toString().split('/*')[1].split('*/')[0];
document.head.appendChild(h2p_DYScript_style_sendBar);
// 整个面板 ===============================================================
var div_DYScript = $h2p_j('<div id="div-DYScript" class="h2p-div-panel"></div>');
// 面板底部功能键
var div_DYScriptTab = ()=>{
var greyAllTabs = () => {
$h2p_j('div#div-sendBar').hide();
$h2p_j('div#div-tab-sendBarrage').css('background', '#f5f5f5');
$h2p_j('div#div-DYLight').hide();
$h2p_j('div#div-tab-DYLight').css('background', '#f5f5f5');
$h2p_j('div#div-config').hide();
$h2p_j('div#div-tab-setting').css('background', '#f5f5f5');
}
let div_DYScriptTab = $h2p_j('<div id="div-DYScriptTab" class="h2p-div-inlinetab"></div>');
// 发弹幕
let div_tab_barrage = $h2p_j('<div id="div-tab-sendBarrage" class="h2p-div-tab" style="background: #DDDDDD;" title="发弹幕">📢</div>');
$h2p_j(div_tab_barrage).click(()=>{
greyAllTabs();
$h2p_j('div#div-sendBar').show();
$h2p_j('div#div-tab-sendBarrage').css('background', '#DDDDDD');
});
// 清爽模式
let div_tab_light = $h2p_j('<div id="div-tab-DYLight" class="h2p-div-tab" style="width: 33.4%" title="清爽模式">✡️</div>');
$h2p_j(div_tab_light).click(()=>{
greyAllTabs();
$h2p_j('div#div-DYLight').show();
$h2p_j('div#div-tab-DYLight').css('background', '#DDDDDD');
});
// 自动化设置
let div_tab_setting = $h2p_j('<div id="div-tab-setting" class="h2p-div-tab" title="自动化设置">⏲️</div>');
$h2p_j(div_tab_setting).click(()=>{
greyAllTabs();
$h2p_j('div#div-config').show();
$h2p_j('div#div-tab-setting').css('background', '#DDDDDD');
});
$h2p_j(div_DYScriptTab).append( div_tab_barrage );
$h2p_j(div_DYScriptTab).append( div_tab_light );
$h2p_j(div_DYScriptTab).append( div_tab_setting );
return div_DYScriptTab;
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 发弹幕
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 初始化自动发弹幕界面 ===============================================================
(()=>{
var str_div_bar = (()=>{/*
<div id="div-sendBar" class="h2p-div-inlinepanel">
<!-- 发送弹幕的速度 And 倒计时 -->
<div class="h2p-div-layer">
<label>间隔:</label>
<input id="input-sendBar-speedMin" class="h2p-input-normal" :class="[ isSending ? 'h2p-input-disable' : 'h2p-input-able' ]" style="width: 44px; margin-left: -10px" placeholder=">2000" v-model="speedMin" @keyup="speedCheck" @blur="speedMinStore" :disabled="isSending" />
<i>~</i>
<input id="input-sendBar-speedMax" class="h2p-input-normal" :class="[ isSending ? 'h2p-input-disable' : 'h2p-input-able' ]" style="width: 44px;" placeholder=">2000" v-model="speedMax" @keyup="speedCheck" @blur="speedMaxStore" :disabled="isSending" />
<label>毫秒</label>
<input id="input-CD" class="h2p-input-normal h2p-input-disable" style="position: absolute; right: 0; width: 32px;" v-model="CD_sendBar" disabled/>
</div>
<hr style="margin: 3px; border: 1px solid transparent;">
<!-- 是否发送抄袭弹幕 -->
<div class="h2p-div-layer" style="height: 22px;">
<div class="h2p-div-layer-half">
<input id="input-bar-isCopy" class="h2p-checkbox-left" type="checkbox" :checked="isCopy" @click="change_isCopy" />
<label class="h2p-label-checkbox-left">发送抄袭弹幕</label>
</div>
<div class="h2p-div-layer-half" style="left: 50%">
<label class="h2p-color-font-green">抄袭间隔:</label>
<input id="input-copyBar-interval" class="h2p-input-normal" style="position: absolute; width: 65px;" placeholder="默认 0 条" @keyup="copyINVLInput" @blur="copyINVLBlur" v-model="INVL_copy" />
</div>
</div>
<hr style="margin: 3px; border: 1px solid transparent;">
<!-- 是否发送循环弹幕 -->
<div class="h2p-div-layer" style="height: 98px;">
<input id="input-bar-isLoop" class="h2p-checkbox-left" type="checkbox" :checked="isLoop" @click="change_isLoop" />
<textarea id="input-loopBar-content" class="h2p-textarea-loopBarrage" :class="[ isSending ? 'h2p-input-disable' : 'h2p-input-able' ]" placeholder="循环弹幕" @change="loopBarInput" @blur="loopBarStore" :disabled="isSending"></textarea>
</div>
<hr style="margin: 3px; border: 1px solid transparent;">
<!-- 是否使用关键词自动回复 -->
<div class="h2p-div-layer">
<div class="h2p-div-layer-half">
<input id="input-bar-isKeyReply" class="h2p-checkbox-left" type="checkbox" :checked="isKeyReply" @click="change_isKeyReply" />
<label class="h2p-label-checkbox-left">关键词回复</label>
<button class="h2p-hover-pointer" style="width: 26px; border-radius: 50%" title="添加关键词" @click="keyReplyAdd">+</button>
</div>
<div class="h2p-div-layer-half" style="left: 50%">
<select id="select-keyReply" style="width: 100%; height: 24px;" @click="keyReplySelect" @change="keyReplySelect">
<option v-for="keyReply in keyReplys" :value="keyReply.value">{{ keyReply.key }}</option>
</select>
</div>
</div>
<hr style="margin: 3px; border: 1px solid transparent;">
<div class="h2p-div-layer">
<div class="h2p-div-layer-half">
<button class="h2p-checkbox-left h2p-hover-pointer" style="border-radius: 50%" title="删除关键词" @click="keyReplyDel">-</button>
<input id="input-keyReply-key" class="h2p-input-normal h2p-label-checkbox-left" style="width: 70%;" placeholder="关键词" v-model="key" @keyup="keyReplyStore">
</div>
<div class="h2p-div-layer-half" style="left: 50%">
<input id="input-keyReply-reply" class="h2p-input-normal" style="width: 90%; padding: 0 4.2%;" placeholder="自动回复弹幕" v-model="reply" @keyup="keyReplyStore" />
</div>
</div>
<hr style="margin: 3px; border: 1px solid transparent;">
<!-- 是否参加弹幕抽奖 -->
<div class="h2p-div-layer">
<div class="h2p-div-layer-half">
<input id="input-bar-isLuckDraw" class="h2p-checkbox-left" type="checkbox" :checked="isLuckDraw" @click="change_isLuckDraw" />
<label class="h2p-label-checkbox-left">发送抽奖弹幕</label>
</div>
<div class="h2p-div-layer-half" style="left: 50%">
<label class="h2p-color-font-green">抽奖发送:</label>
<input class="h2p-input-normal h2p-input-disable" style="width: 22px; margin-left: -15px;" v-model="CNT_luckDraw" disabled />
<i style="margin: 0 -5px">/</i>
<input class="h2p-input-normal" :class="[ isSending ? 'h2p-input-disable' : 'h2p-input-able' ]" style="width: 22px;" placeholder="默认 2 次" v-model="CNT_luckDrawTotal" @keyup="luckDrawCountInput" @blur="luckDrawCountBlur" :disabled="isSending" />
</div>
</div>
<hr style="margin: 3px; border: 1px solid transparent;">
<!-- 开启弹幕发送按钮 -->
<div class="h2p-div-layer">
<button id="btn-sendBar" class="h2p-btn-sendBar" :style="{ background : clr_btnSend }" @mouseover="btn_sendBar_mouseOver" @mouseout="btn_sendBar_mouseOut" @click="openAutoSendBar">{{ Con_btnSend }}</button>
</div>
</div>
*/}).toString().split('/*')[1].split('*/')[0].replace(/[\n]/g, '');
var div_bar = $h2p_j(str_div_bar);
$h2p_j(div_DYScript).append(div_bar);
// 检查弹幕面板挂载点(斗鱼弹幕显示区域)是否加载完成
var check_mountPoint_barPanel = setInterval( ()=>{
if ( $h2p_j('div.layout-Player-asideMainTop').length > 0 && $h2p_j('div.BarrageSuperLink').length > 0 ) {
window.clearInterval( check_mountPoint_barPanel );
check_mountPoint_barPanel = undefined;
setTimeout( ()=>{ $h2p_j('div.layout-Player-asideMainTop').append( div_DYScript ); }, 2000);
}
}, 1000);
// 检查弹幕图标挂载点(斗鱼弹幕输入框)是否加载完成
var check_mountPoint_barIcon = setInterval( ()=>{
if ( $h2p_j('div#div-sendBar').length > 0 ) {
window.clearInterval( check_mountPoint_barIcon );
check_mountPoint_barIcon = undefined;
BOOL_ok_sendBar = true;
}
}, 1000);
})();
let INVL_barSend= undefined; // 自动发弹幕
let INVL_barCD = undefined; // 弹幕倒计时
let speed = 0; // 弹幕发送间隔时间
const speedDef = 6000; // 弹幕发送默认间隔时间
let loopBarConTemp = ''; // 循环弹幕临时缓存
let luckDrawBar = ''; // 抽奖弹幕内容
let CD_luckDraw = 0; // 弹幕抽奖活动倒计时
const CNT_luckDrawDef = 2; // 抽奖弹幕默认发送次数
let INDEX_keyReply = 0; // 关键词回复弹幕列表已经检测的位置
window.vue_sendBar = undefined;
// 发送弹幕组件构建 Vue
var INVL_createVue_sendBar = setInterval( ()=>{
if ( BOOL_ok_sendBar ) {
window.vue_sendBar = new Vue({
el : '#div-sendBar',
data : {
speedMin : 2000,
speedMax : 3000,
isCopy : false,
isLoop : false,
isKeyReply : false,
isLuckDraw : false,
keyReplys : [],
key : '',
reply : '',
INVL_copy : 0, // 抄袭间隔弹幕数目
CD_sendBar : 0, // 弹幕倒计时
CNT_luckDraw: 0, // 抽奖弹幕实际发送次数
CNT_luckDrawTotal: 2, // 抽奖弹幕总共发送次数
Con_btnSend : '发送',
clr_btnSend : '#00ddbb',
isSending : false,
},
computed: {},
methods : {
isStrNone : (str)=>{ return str == undefined || str.length == 0; },
change_isCopy : ()=>{ vue_sendBar.isCopy = !vue_sendBar.isCopy; },
change_isLoop : ()=>{ vue_sendBar.isLoop = !vue_sendBar.isLoop; },
change_isKeyReply : ()=>{ vue_sendBar.isKeyReply = !vue_sendBar.isKeyReply; },
change_isLuckDraw : ()=>{ vue_sendBar.isLuckDraw = !vue_sendBar.isLuckDraw; },
btn_sendBar_mouseOver : ()=>{ vue_sendBar.clr_btnSend = '#00d1b2'; },
btn_sendBar_mouseOut : ()=>{ vue_sendBar.clr_btnSend = '#00ddbb'; },
lenCheck : (value, len)=>{
value = value.replace(/[^\d]/g,'');
if ( value.length > len ) { value = value.substr(0, len); }
return value;
},
numCheck : (value, len)=>{
value = value.replace(/[^\d]/g,'');
while( value.length > 0 && value[0] == '0' ) { value = value.substr(1, value.length); }
if ( value.length > len ) { value = value.substr(0, len); }
return value;
},
copyINVLInput : ()=>{
vue_sendBar.INVL_copy = vue_sendBar.lenCheck(vue_sendBar.INVL_copy, 3);
},
copyINVLBlur : ()=>{
vue_sendBar.INVL_copy = vue_sendBar.lenCheck(vue_sendBar.INVL_copy, 3);
if ( vue_sendBar.INVL_copy.length == 0 ) { vue_sendBar.INVL_copy = 0; }
h2p_DYScript_config.INVL_copy = parseInt(vue_sendBar.INVL_copy);
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
},
speedCheck : (event)=>{
let value = $h2p_j(event.target).val();
value = vue_sendBar.lenCheck(value, 6);
$h2p_j(event.target).val(value)
},
speedMinStore : ()=>{
vue_sendBar.speedMin = vue_sendBar.numCheck(vue_sendBar.speedMin, 6);
vue_sendBar.speedMin = parseInt(vue_sendBar.speedMin) ? parseInt(vue_sendBar.speedMin) : speedDef;
h2p_DYScript_config.speedMin = vue_sendBar.speedMin;
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
},
speedMaxStore : (event)=>{
vue_sendBar.speedMax = vue_sendBar.numCheck(vue_sendBar.speedMax, 6);
vue_sendBar.speedMax = parseInt(vue_sendBar.speedMax) ? parseInt(vue_sendBar.speedMax) : vue_sendBar.speedMin + 1500;
h2p_DYScript_config.speedMax = vue_sendBar.speedMax > vue_sendBar.speedMin ? vue_sendBar.speedMax : vue_sendBar.speedMin + 1500;
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
},
loopBarInput : (event)=>{
loopBarConTemp = $h2p_j(event.target).val();
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
},
loopBarStore : ()=>{
if ( loopBarConTemp.length > 0 ) {
h2p_DYScript_config.loopBarCon = loopBarConTemp;
loopBarConTemp = '';
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
}
},
keyReplyAdd : ()=>{
vue_sendBar.key = '&待定&';
vue_sendBar.reply = '';
let keyReply = { 'key' : vue_sendBar.key, 'value' : vue_sendBar.reply };
vue_sendBar.keyReplys.push(keyReply);
h2p_DYScript_config.keyReplys.push(keyReply);
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
setTimeout(()=>{
$h2p_j('#select-keyReply > option:last').attr('selected', 'true');
}, 100);
},
keyReplyDel : ()=>{
let index = document.getElementById('select-keyReply').selectedIndex;
Vue.delete(vue_sendBar.keyReplys, index);
h2p_DYScript_config.keyReplys.splice(index, 1);
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
setTimeout(()=>{
// 关键词和回复全部删除了
if ( $h2p_j('select#select-keyReply option:selected').length > 0 ) {
let option = $h2p_j('select#select-keyReply option:selected');
vue_sendBar.key = option.text();
vue_sendBar.reply = option.val();
} else {
vue_sendBar.key = '';
vue_sendBar.reply = '';
}
}, 100);
},
// select 元素选择 option
keyReplySelect : ()=>{
let option = $h2p_j('select#select-keyReply option:selected');
vue_sendBar.key = option.text();
vue_sendBar.reply = option.val();
},
keyReplyStore : ()=>{
let index = document.getElementById('select-keyReply').selectedIndex;
let keyReply = { 'key' : vue_sendBar.key, 'value' : vue_sendBar.reply };
Vue.set(vue_sendBar.keyReplys, index, keyReply);
h2p_DYScript_config.keyReplys.splice(index, 1, keyReply);
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
},
// 抽奖弹幕输入框输入检测
luckDrawCountInput : (event)=>{
let value = $h2p_j(event.target).val();
value = vue_sendBar.lenCheck(value, 2);
vue_sendBar.CNT_luckDrawTotal = parseInt(value) ? parseInt(value) : '';
},
// 抽奖弹幕输入框失去焦点
luckDrawCountBlur : (event)=>{
let value = $h2p_j(event.target).val();
value = vue_sendBar.numCheck(value, 2);
vue_sendBar.CNT_luckDrawTotal = parseInt(value) ? parseInt(value) : CNT_luckDrawDef;
},
sendBar : ()=>{
let barrage = '';
// 优先抽奖弹幕
if ( vue_sendBar.isLuckDraw && $h2p_j('div.UPlayerLotteryEnter-deadsec').length > 0 ){
// 计算目前倒计时
let CD_luckDraw_now = $h2p_j('div.UPlayerLotteryEnter-deadsec').text().split(':').reduce( (valPrev, val)=>{return parseInt(valPrev) * 60 + parseInt(val);} );
// 判断是否是新一轮抽奖
if ( CD_luckDraw_now > CD_luckDraw ) {
// 清除上一轮抽奖内容
luckDrawBar = undefined;
// 新一轮抽奖弹幕
vue_sendBar.CNT_luckDraw = 0;
// 显示抽奖内容
temp1.click();
try{
// 获取抽奖弹幕条件
let barREQM = $h2p_j('div.ULotteryStart-rule > span:eq(0)').text().split(':')[1];
const REQMs = ['发弹幕', '发弹幕+关注主播'];
// 不是赠送、礼物、福袋
var regex = /[\u8d60\u9001\u793c\u7269\u798f\u888b]+/g;
if ( barREQM.search(regex) < 0 && ( REQMs.indexOf(barREQM) > -1 || (userInfo.isAnchorFan && barREQM.indexOf('成为粉丝') > -1) ) ) {
$h2p_j('div.UPlayerLotteryEnter-deadsec').click();
// 获取抽奖弹幕内容
luckDrawBar = ('.ULotteryStart-danmuDesc.UserLottery-ellipse.is-coping').text();
luckDrawBar = luckDrawBar.split(':')[1] ? luckDrawBar.split(':')[1] : luckDrawBar.split(':')[0];
}
} catch (err) { console.log('不是弹幕抽奖'); }
finally { $h2p_j('span.LotteryContainer-close').click(); }
}
barrage = vue_sendBar.CNT_luckDraw < vue_sendBar.CNT_luckDrawTotal ? luckDrawBar : '';
if ( barrage != undefined && barrage.length > 0 ) { vue_sendBar.CNT_luckDraw++; }
CD_luckDraw = CD_luckDraw_now;
}
// 关键词弹幕回复
if ( vue_sendBar.isStrNone(barrage) && vue_sendBar.isKeyReply ) {
let bars = $h2p_j('ul#js-barrage-list > li');
if ( bars.length > MAX_barList ) {
let surplusNum = bars.length - MAX_barList;
$h2p_j('#js-barrage-list > li:lt(' + surplusNum + ')').remove();
INDEX_keyReply = INDEX_keyReply > surplusNum ? INDEX_keyReply - surplusNum : 0;
bars = $h2p_j('ul#js-barrage-list > li');
}
for ( let i = INDEX_keyReply; i < bars.length; i++ ) {
INDEX_keyReply++;
let ele = bars[i];
let bar_check = $h2p_j(ele).find('span[class^="Barrage-content"]').text().replace(/\s/g, '');
let nickName = $h2p_j(ele).find('span[class^="Barrage-nickName"]').attr('title');
let keys = [];
let keyReplys = vue_sendBar.keyReplys;
for ( let i = 0; i < keyReplys.length; i++ ){
let keyReply = keyReplys[i];
if ( keyReply.key != undefined && keyReply.key.length > 0 && keyReply.key != '&待定&' ) { keys.push(keyReply.key); }
}
let index = ((bar_check) => {
for ( let j = 0; j < keys.length; j++ ) {
// 不回复自己的弹幕
if ( bar_check.indexOf(keys[j]) > -1 && nickName != userInfo.nickName ) { return j; }
}
return -1;
})(bar_check);
barrage = index > -1 && index < keyReplys.length ? keyReplys[index].value : '';
if ( !vue_sendBar.isStrNone(barrage) ) break;
}
}
// 循环发送抄袭弹幕
if ( vue_sendBar.isStrNone(barrage) && vue_sendBar.isCopy ) {
if ( $h2p_j('span.Barrage-content').length > 0 ) {
let barListLen = $h2p_j('span.Barrage-content').length;
let index = barListLen - 1;
if ( vue_sendBar.INVL_copy < barListLen - 1 ) { index -= vue_sendBar.INVL_copy; }
else { index -= Math.floor( Math.random * (barListLen - 1) ); }
barrage = $h2p_j('span.Barrage-content:eq(' + index + ')').text().replace(/\s/g, '');
barrage = barrage.length > 0 ? barrage : $h2p_j('span.Barrage-content:eq(' + (index + 1) + ')').text().replace(/\s/g, '');
}
}
// 循环发送自定义弹幕
if ( vue_sendBar.isStrNone(barrage) && vue_sendBar.isLoop ) {
let barrageLoop = $h2p_j('textarea#input-loopBar-content').val().split('\n');
let index = Math.round( Math.random()*barrageLoop.length );
barrage = barrageLoop[index] ? barrageLoop[index] : barrageLoop[0];
}
if ( !vue_sendBar.isStrNone(barrage) ) {
$h2p_j('textarea.ChatSend-txt').val(barrage);
$h2p_j('div.ChatSend-button').click();
}
if ( INVL_barCD == undefined ) { setINVL_barCD(); }
// 重新计算发送速度
speed = Math.floor( Math.random() * (vue_sendBar.speedMax - vue_sendBar.speedMin) + vue_sendBar.speedMin );
// 重新显示倒计时
vue_sendBar.CD_sendBar = parseInt( speed / 100 ) / 10.0;
window.clearInterval(INVL_barSend);
INVL_barSend = setInterval(vue_sendBar.sendBar, speed);
},
// 开启发送弹幕
setINVL_autoSendBar : ()=>{
speed = Math.floor( Math.random() * (vue_sendBar.speedMax - vue_sendBar.speedMin) + vue_sendBar.speedMin );
vue_sendBar.isSending = true;
vue_sendBar.CNT_luckDraw = 0;
$h2p_j('#div-tab-sendBarrage').text('🔥');
INVL_barSend = setInterval(vue_sendBar.sendBar, speed);
},
// 停止发送弹幕
clearINVL_autoSendBar : ()=>{
window.clearTimeout(INVL_barSend);
INVL_barSend = undefined;
vue_sendBar.isSending = false;
$h2p_j('#div-tab-sendBarrage').text('📢');
},
// 开启倒计时
setINVL_barCD : ()=>{
if ( vue_sendBar.CD_sendBar <= 0 ) { vue_sendBar.CD_sendBar = parseInt( speed / 100 ) / 10; }
INVL_barCD = setInterval( ()=>{
if ( vue_sendBar.CD_sendBar <= 0 ) { vue_sendBar.CD_sendBar = parseInt( speed / 100 ) / 10; }
vue_sendBar.CD_sendBar = ( vue_sendBar.CD_sendBar * 10 - 1 ) / 10;
}, 100);
},
clearINVL_barCD : ()=>{
window.clearInterval(INVL_barCD);
INVL_barCD = undefined;
vue_sendBar.CD_sendBar = 0;
},
// 开始发送弹幕和倒计时
openAutoSendBar : ()=>{
vue_sendBar.clearINVL_barCD();
if ( INVL_barSend == undefined ) {
vue_sendBar.setINVL_autoSendBar();
vue_sendBar.setINVL_barCD();
}
else { vue_sendBar.clearINVL_autoSendBar(); }
vue_sendBar.Con_btnSend = vue_sendBar.isSending ? '停止发送' : '发送';
},
}
});
BOOL_vue_sendBar = true;
window.clearInterval(INVL_createVue_sendBar);
INVL_createVue_sendBar = undefined;
}
}, 100 );
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 清爽模式
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 创建元素样式
var h2p_DYScript_style_clear = document.createElement('style');
h2p_DYScript_style_clear.type = 'text/css';
h2p_DYScript_style_clear.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;
background : #00ddbb;
cursor : pointer;
}
.h2p-clearWidthLimit {
width : 100%!important;
max-width : 100%!important;
height : 100%;
margin : auto 0px!important;
}
*/}).toString().split('/*')[1].split('*/')[0];
document.head.appendChild(h2p_DYScript_style_clear);
var BOOL_hidePS = false; // part screen
var BOOL_hideWS = false; // wide screen
var BOOL_hideFS = false; // full screen
// 清除贵族弹幕
var INVL_clearNobleBar;
(()=>{
// 清爽界面面板 ===============================================================
var div_DYLight = $h2p_j('<div id="div-DYLight" class="h2p-div-inlinepanel" style="display: none"></div>');
var btn_hide_ps = document.createElement('button');
$h2p_j(btn_hide_ps).attr('id', 'btn-hide-ps');
$h2p_j(btn_hide_ps).attr('class', 'h2p-btn');
$h2p_j(btn_hide_ps).text('部分隐藏');
btn_hide_ps.onclick = ()=>{
DY_hidePS();
}
btn_hide_ps.onmouseover = ()=>{
this.style.background = '#00d1b2';
}
btn_hide_ps.onmouseout = ()=>{
this.style.background = '#00ddbb';
}
var btn_hide_ws = document.createElement('button');
$h2p_j(btn_hide_ws).attr('id', 'btn-hide-ws');
$h2p_j(btn_hide_ws).attr('class', 'h2p-btn');
$h2p_j(btn_hide_ws).text('宽屏模式');
btn_hide_ws.onclick = ()=>{
DY_hideWS();
}
btn_hide_ws.onmouseover = ()=>{
this.style.background = '#00d1b2';
}
btn_hide_ws.onmouseout = ()=>{
this.style.background = '#00ddbb';
}
var btn_hide_fs = document.createElement('button');
$h2p_j(btn_hide_fs).attr('id', 'btn-hide-fs');
$h2p_j(btn_hide_fs).attr('class', 'h2p-btn');
$h2p_j(btn_hide_fs).text('网页全屏');
btn_hide_fs.onclick = ()=>{
DY_hideFS();
}
btn_hide_fs.onmouseover = ()=>{
this.style.background = '#00d1b2';
}
btn_hide_fs.onmouseout = ()=>{
this.style.background = '#00ddbb';
}
// 分隔线 ===============================================================
let hr_style = '<hr style="margin: 6px; border: 1px solid transparent;">';
// 添加所有清爽按钮
$h2p_j(div_DYLight).append($h2p_j(hr_style));
$h2p_j(div_DYLight).append(btn_hide_ps);
$h2p_j(div_DYLight).append($h2p_j(hr_style));
$h2p_j(div_DYLight).append($h2p_j(hr_style));
$h2p_j(div_DYLight).append(btn_hide_ws);
$h2p_j(div_DYLight).append($h2p_j(hr_style));
$h2p_j(div_DYLight).append($h2p_j(hr_style));
$h2p_j(div_DYLight).append(btn_hide_fs);
$h2p_j(div_DYLight).append($h2p_j(hr_style));
$h2p_j(div_DYScript).append(div_DYLight);
var check_mountPoint_clearIcon = setInterval( ()=>{
if ( document.getElementById('div-DYScript') && document.getElementsByClassName('ChatToolBar')[0] ) {
window.clearInterval( check_mountPoint_clearIcon );
BOOL_ok_clear = true;
BOOL_vue_clear = true;
}
}, 1000);
})();
var hideEnable= () => {
$h2p_j('#btn-hide-ps').attr('disabled', false);
$h2p_j('#btn-hide-fs').attr('disabled', false);
$h2p_j('#btn-hide-ws').attr('disabled', false);
$h2p_j('#btn-hide-ps').css('cursor', 'pointer');
$h2p_j('#btn-hide-fs').css('cursor', 'pointer');
$h2p_j('#btn-hide-ws').css('cursor', 'pointer');
}
var hideDisable = () => {
$h2p_j('#btn-hide-ps').attr('disabled', true);
$h2p_j('#btn-hide-fs').attr('disabled', true);
$h2p_j('#btn-hide-ws').attr('disabled', true);
$h2p_j('#btn-hide-ps').css('cursor', 'default');
$h2p_j('#btn-hide-fs').css('cursor', 'default');
$h2p_j('#btn-hide-ws').css('cursor', 'default');
}
var funcDisable = () => {
// 禁用网页全屏
$h2p_j('div.wfs-exit-180268').css('visibility','hidden');
// 禁用窗口全屏
$h2p_j('div.fs-781153').css('visibility','hidden');
// 禁用消除弹幕框
$h2p_j('label.layout-Player-asidetoggleButton').css('visibility','hidden');
}
var funcEnable = () => {
// 启用网页全屏
$h2p_j('div.wfs-exit-180268').css('visibility','visible');
// 启用窗口全屏
$h2p_j('div.fs-781153').css('visibility','visible');
// 启用消除弹幕框
$h2p_j('label.layout-Player-asidetoggleButton').css('visibility','visible');
}
$h2p_j(document).ready().keydown(function (e) {
// ESC 按键
if ( e.which === 27 ) {
if ( BOOL_hidePS ) DY_hidePS();
else if ( BOOL_hideFS ) DY_hideFS();
else if ( BOOL_hideWS ) DY_hideWS();
}
});
// 隐藏部分元素
var DY_hidePS = ()=>{
if ( BOOL_hideFS || BOOL_hideWS ) {
return;
}
// 背景图片
$h2p_j('#js-background-holder').toggle();
// 左侧边栏
$h2p_j('#js-aside').toggle();
// 竞猜
$h2p_j('div#js-player-guessgame').toggle();
// 友邻、竞猜
$h2p_j('div#js-bottom').toggle();
// 贵宾弹幕
$h2p_j('div.Barrage-topFloater').toggle();
// 清除弹幕
if ( document.getElementsByClassName('showdanmu-42b0ac').length > 0 ) {
document.getElementsByClassName('showdanmu-42b0ac')[0].click();
}
// 吃鸡战绩
$h2p_j('div.PubgInfo').toggle();
// 超级粉丝团
if ( $h2p_j('div#js-room-activity').length > 0 ) {
$h2p_j('div#js-room-activity').remove();
}
$h2p_j('div#root').children('div.bc-wrapper:gt(1)').toggle();
// 清除贵族弹幕
INVL_clearNobleBar = setInterval( () => {
let nobleBarrages = document.getElementsByClassName('js-noblefloating-barragecont Barrage-notice--noble');
let len = nobleBarrages.length;
for ( let i = 0; i < len; i++ ) {
nobleBarrages[i].parentNode.removeChild(nobleBarrages[i]);
}
nobleBarrages = document.getElementsByClassName('Barrage-listItem js-fansfloating-barrage');
len = nobleBarrages.length;
for ( let i = 0; i < len; i++ ) {
nobleBarrages[i].parentNode.removeChild(nobleBarrages[i]);
}
}, 200);
// 导航栏 ==============================
// 斗鱼 logo
$h2p_j('a.Header-logo').toggle();
// 粉丝节
$h2p_j('div.HeaderNav').toggle();
// 客户端
$h2p_j('div.Header-download-wrap').toggle();
// 开播
$h2p_j('div.Header-broadcast-wrap').toggle();
// 创世幻神
$h2p_j('span.HeaderGif-left').toggle();
$h2p_j('span.HeaderGif-right').toggle();
// 导航栏 ==============================
// 主播信息
$h2p_j('div#js-player-title').toggle();
// 任务
$h2p_j('div.PlayerToolbar-Task').toggle();
$h2p_j('div.ToolbarActivityArea').toggle();
// 幸运宝藏
$h2p_j('div.LuckGiftEnter').toggle();
// 太空探险
$h2p_j('div.TurntableLottery').toggle();
// 送礼
$h2p_j('div.ToolbarGiftArea-GiftBox').toggle();
// 聊天栏 ==============================
$h2p_j('div.layout-Player-announce').toggle();
$h2p_j('div.layout-Player-rank').toggle();
// 聊天栏 ==============================
if ( !BOOL_hidePS ) {
BOOL_hidePS = true;
hideDisable();
$h2p_j('#btn-hide-ps').attr('disabled', false);
$h2p_j('#btn-hide-ps').css('cursor', 'pointer');
// 特定元素 ================================================
if ( document.getElementsByClassName('Act129684 ActBase is-show').length > 0 ) {
document.getElementsByClassName('Act129684 ActBase is-show')[0].classList.remove('is-show');
}
// 去除页面背景图片
if ( window.location.href.indexOf('/topic/') > -1 ) {
$h2p_j('div[class="bc-wrapper bc-wrapper-2"]').hide();
$h2p_j('div#root').children('div.bc-wrapper:eq(1)').css('margin-top', '68px');
}
// 适配大屏幕
if ( document.getElementsByClassName('layout-Main').length > 0 && window.screen.width > MAX_DYWidth ) {
document.getElementsByClassName('layout-Main')[0].classList.add('h2p-clearWidthLimit');
}
$h2p_j('#btn-hide-ps').attr('disabled', false);
$h2p_j('#btn-hide-ps').css('cursor', 'pointer');
// 放大弹幕栏
$h2p_j('div#js-player-barrage').css('top', '0');
$h2p_j('.layout-Main').css('margin-left', '0');
// 清除四周空白
// distance left and right; distance up and down
let dist_ud = jQuery('body').height() - $h2p_j('.layout-Main').height();
if ( window.location.href.indexOf('/topic/') > -1 ) {
if ( $h2p_j('div#bc3').css('margin-top').length > 0 ) {
dist_ud -= $h2p_j('div#bc3').css('margin-top').split('px')[0];
} else {
dist_ud -= 68;
}
} else {
if ( $h2p_j('section.layout-Container').length > 0 ) {
dist_ud -= $h2p_j('section.layout-Container').css('padding-top').split('px')[0];
} else {
dist_ud -= 68;
}
}
let dist_lr = window.outerWidth - $h2p_j('.layout-Main').width() - 17;
dist_ud = dist_ud > 0 ? dist_ud : 0;
dist_lr = dist_lr > 0 ? dist_lr : 0;
$h2p_j('.layout-Main').css('padding', dist_ud / 2 + 'px ' + dist_lr / 2 + 'px');
// 背景改为黑色
$h2p_j('.layout-Main').css('background', 'black');
$h2p_j('#btn-hide-ps').text('显示部分元素');
setTimeout(()=>{
if ( document.getElementsByClassName('roomSmallPlayerFloatLayout-closeBtn')[0] ) {
document.getElementsByClassName('roomSmallPlayerFloatLayout-closeBtn')[0].click();
}
}, 500);
// 恢复正常尺寸画面
setTimeout(() => {
document.getElementsByClassName('wfs-2a8e83')[0].click();
setTimeout(() => {
document.getElementsByClassName('wfs-exit-180268')[0].click();
}, 50)
}, 20);
}
else {
BOOL_hidePS = false;
hideEnable();
// 特定元素 ================================================
if ( document.getElementsByClassName('Act129684 ActBase').length > 0 ) {
document.getElementsByClassName('Act129684 ActBase')[0].classList.add('is-show');
}
// 显示页面背景图片
if ( window.location.href.indexOf('/topic/') > -1 ) {
$h2p_j('div[class="bc-wrapper bc-wrapper-2"]').show();
$h2p_j('div#root').children('div.bc-wrapper:eq(1)').css('margin-top', '0');
}
// 适配大屏幕
if ( document.getElementsByClassName('layout-Main').length > 0 && window.screen.width > MAX_DYWidth ) {
document.getElementsByClassName('layout-Main')[0].classList.remove('h2p-clearWidthLimit');
}
$h2p_j('div#js-player-barrage').css('top', '256px');
$h2p_j('.layout-Main').css('margin', '');
$h2p_j('.layout-Main').css('padding', '');
// 去除背景黑色
$h2p_j('.layout-Main').css('background', '');
$h2p_j('#btn-hide-ps').text('隐藏部分元素');
// 恢复正常尺寸画面
setTimeout(() => {
document.getElementsByClassName('wfs-2a8e83')[0].click();
setTimeout(() => {
document.getElementsByClassName('wfs-exit-180268')[0].click();
}, 50)
}, 20);
// 显示贵族弹幕
window.clearInterval(INVL_clearNobleBar);
INVL_clearNobleBar = undefined;
}
}
// 宽屏模式
var DY_hideWS = ()=>{
if ( BOOL_hidePS || BOOL_hideFS ) {
return;
}
// 任务
$h2p_j('div.PlayerToolbar-Task').toggle();
$h2p_j('div.ToolbarActivityArea').toggle();
// 幸运宝藏
$h2p_j('div.LuckGiftEnter').toggle();
// 太空探险
$h2p_j('div.TurntableLottery').toggle();
// 送礼
$h2p_j('div.ToolbarGiftArea-GiftBox').toggle();
// 贵宾弹幕
$h2p_j('div.Barrage-topFloater').toggle();
// 清除弹幕
if ( document.getElementsByClassName('showdanmu-42b0ac').length > 0 ) {
document.getElementsByClassName('showdanmu-42b0ac')[0].click();
}
// 吃鸡战绩
$h2p_j('div.PubgInfo').toggle();
// 超级粉丝团
if ( $h2p_j('div#js-room-activity').length > 0 ) {
$h2p_j('div#js-room-activity').remove();
}
// 聊天栏 ==============================
$h2p_j('div.layout-Player-announce').toggle();
$h2p_j('div.layout-Player-rank').toggle();
// 聊天栏 ==============================
if ( !BOOL_hideWS ) {
BOOL_hideWS = true;
hideDisable();
$h2p_j('#btn-hide-ws').attr('disabled', false);
$h2p_j('#btn-hide-ws').css('cursor', 'pointer');
// 播放器宽屏模式
let setINVL_waitWideScreen = setInterval( ()=>{
if ( document.getElementsByClassName('wfs-2a8e83').length > 0 ) {
$h2p_j('div.wfs-2a8e83').click();
funcDisable();
window.clearInterval(setINVL_waitWideScreen);
setINVL_waitWideScreen = undefined;
}
}, 200);
// 放大弹幕栏
$h2p_j('div#js-player-barrage').css('top', '0');
$h2p_j('#btn-hide-ws').text('退出宽屏模式');
}
else {
BOOL_hideWS = false;
hideEnable();
// 退出播放器宽屏模式
let setINVL_waitWideScreen = setInterval( ()=>{
if ( document.getElementsByClassName('wfs-exit-180268').length > 0 ) {
$h2p_j('div.wfs-exit-180268').click();
funcEnable();
window.clearInterval(setINVL_waitWideScreen);
setINVL_waitWideScreen = undefined;
}
}, 200);
// 还原弹幕栏
$h2p_j('div#js-player-barrage').css('top', '256px');
$h2p_j('#btn-hide-ws').text('宽屏模式');
}
}
// 隐藏全部元素(除播放界面)
var DY_hideFS = ()=>{
if ( BOOL_hidePS || BOOL_hideWS ) {
return;
}
if ( !BOOL_hideFS ) {
BOOL_hideFS = true;
// 播放器宽屏模式
let setINVL_waitWideScreen = setInterval( ()=>{
if ( document.getElementsByClassName('wfs-2a8e83').length > 0 ) {
$h2p_j('div.wfs-2a8e83').click();
setTimeout(() => {
// 隐藏弹幕框
$h2p_j('label.layout-Player-asidetoggleButton').click();
}, 200);
funcDisable();
window.clearInterval(setINVL_waitWideScreen);
setINVL_waitWideScreen = undefined;
}
}, 200);
}
else {
BOOL_hideFS = false;
// 播放器宽屏模式
let setINVL_waitWideScreen = setInterval( ()=>{
if ( document.getElementsByClassName('wfs-exit-180268').length > 0 ) {
// 显示弹幕框
$h2p_j('label.layout-Player-asidetoggleButton').click();
setTimeout(() => {
$h2p_j('div.wfs-exit-180268').click();
}, 200);
funcEnable();
window.clearInterval(setINVL_waitWideScreen);
setINVL_waitWideScreen = undefined;
}
}, 200);
}
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 自动化设置
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 自动签到
var auto_signIn = () => {
let INVL_checkSignInIconReady = setInterval( () => {
if ( document.getElementsByClassName('RoomLevelDetail-level').length > 0 ) {
window.clearInterval(INVL_checkSignInIconReady);
INVL_checkSignInIconReady = undefined;
document.getElementsByClassName('RoomLevelDetail-level')[0].click();
// 关闭签到页面
setTimeout(() => {
document.getElementsByClassName('Autograph-close')[0].click();
}, 150 );
}
}, 200);
}
// 自动领取观看鱼丸
var auto_getFB = () => {
let CNT_bar = 0;
var INVL_autoGetFB = setInterval(() => {
// 观看鱼丸元素存在并且有未领取的鱼丸
if ( $h2p_j('div.FishpondTreasure-entranceGet').length > 0 ) {
// 打开领取鱼丸界面
$h2p_j('div.FishpondTreasure-entranceGet').click();
let taskTitles = document.getElementsByClassName('FTP-btn');
// index 0 : 每日活跃
// index 1 : 每周活跃
for ( let i = 0; i < taskTitles.length && i < 2; i++ ) {
taskTitles[i].click();
if ( i === 0 ) {
// 存在需要发送弹幕领取的
if ( document.getElementsByClassName('TreasureBox-btn barrage-ready').length > 0 && CNT_bar < 4 ) {
// 发送弹幕
document.getElementsByClassName('ChatSend-txt')[0].value = '666';
document.getElementsByClassName('ChatSend-button')[0].click();
CNT_bar++;
// 关闭领取鱼丸界面
if ( document.getElementsByClassName('FTP-close').length > 0 ) {
document.getElementsByClassName('FTP-close')[0].click();
}
// 打开领取鱼丸界面
document.getElementsByClassName('FishpondTreasure-entranceGet')[0].click();
} else {
if ( document.getElementsByClassName('TreasureBox-btn enable').length > 0 ) {
let treasureBtns = document.getElementsByClassName('TreasureBox-btn enable');
for ( let j = 0; j < treasureBtns.length; j++ ) {
treasureBtns[j].click();
}
}
}
}
if ( document.getElementsByClassName('FTP-singleTask-btn is-finished').length > 0 ) {
let singleTask_waitBtns = document.getElementsByClassName('FTP-singleTask-btn is-finished');
for ( let i = 0; i < singleTask_waitBtns.length; i++ ) {
singleTask_waitBtns[i].click();
}
}
}
document.getElementsByClassName('FTP-close')[0].click();
}
}, 5000);
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 脚本自动化配置界面
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 初始化配置界面
(()=>{
var str_div_config = (()=>{/*
<div id="div-config" class="h2p-div-inlinepanel" style="display: none">
<div class="h2p-div-layer" style="text-align: center;">
<label>自动化配置</label>
</div>
<hr style="margin: 6px -9px; border: 1px solid #DCDCDC;">
<div class="h2p-div-layer">
<!-- 是否自动发送抄袭弹幕 -->
<div class="h2p-div-layer-half">
<input id="input-auto-copyBar" class="h2p-checkbox-left" type="checkbox" :checked="auto_isCopy" @click="click_autoCopyBar" />
<label class="h2p-label-checkbox-left">抄袭弹幕</label>
</div>
<!-- 是否自动发送循环弹幕 -->
<div class="h2p-div-layer-half" style="left: 50%">
<input id="input-auto-loopBar" class="h2p-checkbox-left" type="checkbox" :checked="auto_isLoop" @click="click_autoLoopBar" />
<label class="h2p-label-checkbox-left">循环弹幕</label>
</div>
</div>
<hr style="margin: 6px; border: 1px solid transparent;">
<div class="h2p-div-layer">
<!-- 是否自动发送循环弹幕 -->
<div class="h2p-div-layer-half">
<input id="input-auto-keyReply" class="h2p-checkbox-left" type="checkbox" :checked="auto_isKeyReply" @click="click_autoKeyReply" />
<label class="h2p-label-checkbox-left">关键词回复</label>
</div>
<!-- 是否自动发送抽奖弹幕 -->
<div class="h2p-div-layer-half" style="left: 50%">
<input id="input-auto-luckDraw" class="h2p-checkbox-left" type="checkbox" :checked="auto_isLuckDraw" @click="click_autoLuckDraw" />
<label class="h2p-label-checkbox-left">抽奖弹幕</label>
</div>
</div>
<hr style="margin: 6px; border: 1px solid transparent;">
<!-- 隐藏选项 -->
<div class="h2p-div-layer">
<div class="h2p-div-layer-half">
<input id="input-auto-hideMode" class="h2p-checkbox-left" type="checkbox" :checked="auto_isHide" @click="click_autoHideMode" />
<select id="select-hideMode" class="h2p-label-checkbox-left" style="width: 80%; height: 24px;" @change="click_selectHideMode">
<option v-for="hideMode in hideModes" :value="hideMode.value">{{hideMode.text}}</option>
</select>
</div>
</div>
<hr style="margin: 6px; border: 1px solid transparent;">
<!-- 是否自动领取鱼丸和签到 -->
<div class="h2p-div-layer">
<div class="h2p-div-layer-half">
<input id="input-auto-getFB" class="h2p-checkbox-left" type="checkbox" :checked="auto_getFB" @click="click_autoGetFB" />
<label class="h2p-label-checkbox-left">自动领取鱼丸</label>
</div>
<div class="h2p-div-layer-half" style="left: 50%;">
<input id="input-auto-signIn" class="h2p-checkbox-left" type="checkbox" :checked="auto_signIn" @click="click_autoSignIn" />
<label class="h2p-label-checkbox-left">自动签到</label>
</div>
</div>
<hr style="margin: 6px; border: 1px solid transparent;">
<!-- 是否自动领取鱼丸和参加火力全开 -->
<div class="h2p-div-layer" style="display: none">
<input id="input-auto-onFire" class="h2p-checkbox-left" type="checkbox" :checked="auto_onFire" disabled />
<label class="h2p-label-checkbox-left">参与火力全开</label>
</div>
</div>
*/}).toString().split('/*')[1].split('*/')[0].replace(/[\n]/g, '');
var div_config = $h2p_j(str_div_config);
$h2p_j(div_DYScript).append(div_config);
var check_mountPoint_configIcon = setInterval( ()=>{
if ( $h2p_j('div#div-config').length > 0 ) {
window.clearInterval( check_mountPoint_configIcon );
check_mountPoint_configIcon = undefined;
BOOL_ok_config = true;
}
}, 1000);
})();
window.vue_config = undefined;
// 发送弹幕组件构建 Vue
var INVL_createVue_config = setInterval( ()=>{
if ( BOOL_ok_config ) {
vue_config = new Vue({
el : '#div-config',
data : {
auto_isCopy : false,
auto_isLoop : false,
auto_isKeyReply : false,
auto_isLuckDraw : false,
auto_isHide : false,
auto_isHidePS : false,
auto_isHideWS : false,
auto_isHideFS : false,
auto_getFB : false, // 自动获取鱼丸(fish ball)
auto_signIn : false,
auto_onFire : false,
hideModes : [
{ 'value' : 'hidePS', 'text' : '隐藏部分' }, // part screen
{ 'value' : 'hideWS', 'text' : '宽屏模式' }, // wide screen
{ 'value' : 'hideFS', 'text' : '网页全屏' }, // full screen
]
},
methods : {
click_autoCopyBar : ()=>{
vue_config.auto_isCopy = !vue_config.auto_isCopy;
h2p_DYScript_config.isCopy = vue_config.auto_isCopy;
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
},
click_autoLoopBar : ()=>{
vue_config.auto_isLoop = !vue_config.auto_isLoop;
h2p_DYScript_config.isLoop = vue_config.auto_isLoop;
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
},
click_autoKeyReply : ()=>{
vue_config.auto_isKeyReply = !vue_config.auto_isKeyReply;
h2p_DYScript_config.isKeyReply = vue_config.auto_isKeyReply;
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
},
click_autoLuckDraw : ()=>{
vue_config.auto_isLuckDraw = !vue_config.auto_isLuckDraw;
h2p_DYScript_config.isLuckDraw = vue_config.auto_isLuckDraw;
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
},
click_autoHideMode : ()=>{
vue_config.auto_isHide = !vue_config.auto_isHide;
vue_config.click_selectHideMode();
},
// 选择隐藏模式
click_selectHideMode: ()=>{
vue_config.auto_isHidePS = false;
vue_config.auto_isHideWS = false;
vue_config.auto_isHideFS = false;
if ( vue_config.auto_isHide ) {
let value = $h2p_j('select#select-hideMode > option:selected').val();
if ( value == 'hidePS' ) { vue_config.auto_isHidePS = true; }
else if ( value == 'hideWS' ) { vue_config.auto_isHideWS = true; }
else if ( value == 'hideFS' ) { vue_config.auto_isHideFS = true; }
}
h2p_DYScript_config.isHidePS = vue_config.auto_isHidePS;
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_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) );
},
}
});
BOOL_vue_config = true;
window.clearInterval(INVL_createVue_config);
INVL_createVue_config = undefined;
}
}, 100);
// 检查弹幕图标挂载点(斗鱼弹幕输入框)是否加载完成
var check_mountPoint_DYScriptIcon = setInterval( ()=>{
if ( $h2p_j('div#div-DYScript').length > 0 && $h2p_j('div.BarrageSuperLink').length > 0 ) {
let div_sign = $h2p_j('<div class="h2p-div-sign" style="margin: -8px 0 0 -3px;" title="斗鱼脚本"></div>');
let btn_sign = $h2p_j('<span id="button-DYScript" class="h2p-span-sign">🐯</span>');
$h2p_j(btn_sign).click(()=>{ $h2p_j('div#div-DYScript').toggle(); });
$h2p_j(div_sign).append(btn_sign);
$h2p_j('div.ChatToolBar').append( div_sign );
window.clearInterval(check_mountPoint_DYScriptIcon);
}
}, 500);
$h2p_j(div_DYScript).append(div_DYScriptTab);
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 获取自动化配置
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 斗鱼功能自动化配置
var h2p_DYScript_config;
var h2p_DYScript_config_def = {
speedMin : 6000,
speedMax : 7000,
isCopy : false,
INVL_copy : 0,
isLoop : false,
loopBarCon : '',
iskeyReply : false,
keyReplys : [],
isLuckDraw : false,
CNT_luckDraw: 2,
isHidePS : false,
isHideWS : false,
isHideFS : false,
getFB : false,
signIn : false,
};
(()=>{
try{
// 获取本地用户配置
let settingValue = JSON.parse( localStorage.getItem('h2p-DYScript-config') );
if ( !settingValue ) {
settingValue = JSON.parse( localStorage.getItem('h2p-DYScript-setting') );
localStorage.removeItem('h2p-DYScript-setting');
}
h2p_DYScript_config = JSON.parse( JSON.stringify(h2p_DYScript_config_def) );
for ( let attr in settingValue ) {
if ( attr in h2p_DYScript_config ) {
h2p_DYScript_config[attr] = settingValue[attr];
}
}
if ( 'loopBarrage' in settingValue ) { h2p_DYScript_config.isLoop = settingValue.loopBarrage; }
if ( 'loopBarContext' in settingValue ) { h2p_DYScript_config.loopBarCon = settingValue.loopBarContext; }
if ( 'copyBarrage' in settingValue ) { h2p_DYScript_config.isCopy = settingValue.copyBarrage; }
if ( 'luckDrawBarrage' in settingValue ) { h2p_DYScript_config.isLuckDraw = settingValue.luckDrawBarrage; }
if ( 'receiveFishBall' in settingValue ) { h2p_DYScript_config.getFB = settingValue.receiveFishBall; }
if ( 'hidePart' in settingValue ) { h2p_DYScript_config.isHidePS = settingValue.hidePart; }
if ( 'hideWS' in settingValue ) { h2p_DYScript_config.isHideWS = settingValue.hideWS; }
if ( 'hideAll' in settingValue ) { h2p_DYScript_config.isHideFS = settingValue.hideAll; }
localStorage.setItem('h2p-DYScript-config', JSON.stringify(h2p_DYScript_config) );
} catch (err) {
// 重置本地配置
console.log('重置本地配置');
localStorage.removeItem('h2p-DYScript-config');
h2p_DYScript_config = h2p_DYScript_config_def;
localStorage.setItem('h2p-DYScript-config', 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;
})();
// 自动获取已有徽章的主播
var roomOfAnchorFan = [];
setTimeout( () => {
$h2p_j('html').append('<div id="FansBadgeList" style="display: none"></div>');
setTimeout( () => {
// 获取有粉丝牌的主播房间号
$h2p_j('div#FansBadgeList').load('/member/cp/getFansBadgeList [class="aui_room_table fans-badge-list"]');
setTimeout( () => {
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 anchorRoom = anchorURL.split('/').pop();
roomOfAnchorFan[i] = anchorRoom;
}
let anchorRoom= window.location.href.split('/').pop();
userInfo.isAnchorFan = roomOfAnchorFan.indexOf(anchorRoom) > -1;
console.log(`有粉丝牌的主播房间号${JSON.stringify(roomOfAnchorFan)}`);
}, 3000);
}, 200)
}, 1000);
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// 应用自动化配置
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
(()=>{
// 自动发弹幕自动化设置生效
var INVL_config_bar_work = setInterval(()=>{
if ( BOOL_vue_sendBar && BOOL_vue_config && BOOL_ok_localS ) {
let auto_send = false;
vue_sendBar.speedMin = h2p_DYScript_config.speedMin;
vue_sendBar.speedMax = h2p_DYScript_config.speedMax;
if ( h2p_DYScript_config.isCopy ) {
vue_sendBar.isCopy = true;
vue_config.auto_isCopy = true;
auto_send = true;
}
if ( h2p_DYScript_config.isLoop ) {
vue_sendBar.isLoop = true;
vue_config.auto_isLoop = true;
auto_send = true;
}
if ( h2p_DYScript_config.isKeyReply ) {
vue_sendBar.isKeyReply = true;
vue_config.auto_isKeyReply = true;
auto_send = true;
}
if ( h2p_DYScript_config.keyReplys ) {
for ( let i = 0; i < h2p_DYScript_config.keyReplys.length; i++ ) {
vue_sendBar.keyReplys.push( h2p_DYScript_config.keyReplys[i] );
}
}
if ( h2p_DYScript_config.isLuckDraw ) {
vue_sendBar.isLuckDraw = true;
vue_config.auto_isLuckDraw = true;
auto_send = true;
}
$h2p_j('input#input-copyBar-interval').val(h2p_DYScript_config.INVL_copy);
$h2p_j('textarea#input-loopBar-content').val(h2p_DYScript_config.loopBarCon);
if ( auto_send ) { $h2p_j('button#btn-sendBar').click(); }
window.clearInterval(INVL_config_bar_work);
}
}, 500);
// 清爽模式自动化设置生效
var INVL_config_clear_work = setInterval(()=>{
if ( BOOL_vue_clear && BOOL_ok_localS ) {
if ( h2p_DYScript_config.isHidePS ) {
vue_config.auto_isHide = true;
vue_config.auto_isHidePS = true;
$h2p_j('select#select-hideMode > option[value="hidePS"]').attr('selected', true);
$h2p_j('button#btn-hide-ps').click();
console.log('启动:隐藏部分');
}
else if ( h2p_DYScript_config.isHideWS ) {
vue_config.auto_isHide = true;
vue_config.auto_isHideWS = true;
$h2p_j('select#select-hideMode > option[value="hideWS"]').attr('selected', true);
$h2p_j('button#btn-hide-ws').click();
console.log('启动:宽屏模式');
}
else if ( h2p_DYScript_config.isHideFS ) {
vue_config.auto_isHide = true;
vue_config.auto_isHideFS = true;
$h2p_j('select#select-hideMode > option[value="hideFS"]').attr('selected', true)
$h2p_j('button#btn-hide-fs').click();
console.log('启动:网页全屏');
}
window.clearInterval(INVL_config_clear_work);
}
}, 500);
// 领取鱼丸自动化设置生效
var INVL_config_getFB_work = setInterval(()=>{
if ( BOOL_ok_config && h2p_DYScript_config.getFB ) {
auto_getFB();
$h2p_j('input-auto-getFB').attr('checked', true);
console.log('启动:自动领取观看鱼丸');
window.clearInterval(INVL_config_getFB_work);
}
}, 500);
// 签到自动化设置生效
var INVL_config_signIn_work = setInterval(()=>{
if ( BOOL_ok_config && h2p_DYScript_config.signIn ) {
auto_signIn();
$h2p_j('input-auto-signIn').attr('checked', true);
console.log('启动:自动签到');
window.clearInterval(INVL_config_signIn_work);
}
}, 500);
})();
})();