Greasy Fork

来自缓存

Greasy Fork is available in English.

超级小桀房间小助手

快速下注、自动签到、自动抢分、查看积分详情、查看地图详情、查看竞猜信息、快速压鱼丸、快速发弹幕、去广告、极简模式。

当前为 2019-05-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @author DreamChaser
// @description 快速下注、自动签到、自动抢分、查看积分详情、查看地图详情、查看竞猜信息、快速压鱼丸、快速发弹幕、去广告、极简模式。
// @icon https://apic.douyucdn.cn/upload/avatar/002/86/30/15_avatar_big.jpg
// @name 超级小桀房间小助手
// @version 1.5.5
// @match https://www.douyu.com/*
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_notification
// @namespace http://greasyfork.icu/zh-CN/users/285196-dreamchaser
// @require https://code.jquery.com/jquery-2.1.4.min.js
// @connect xiaojie666.com
// @connect open.douyucdn.cn
// ==/UserScript==

var $ = window.jQuery;
var x,y;
var dragFlag = false,sighInFlag = true,giftFlag=true,activateFlag=false,loopFlag=false,qfFlag=false,closeFlag=false;
var lastText = "",loopText="",text="",lastLog="";
var nickname = getCookie('acf_nickname');
//var acf_did = getCookie('acf_did');
//var acf_uid = getCookie('acf_username');
//var acf_ltkid = getCookie('acf_ltkid');
//var acf_stk = getCookie('acf_stk');
var lastGiftNum=0,giftNum=0,lastBetCount=-1,betSelect,ywSelected,color,giftStatusCheck,giftOpen,qf,exqf,creditQf,chatSendClick;
var mapsJSON,creditJSON,onlineJSON;
var fullTailText=GM_getValue('fullTailText', ''),tailFlag=1;
var lastCredit=GM_getValue('lastCredit',-1),lastMaxCredit=GM_getValue('lastMaxCredit',-1),myCredit=GM_getValue('myCredit',-1);
var log=GM_getValue('log','');
var year,month,date,h,m,s,now,nowYMD,nowHMS;
var roomStatus=GM_getValue('lastRoomStatus',0),lastRoomStatus=GM_getValue('lastRoomStatus',-1);
var notifyText;
var loopInterval,intervalTime=3000;
var pathName=window.location.pathname;
var height;
var div = document.createElement('div');
var dragDiv=document.getElementById("drag");
div.setAttribute('id', 'newDiv');
div.style.setProperty('position', 'fixed');
div.style.setProperty('height', height+'px');
div.style.setProperty('width', '258px');
div.style.setProperty('background', 'rgba(222, 222, 222, 0.8)');
div.style.setProperty('left', '3%');
div.style.setProperty('top', '10%');
div.style.setProperty('border', '1px solid #96c2f1');
div.style.setProperty('z-index', '999');
div.style.setProperty('box-shadow', '0 1px 5px 4px #888888');
div.innerHTML = (function(){/*
<section id="drag" readonly="value" style="background:white">
  <p style="font-weight: bold;height: 30px;text-align: left;margin-left: 7px;margin-right: 7px;"><a href="https://www.douyu.com/74751">超级小桀</a>房间小助手
    <span id="online"></span>
      <input type="button" id="bnt_donate" style="width: 65px;margin-top: 4px;margin-left: 27px;font-weight: bold;color:red;" value="支持一下"></p>
</section>
<section id="hide" style="margin-top: 5px;margin-left: 7px;margin-right: 7px;">
  <p style="height: 22px;">
    <input class="magic-checkbox" type="checkbox" id="hidecredit" style="height:17px;width:17px;vertical-align: middle;" checked="checked">&nbsp;个人信息&nbsp;&nbsp;&nbsp;&nbsp;
    <input class="magic-checkbox" type="checkbox" id="hidemaps" style="margin-left: 7xp;height:17px;width:17px;vertical-align: text-top;" checked="checked">&nbsp;地图信息&nbsp;&nbsp;&nbsp;&nbsp;
    <input class="magic-checkbox" type="checkbox" id="hideinstructions" style="margin-left: 7xp;height:17px;width:17px;vertical-align: text-top;" checked="checked">&nbsp;功能指令</p>
  <p style="height: 22px;">
    <input class="magic-checkbox" type="checkbox" id="hidedanmu" style="height:17px;width:17px;vertical-align: text-top;" checked="checked">&nbsp;弹幕发送&nbsp;&nbsp;&nbsp;&nbsp;
    <input class="magic-checkbox" type="checkbox" id="hideqfqd" style="height:17px;width:17px;vertical-align: text-top;" checked="checked">&nbsp;抢分签到&nbsp;&nbsp;&nbsp;&nbsp;
    <input class="magic-checkbox" type="checkbox" id="hidebet" style="height:17px;width:17px;vertical-align: text-top;" checked="checked">&nbsp;竞猜信息</p>
  <p style="height: 22px;">
    <input class="magic-checkbox" type="checkbox" id="hidelog" style="height:17px;width:17px;vertical-align: middle;" checked="checked">&nbsp;日志信息
    <input type="button" id="bnt_hide" style="width: 75px;margin-left: 12px;margin-right: 5px;" value="显示">
    <select id="watchstyle" style="height:22px;width: 75px;background-color:hsla(0,0%,100%,.4);">
      <option>完整模式</option>
      <option>极简模式</option>
      <option>挂机模式</option></select>
  </p>
    </section>
<section id="credit" style="margin-top: 5px;margin-left: 7px;margin-right: 7px;">
  <textarea id="showcredit" style="height:96px;width: 237px;line-height:12pt;overflow:hidden;resize:none;background-color:hsla(0,0%,100%,.4);" readonly="value"></textarea>
</section>
<section id="maps" style="margin-top: 5px;margin-left: 7px;margin-right: 7px;">
  <textarea id="showmaps" style="height:112px;width: 237px;line-height:12pt;resize:none;background-color:hsla(0,0%,100%,.4);" readonly="value"></textarea>
</section>
<section id="instructions" style="margin-top: 5px;margin-left: 7px;margin-right: 7px;">
  <input type="button" id="bnt_fullmapsmess" style="width:75px;" value="地图详情">
  <input type="button" id="bnt_help" style="width:75px;margin-left: 5px;margin-right: 6px;" value="帮助">
  <input type="button" id="bnt_renew" style="width:75px;" value="刷新">
  <input type="button" id="bnt_getcredit" style="width:75px;" value="#抢分">
  <input type="button" id="bnt_joingroup" style="width:75px;margin-left: 5px;margin-right: 6px;margin-top: 5px;" value="#入团">
  <input type="button" id="bnt_vip" style="width:75px;" value="#购买会员">
  <select id="betselect" style="height:22px;width:75px;background-color:hsla(0,0%,100%,.4);">
    <option style="color:red">#1</option>
    <option style="color:blue">#2</option></select>
  <select id="betcredit" style="height:22px;width:75px;margin-top:5px;margin-left: 5px;margin-right: 6px;background-color:hsla(0,0%,100%,.4);">
    <option>压1/5</option>
    <option>压1/4</option>
    <option>压1/3</option>
    <option>压一半</option>
    <option>全压了</option></select>
  <input type="button" id="bnt_confirm" style="height: 22px;width: 75px;color: red;" value="压分">
</section>
<section id="danmu" style="margin-top: 5px;margin-left: 7px;margin-right: 7px;">
  <textarea id="write" style="float: left;height: 47px;width: 153px;margin-right: 9px;line-height:12pt;overflow:hidden;resize:none;background-color:hsla(0,0%,100%,.4);" placeholder="请输入要发送的弹幕内容"></textarea>
  <p>
    <input class="magic-checkbox" type="checkbox" id="enter" style="height:17px;width:17px;vertical-align: bottom;">&nbsp;Enter发送
    <input class="magic-checkbox" type="checkbox" id="loop" style="height:17px;width:17px;vertical-align: bottom;">&nbsp;循环发送
    <input class="magic-checkbox" type="checkbox" id="random" style="height:17px;width:17px;vertical-align: bottom;">&nbsp;随机数</p>
  <select id="danmuselect" style="height:22px;width:75px;background-color:hsla(0,0%,100%,.4);">
    <option>普通弹幕</option>
    <option>高级弹幕</option>
    <option>上电视</option></select>
  <select id="color" style="height:22px;width:75px;margin-top:5px;margin-left: 5px;margin-right: 6px;background-color:hsla(0,0%,100%,.4);" disabled="disabled">
    <option style="color:blue">蓝</option>
    <option style="color:green">绿</option>
    <option style="color:pink">粉</option>
    <option style="color:orange">橙</option>
    <option style="color:purple">紫</option>
    <option style="color:red">红</option></select>
  <input type="button" id="bnt_chatsend" style="height: 22px;width: 75px;color: black;" value="发送">
</section>
<section id="qfqd" style="margin-top: 5px;margin-left: 7px;margin-right: 7px;display: block;">
  <p style="height: 27px;">
    <select id="formatselect" style="height:22px;width:75px;background-color:hsla(0,0%,100%,.4);">
      <option>抢分/签到+小尾巴</option>
      <option>抢分/签到+小尾巴+时间</option>
      <option>抢分/签到+时间+小尾巴</option></select>
    <textarea id="tail" style="height: 16px;width: 69px;margin-left: 5px;margin-right: 6px;line-height:12pt;overflow:hidden;resize:none;vertical-align: bottom;background-color:hsla(0,0%,100%,.4);" placeholder="小尾巴"></textarea>
    <input type="button" id="bnt_tailsave" style="width:75px;margin-right: auto;" value="保存"></p>
  <p>
    <input class="magic-checkbox" type="checkbox" id="autoqf" style="height:17px;width:17px;vertical-align: middle;" checked="checked">&nbsp;自动抢分&nbsp;&nbsp;&nbsp;&nbsp;
    <input class="magic-checkbox" type="checkbox" id="autoqd" style="margin-left: 7xp;height:17px;width:17px;vertical-align: text-top;" checked="checked">&nbsp;自动签到&nbsp;&nbsp;&nbsp;&nbsp;
    <input class="magic-checkbox" type="checkbox" id="onlinenotify" style="margin-left: 7xp;height:17px;width:17px;vertical-align: text-top;" checked="checked">&nbsp;在播通知</p>
</section>
<section id="log" style="margin-top: 5px;margin-left: 7px;margin-right: 7px;">
  <textarea id="log" style="height:96px;width: 237px;line-height:12pt;resize:none;background-color:hsla(0,0%,100%,.4);" readonly="value"></textarea>
  <input type="button" id="bnt_cleanlog" style="width: 65px;" value="清空日志">
</section>
<section id="bet" style="margin-top: 5px;margin-left: 7px;margin-right: 7px;">
<section id="bet1">
  <textarea id="betmess" style="height:80px;width: 237px;line-height:12pt;overflow:hidden;resize:none;background-color:hsla(0,0%,100%,.4);" readonly="value"></textarea>
  <select id="ywselect" style="height:22px;width:75px;background-color:hsla(0,0%,100%,.4);">
    <option style="color:red">左边</option>
    <option style="color:blue">右边</option></select>
  <select id="ywnum" style="height:22px;width: 75px;margin-left: 5px;margin-right: 6px;background-color:hsla(0,0%,100%,.4);">
    <option>100</option>
    <option>1000</option>
    <option>10000</option>
    <option>ALL IN</option></select>
  <input type="button" id="bnt_ywconfirm" style="height:22px;width:75px;color:red;" value="压鱼丸">
</section>
<section id="bet2" style="margin-top: 5px";>
    <textarea id="betmess1" style="height:80px;width: 237px;line-height:12pt;overflow:hidden;resize:none;background-color:hsla(0,0%,100%,.4);" readonly="value"></textarea>
  <select id="ywselect1" style="height:22px;width:75px;background-color:hsla(0,0%,100%,.4);">
    <option style="color:red">左边</option>
    <option style="color:blue">右边</option></select>
  <select id="ywnum1" style="height:22px;width: 75px;margin-left: 5px;margin-right: 6px;background-color:hsla(0,0%,100%,.4);">
    <option>100</option>
    <option>1000</option>
    <option>10000</option>
    <option>ALL IN</option></select>
  <input type="button" id="bnt_ywconfirm1" style="height:22px;width:75px;color:red;" value="压鱼丸">
</section>
<section id="bet3" style="margin-top: 5px">
      <textarea id="betmess2" style="height:80px;width: 237px;line-height:12pt;overflow:hidden;resize:none;background-color:hsla(0,0%,100%,.4);" readonly="value"></textarea>
  <select id="ywselect2" style="height:22px;width:75px;background-color:hsla(0,0%,100%,.4);">
    <option style="color:red">左边</option>
    <option style="color:blue">右边</option></select>
  <select id="ywnum2" style="height:22px;width: 75px;margin-left: 5px;margin-right: 6px;background-color:hsla(0,0%,100%,.4);">
    <option>100</option>
    <option>1000</option>
    <option>10000</option>
    <option>ALL IN</option></select>
  <input type="button" id="bnt_ywconfirm2" style="height:22px;width:75px;color:red;" value="压鱼丸">
  </section>
</section>
		*/}).toString().split('/*')[1].split('*/')[0].replace(/[\n]/g, '');
document.body.appendChild(div);
div.style.left = GM_getValue('left','3%');
div.style.top = GM_getValue('top','10%');
$("#autoqf").prop("checked",GM_getValue('autoqf',false));
$("#autoqd").prop("checked",GM_getValue('autoqd',false));
$("#enter").prop("checked",GM_getValue('enter',false));
$("#onlinenotify").prop("checked",GM_getValue('onlineNotify',false));

$(document).keypress(function(event){
    if(event.keyCode ==13&&document.getElementById("enter").checked){
        $("#bnt_chatsend").trigger("click");
    }
});

var arr=new Array("bnt_getcredit","bnt_joingroup","bnt_vip","#抢分","#入团","#购买会员");
for (var i=0;i<3;i++){
    addEvent(arr[i],arr[i+3])
}

var creditRankJSON,myCreditRank="",myMaxCreditRank="";
creditRank("credit","myCreditRank",lastCredit);
creditRank("maxCredit","myMaxCreditRank",lastMaxCredit);

var lastWatch=GM_getValue('lastWatch', '完整模式');
if (lastWatch=="极简模式"){
    $("#watchstyle").val("极简模式");
}
else if (lastWatch=="挂机模式"){
    $("#watchstyle").val("挂机模式");
}
watchStyle();

$(document).ready(function (){
    activate();
    creditMess();
    mapsMess();
    betMess();
    recoverStatus();
    online();
    notify();
    var clearAD = setInterval(function(){
        removeAD();
    },1000);
    setTimeout(function(){
        clearInterval(clearAD);
    },10000);
    creditQf=setInterval(function (){
        creditMess();
    },5000);
    setInterval(function(){
        mapsMess();
        logMess();
        online();
        if(document.getElementById("autoqd").checked) {
            sighIn();
        }
    },5000);
    loopInterval=setInterval(loopDanmu,3000);
    setInterval(function(){
        if (pathName=="/74751"){
            GM_setValue('autoqf', document.getElementById("autoqf").checked);
            GM_setValue('autoqd', document.getElementById("autoqd").checked);
            GM_setValue('enter', document.getElementById("enter").checked);
            GM_setValue('loop', document.getElementById("loop").checked);
            GM_setValue('random', document.getElementById("random").checked);
        }
        GM_setValue('onlineNotify', document.getElementById("onlinenotify").checked);
        giftStatusCheck=$('div.TreasureStatus-text').length;
        giftOpen=$('.TreasureStatus-bg.is-open').length;
        if(giftStatusCheck==0){
            giftFlag = true;
        }
        if( document.getElementById("autoqf").checked) {
            exGiftCheck();
            if (giftFlag){
                giftCheck();
            }
        }
        betMess();
    },800);
});

function removeAD(){
    $("div.Bottom-ad").hide();
    $("div.SignBaseComponent-sign-ad").remove();
    $("div.SignBaseComponent-sign-box.RoomChat.Barrage-chat-ad").remove();
    $("div.SysSign-Ad").remove();
    $("div.GuessGameAdContainer").remove();
    $("div.PlayerToolbar-signCont").remove();
    $("div[class*='recommendAD']").remove();
    $("div[class*='recommendApp']").remove();
    $("div.YzMakeFriends.is-active").remove();
}

function watchStyle(){
    var watch=$("#watchstyle").find("option:selected").text();
    if(watch=='完整模式'){
        $("aside#js-aside.layout-Aside").show();
        $("div#js-bottom.layout-Bottom").show();
        $("div#js-player-title.layout-Player-title").show();
        $("header#js-header.layout-Header").show();
        $("main.layout-Main").removeAttr("style");
        $("section.layout-Container").removeAttr("style");

        $("div#js-background-holder.Background-holder").show();
        $("div.layout-Main").removeAttr("style");
        $("div#js-ad-map.layout-Bottom-forDiy").show();
        $("div#js-room-activity").show();

        $("div[class*='wfs-']").click();
        $("div[class*='wfs-exit-']").click();
    }
    else if(watch=='极简模式'){
        $("aside#js-aside.layout-Aside").hide();
        $("div#js-bottom.layout-Bottom").hide();
        $("div#js-player-title.layout-Player-title").hide();
        $("header#js-header.layout-Header").hide();
        $("main.layout-Main").css("cssText","max-width:100%;width:100%;margin:0px;padding:0px;");
        $("section.layout-Container").css("padding","0px");

        $("div#js-background-holder.Background-holder").hide();
        $("div.layout-Main").css("cssText","max-width:100%!important;width:100%!important;");
        $("div#js-ad-map.layout-Bottom-forDiy").hide();
        $("div#js-room-activity").hide();

        $("div[class*='bc-wrapper']").hide();
        $('div.layout-Main').parent("div[class*='bc-wrapper']").attr('style','display:block;');

        $("div[class*='wfs-']").click();
        $("div[class*='wfs-exit-']").click();
    }
    else{
        var count=1;
        var srcRemove=setInterval(function(){
            if($("video[id*='__video']").length!=0){
                setTimeout(function(){
                    $("video[id*='__video']").attr("src", "");
                    $("div.layout-Player-videoMain").remove();
                },1000)
                console.log("blocked live stream")
                clearInterval(srcRemove);
            }
            if(count>30){
                clearInterval(srcRemove);
            }
            count++;
        },500);
        $("div.layout-Player-videoMain").hide();
        $("aside#js-aside.layout-Aside").hide();
        $("div#js-bottom.layout-Bottom").hide();
        $("div#js-player-title.layout-Player-title").hide();
        $("header#js-header.layout-Header").hide();
        $("div#js-player-guessgame.layout-Player-guessgame").hide();
        $("div#js-player-toolbar.layout-Player-toolbar").hide();
        $("main.layout-Main").css("cssText","max-width:100%;width:100%;margin:0px;padding:0px;");
        $("section.layout-Container").css("padding","0px");

        $("div#js-background-holder.Background-holder").hide();
        $("div.layout-Main").css("cssText","max-width:100%!important;width:100%!important;");
        $("div#js-room-activity").hide();
        $("div#js-ad-map.layout-Bottom-forDiy").hide();
        $("div[class*='bc-wrapper']").hide();
        $('div.layout-Main').parent("div[class*='bc-wrapper']").attr('style','display:block;');
    }
    if (watch!=lastWatch){
        if(lastWatch=="挂机模式"){
            window.location.reload();
        }
        lastWatch=watch;
        GM_setValue('lastWatch', lastWatch);
    };
}

function getNow() {
    function fix (s){
        return s < 10 ? '0' + s: s;
    }
    var myDate = new Date();
    year=myDate.getFullYear();
    month=fix(myDate.getMonth()+1);
    date=fix(myDate.getDate());
    h=fix(myDate.getHours());
    m=fix(myDate.getMinutes());
    s=fix(myDate.getSeconds());
    now=year+'-'+month+"-"+date+" "+h+':'+m+":"+s;
    nowYMD=year+'-'+month+"-"+date;
    nowHMS=h+':'+m+":"+s;
}

function notify() {
    var notificationDetails={
        text: (function(){
            /*@笨东儿 *儿 *猫 *人 @绝版石头 *嘉嘉 @苹果DY 匿名大佬 *玮灏 *超群 *友 *迪鑫 *永寿
点我查看新版本预告、tips、支持!*/}).toString().split('/*')[1].split('*/')[0],
        title: "感谢以下水友对本插件的支持",
        image: "https://apic.douyucdn.cn/upload/avatar/002/86/30/15_avatar_big.jpg",
        onclick: function () {
            window.open("https://note.youdao.com/ynoteshare1/index.html?id=a667b6a4cf64b3c053ee091d448f2891&type=note");
        }
    }
    var lastDate=GM_getValue('date', 0);
    getNow();
    GM_setValue('date', nowYMD);
    if(nowYMD != lastDate){
        GM_notification(notificationDetails);
        compareCredit(lastDate);
        lastRoomStatus=-1;
    }
}

function hide(){
    var a=document.getElementById("hidecredit").checked,b=document.getElementById("hidemaps").checked,c=document.getElementById("hideinstructions").checked,d=document.getElementById("hidedanmu").checked,e=document.getElementById("hideqfqd").checked,f=document.getElementById("hidebet").checked,g=document.getElementById("hidelog").checked;
    var arr1=new Array(a,b,c,d,e,f,g,"credit","maps","instructions","danmu","qfqd","bet","log");
    var arr2=new Array(a,b,c,d,e,f,g,"#hidecredit","#hidemaps","#hideinstructions","#hidedanmu","#hideqfqd","#hidebet","#hidelog");
    var trueheight=$('section#drag').outerHeight(true)+$('section#hide').outerHeight(true),height;
    for (var i=0;i<7;i++){
        if (pathName=="/74751"){
            GM_setValue(arr2[i+7], arr2[i]);
        }
        var name="section#"+arr1[i+7]
        height=$(name).outerHeight(true);
        if(arr1[i]&&height!=null){
            $(name).show();
            trueheight+=height;
        }
        else{
            $(name).hide();
        }
    }
    trueheight = $('.GuessGameBox').length ==0 ? trueheight:trueheight+5;
    $("#newDiv").css("height",trueheight);
}

function addEvent(id,str) {
    document.getElementById(id).addEventListener('click', function (event) { danmu(str); }, false);
}

function renew() {
    creditMess();
    mapsMess();
    betMess();
    online();
}

function online(){
    GM_xmlhttpRequest({
        method: "GET",
        url:"http://open.douyucdn.cn/api/RoomApi/room/74751",
        onload:function(response){
            onlineJSON=JSON.parse(response.responseText);
            roomStatus=onlineJSON.data.room_status;
            if(onlineJSON.data.room_status =="1"){
                $('span#online').text('直播中');
                $('span#online').css('color','red');
            }
            else{
                $('span#online').text('已下播');
                $('span#online').css('color','blue');
            }
        }
    })
    if(roomStatus!=lastRoomStatus){
        if(roomStatus==1){
            if(document.getElementById("onlinenotify").checked){
                notifyText={
                    text: (function(){
                        /*超级小桀已开播,点我直达直播间*/}).toString().split('/*')[1].split('*/')[0],
                    title: "超级小桀房间小助手提醒",
                    image: "https://apic.douyucdn.cn/upload/avatar/002/86/30/15_avatar_big.jpg",
                    onclick: function () {
                        window.open("https://www.douyu.com/74751");
                    }
                };
                GM_notification(notifyText);
            }
        }
        else{
            var count=1;
            var close=setInterval(function(){
                if(($('span.dy-ModalRadius-close-x').length!=0)){
                    $('span.dy-ModalRadius-close-x').click();
                    closeFlag=true;
                }
                if(closeFlag || count>30){
                    clearInterval(close);
                    close=null;
                    closeFlag=false;
                }
                count++;
            },1000);
        }
    }
    GM_setValue('lastRoomStatus', roomStatus);
    lastRoomStatus=roomStatus;
};

function creditMess() {
    if(nickname.length== 0){
        $("#showcredit").val( "个人信息:\n暂未查询到您的个人信息。\n请登录您的斗鱼帐号!");
    }
    else{
        GM_xmlhttpRequest({
            timeout:5000,
            method: "GET",
            url: "http://api.xiaojie666.com/xiaojie/credit/query.do?nickName=" + nickname ,
            ontimeout:function(response){
                $("#showcredit").val( "个人信息:\n当前网络异常或服务器异常,请检查当前网络或登录xiaojie666.com查询服务器状态。" );
            },
            onload: function(response) {
                creditJSON = JSON.parse(response.responseText);
                var viptime=new Date(creditJSON.vipDate),showvipdate;
                var year = viptime.getFullYear();
                var month = viptime.getMonth()+1;
                var date = viptime.getDate();
                if (year == 1970) {
                    showvipdate = '未购买';
                }
                else {
                    showvipdate = year + "年" + month+"月" + date+"日";
                }
                $("#showcredit").val( "个人信息:\n昵称:" + creditJSON.nickName + "\n总赚得积分:" + creditJSON.earnedCredit + "\n历史最高积分:" + creditJSON.maxCredit + "   排名:" + myMaxCreditRank + "\n当前积分:" + creditJSON.credit + "   排名:" + myCreditRank + "\n会员到期时间:"+ showvipdate);
                compareCreditQf(lastCredit,creditJSON.credit);
                if(lastMaxCredit < creditJSON.maxCredit){
                    myMaxCreditRank=creditRank("maxCredit","myMaxCreditRank",creditJSON.maxCredit);
                    GM_setValue('lastMaxCredit', creditJSON.maxCredit);
                }
                if(lastCredit!=creditJSON.credit){
                    myCreditRank=creditRank("credit","myCreditRank",creditJSON.credit);
                    var diffCredit=creditJSON.credit-lastCredit;
                    diffCredit>0 ? diffCredit="+"+diffCredit :diffCredit;
                    getNow();
                    GM_setValue('lastCredit', creditJSON.credit);
                    lastCredit=GM_getValue('lastCredit', 0);
                    log=nowHMS+" "+diffCredit+"积分 当前积分为:"+creditJSON.credit+"\n"+log;
                }
            }
        });
    }
}

function creditRank(myCreditClass,myRankClass,myCredit) {
    GM_xmlhttpRequest({
        method: "GET",
        url: "http://api.xiaojie666.com/xiaojie/credit/rank.do?order="+myCreditClass,
        onload:function(response) {
            creditRankJSON = JSON.parse(response.responseText);
            var length=creditRankJSON.length;
            if(myRankClass=="myCreditRank"){
                if(myCredit>=creditRankJSON[length-1].credit){
                    for(var i=0;i<creditRankJSON.length;i++){
                        if(nickname==creditRankJSON[i].nickName){
                            myCreditRank=i+1;
                            return ;
                        }
                    }
                }
                else{
                    myCreditRank="未上榜";
                    return ;
                }
            }
            else if(myRankClass=="myMaxCreditRank"){
                if(myCredit>=creditRankJSON[length-1].maxCredit){
                    for(i=0;i<creditRankJSON.length;i++){
                        if(nickname==creditRankJSON[i].nickName){
                            myMaxCreditRank=i+1;
                            return ;
                        }
                    }
                }
                else{
                    myMaxCreditRank="未上榜";
                    return ;
                }
            }
        }
    });
}

function mapsMess() {
    GM_xmlhttpRequest({
        timeout:5000,
        method: "GET",
        url: "http://api.xiaojie666.com/xiaojie/levelrecord/list.do?page=0&rows=1",
        ontimeout:function(response){
            $("#showmaps").val( "地图信息:\n当前网络异常或服务器异常,请检查当前网络或登录xiaojie666.com查询服务器状态。" );
        },
        onload:function(response) {
            mapsJSON = JSON.parse(response.responseText);
            var lifetime=mapsJSON.levelRecords[0].lifeTime,showpassdate;
            if (lifetime == null) {
                showpassdate = '未知';
            }
            else {
                var min= parseInt(lifetime/60);
                var sec= lifetime%60;
                showpassdate = min+ "分" + sec+"秒";
            }
            $("#showmaps").val("地图信息:\nID:"+ mapsJSON.levelRecords[0].levelId +"\n国家:"+ mapsJSON.levelRecords[0].creator_ntd_origin_zh + "\n全球尝试次数:"+mapsJSON.levelRecords[0].attempts + "\n通过率:"+(mapsJSON.levelRecords[0].clearrate * 100).toFixed(2) + "%\n地图名:" + mapsJSON.levelRecords[0].name_zh + "\n通关尝试次数:" + mapsJSON.levelRecords[0].deathCount + "    用时:" + showpassdate );
        }
    });
}

function logMess() {
    if(log!=lastLog)
    {
        lastLog=log;
        GM_setValue('log', log);
    }
    $("textarea#log").val("日志信息:\n"+log);
}

function cleanLog() {
    GM_setValue('log', '');
    log="";
    logMess();
}

function fullMapsMess(){
    window.open("https://supermariomakerbookmark.nintendo.net/courses/"+ mapsJSON.levelRecords[0].levelId);
}

function donate(){
    window.open("http://note.youdao.com/noteshare?id=a667b6a4cf64b3c053ee091d448f2891&sub=EDF425F0960048C798AE3FAD1F4B20D6");
}

function help(){
    alert((function(){
        /*       显示:将你要显示的功能模块旁边的勾选框打上√,则会显示相应的功能模块,反之则隐藏。
       #签到:输入签到可以获得一定积分,具体获得的积分数量与斗鱼等级,是否加入粉丝团以及是否购买会员有关,每天整点例如5点的前后5分钟可以签到,每半小时可以签到一次。
       #抢分:有散分或者直播间有飞机以上的礼物的时候, 可以输入此命令来随机获得一定的积分。
       #入团:在主播开启一轮新团战之前可以输入此命令,会随机挑选99个水友ID参战,获胜的ID会增加积分,使用此命令不消耗积分。
       #购买会员:购买会员需要消耗5000积分一次,持续时间1个月,可以多次重复购买,重复购买相当于自动续费,会员期间内,你的签到和送礼获得的积分是直接翻倍的。
       #1 5000:1代表投票一号阵营,5000代表下注5000分,#2同理,封盘后不可再压。
       普通弹幕:在直播间发送普通弹幕,与在斗鱼聊天框发送内容无区别,不消耗积分。
       高级弹幕:在直播间发送从左至右移动的彩色弹幕,需要200积分发能发一次,并且需要历史最高积分大于50000。
       上电视:在直播间发送彩色弹幕,一般在屏幕左下角弹出,只有在主播切换到室内镜头画面时才开启这个功能(一般为中午吃饭时),每条消耗10积分。
       小尾巴:在自动签到抢分的时候加上自定义内容,如:“抢分/签到+小尾巴+时间 主播你真丑”则每次自动签到的内容为:“#抢分 主播你真丑 2019-4-9 5:00:00”抢分亦如此。PS:小尾巴可以为空。
       日志:记录使用插件发送的内容和分数变化情况,每天会有与上次使用插件时的积分对比。
       循环发送:重复发送文本框的内容,3S~8S随机间隔发送一次,建议配合随机数一起使用。
       随机数:当发送内容与上次发送内容重复时,在内容后加入随机数,建议打开此选项,以免发送过快,被误封。
       清空日志:仅清除当前日志信息,不会影响对比记录分析。*/}).toString().split('/*')[1].split('*/')[0]);
}

function sendColor(){
    color = $("#color").find("option:selected").text();
    switch (color){
        case '蓝':$("#bnt_chatsend").css("color","blue");break;
        case '绿':$("#bnt_chatsend").css("color","green");break;
        case '粉':$("#bnt_chatsend").css("color","pink");break;
        case '橙':$("#bnt_chatsend").css("color","orange");break;
        case '紫':$("#bnt_chatsend").css("color","purple");;break;
        case '红':$("#bnt_chatsend").css("color","red");break;
    }
}

function danmuSelect(){
    var danmuselect=$("#danmuselect").find("option:selected").text();
    if(danmuselect=='普通弹幕'){
        $('#color').attr("disabled","disabled");
        $("#bnt_chatsend").css("color","black");
    }
    else{
        $("#color").removeAttr("disabled");
        sendColor();
    }
}

function chatSend(){
    var c;
    var danmuselect=$("#danmuselect").find("option:selected").text();
    text = $('#write').val();
    color = $("#color").find("option:selected").text();
    if(danmuselect=='普通弹幕'){
        c = '';
    }
    else if(danmuselect=='高级弹幕'){
        c = '#'+ color + ' ';
    }
    else{
        c = '#上电视 '+ color + '色 ';
    }
    if (text.length==0)
    {
        alert("输入内容为空,请重新输入");
        return;
    }
    else{
        text=c+text;
        danmu(text);
    }
    if(document.getElementById("loop").checked){
        loopFlag=true;
        GM_setValue('loopText',text);
    }
    else{
        loopFlag=false;
    }
    $('#write').val('');
}

function select(){
    betSelect=$("#betselect").find("option:selected").text();
    if(betSelect=='#1'){
        $("#bnt_confirm").css("color","red");
    }
    else{
        $("#bnt_confirm").css("color","blue");
    }
}

function betCredit(){
    betSelect=$("#betselect").find("option:selected").text();
    var betcredit=$("#betcredit").find("option:selected").text();
    var num;
    switch (betcredit){
        case '全压了':;
        case '压一半':num='老子'+betcredit;break;
        case '压1/3':num = parseInt(creditJSON.credit/3);break;
        case '压1/4':num = parseInt(creditJSON.credit/4);break;
        case '压1/5':num = parseInt(creditJSON.credit/5);break;
    }
    danmu(betSelect + " " + num);

}

function ywSelect(set,bnt){
    ywSelected=$("#"+set).find("option:selected").text();
    if(ywSelected=='左边'){
        $("#"+bnt).css("color","red");
    }
    else{
        $("#"+bnt).css("color","blue");
    }
}

function betYw(set,num,bnt){
    var ywnum = $("#"+num).find("option:selected").text();
    ywSelected=$("#"+set).find("option:selected").text();
    if(ywSelected=='左边'){
        switch (bnt){
            case 'bnt_ywconfirm':$('div.GuessContItem.is-left:eq(0)').click();break;
            case 'bnt_ywconfirm1':$('div.GuessContItem.is-left:eq(1)').click();break;
            case 'bnt_ywconfirm2':$('div.GuessContItem.is-left:eq(2)').click();break;
        }
    }
    else{
        switch (bnt){
            case 'bnt_ywconfirm':$('div.GuessContItem.is-right:eq(0)').click();break;
            case 'bnt_ywconfirm1':$('div.GuessContItem.is-right:eq(1)').click();break;
            case 'bnt_ywconfirm2':$('div.GuessContItem.is-right:eq(2)').click();break;
        }
    }
    switch (ywnum){
        case '100':$('.chooseOption:eq(1)').click();break;
        case '1000':$('.chooseOption:eq(2)').click();break;
        case '10000':$('.chooseOption:eq(3)').click();break;
        case 'ALL IN':$('.chooseOption:eq(4)').click();break;
    }
    $('div.guessGame--btn.guessGame--btn--sizeM').click();
}

function recoverStatus() {
    if (pathName=="/74751"){
        var qf=GM_getValue('autoqf',false),qd=GM_getValue('autoqd',false),et=GM_getValue('enter',false),lp=GM_getValue('loop',false),rm=GM_getValue('random',true),oy=GM_getValue('onlineNotify',true);
        var a=GM_getValue('#hidecredit',true),b=GM_getValue('#hidemaps',true),c=GM_getValue('#hideinstructions',true),d=GM_getValue('#hidedanmu',true),e=GM_getValue('#hideqfqd',true),f=GM_getValue('#hidebet',true),g=GM_getValue('#hidelog',true);
        var arr=new Array(a,b,c,d,e,f,g,qf,qd,et,lp,rm,oy,"#hidecredit","#hidemaps","#hideinstructions","#hidedanmu","#hideqfqd","#hidebet","#hidelog",'#autoqf','#autoqd',"#enter","#loop","#random","#onlinenotify");
        for (var i=0;i<13;i++){
            if(arr[i])
            {
                $(arr[i+13]).prop("checked",true);
            }
            else
            {
                $(arr[i+13]).prop("checked",false);
            }
        }
    }
    else{
        arr=new Array("#hidecredit","#hidemaps","#hideinstructions","#hidedanmu","#hideqfqd","#hidelog",'#autoqf','#autoqd',"#enter","#loop","#random");
        for (i=0;i<11;i++){
            $(arr[i]).prop("checked",false);
        }
        $("#hidebet").prop("checked",GM_getValue('#hidebet',true));
        $("#onlinenotify").prop("checked",GM_getValue('onlineNotify',true));
    }
    hide();
}

var betMessFlag=true,betMessClickFlag=false;
var lastPlayerHeight=0;
function betMess() {
    var playerHeight=$("div#js-player-title.layout-Player-title").outerHeight(true)+$("div#js-player-video-case.layout-Player-videoMain").outerHeight(true)+275;
    if(playerHeight!=lastPlayerHeight){
        $('div.layout-Player-guessgame').css('top',playerHeight+'px');
        lastPlayerHeight=playerHeight;
    }
    if($('div.GuessIcon').length!=0&&betMessFlag){
        $('div.GuessIcon').click();
        betMessFlag=false;
        betMessClickFlag=true;
    }
    if($('div.guessGameContainer.is-diyRoom').length!=0&&betMessClickFlag){
        $('div.layout-Player-guessgame').css('position','relative');
        betMessClickFlag=false;
    }
    var betcount=$('.GuessGameBox').length;
    if(betcount!=lastBetCount){
        if(betcount==0)
        {
            $('section#bet1').hide();
            $('section#bet2').hide();
            $('section#bet3').hide();
            lastBetCount=betcount;
        }
        else if(betcount==1){
            $('section#bet1').show();
            $('section#bet2').hide();
            $('section#bet3').hide();
            lastBetCount=betcount;
        }
        else if(betcount==2){
            $('section#bet1').show();
            $('section#bet2').show();
            $('section#bet3').hide();
            lastBetCount=betcount;
        }
        else if(betcount==3){
            $('section#bet1').show();
            $('section#bet2').show();
            $('section#bet3').show();
            lastBetCount=betcount;
        }
        hide();
    }
    switch(betcount){
        case 3:
            $("#betmess2").val("竞猜信息:     "+$('span.GuessMainPanelBoxRight-rightBar:eq(2)').text()+"\n"+$('div.boxLeft:eq(2)').text()+"\n左边:" + $('p.GuessContItem-itemTitle:eq(4)').text()+ "   "+$('p.GuessContItem-itemLoss:eq(4)').text() + "\n右边:"+ $('p.GuessContItem-itemTitle:eq(5)').text()+"   "+$('p.GuessContItem-itemLoss:eq(5)').text()+"\n"+$('.bidNumLeft:eq(2)').text()+" VS "+$('.bidNumRight:eq(2)').text());
        case 2:
            $("#betmess1").val("竞猜信息:     "+$('span.GuessMainPanelBoxRight-rightBar:eq(1)').text()+"\n"+$('div.boxLeft:eq(1)').text()+"\n左边:" + $('p.GuessContItem-itemTitle:eq(2)').text()+ "   "+$('p.GuessContItem-itemLoss:eq(2)').text() + "\n右边:"+$('p.GuessContItem-itemTitle:eq(3)').text()+"   "+$('p.GuessContItem-itemLoss:eq(3)').text()+"\n"+$('.bidNumLeft:eq(1)').text()+" VS "+$('.bidNumRight:eq(1)').text());
        case 1:
            $("#betmess").val("竞猜信息:     "+$('span.GuessMainPanelBoxRight-rightBar:eq(0)').text()+"\n"+$('div.boxLeft:eq(0)').text()+"\n左边:" + $('p.GuessContItem-itemTitle:eq(0)').text()+ "   "+$('p.GuessContItem-itemLoss:eq(0)').text() + "\n右边:"+$('p.GuessContItem-itemTitle:eq(1)').text()+"   "+$('p.GuessContItem-itemLoss:eq(1)').text()+"\n"+$('.bidNumLeft:eq(0)').text()+" VS "+$('.bidNumRight:eq(0)').text());break;
    }
}

function tail(){
    var tailText = $('#tail').val();
    var formatselect = $("#formatselect").find("option:selected").text();
    getNow();
    if(formatselect=='抢分/签到+小尾巴'){
        fullTailText=tailText;
        tailFlag=1;
    }
    else if (formatselect=='抢分/签到+小尾巴+时间'){
        if (tailText.length==0){
            fullTailText=nowHMS;
        }
        else {
            fullTailText=tailText+" "+nowHMS;
        }
        tailFlag=2;
    }
    else {
        if (tailText.length==0){
            fullTailText=nowHMS;
        }
        else{
            fullTailText=nowHMS+" "+tailText;
        }
        tailFlag=3;
    }
    GM_setValue('tailText',tailText);
    GM_setValue('tailFlag',tailFlag);
    $('#tail').val('');
    alert("保存成功,当前格式为:#抢分/签到 "+fullTailText);
}

function fullTail(danmu){
    var tailText = GM_getValue('tailText','');
    getNow();
    if (tailText.length==0){
        if(GM_getValue('tailFlag',tailFlag)==1){
            return (danmu);
        }
        else {
            return(danmu+" "+nowHMS);
        }
    }
    else{
        if(GM_getValue('tailFlag',tailFlag)==1){
            return (danmu+" "+tailText);
        }
        else if (GM_getValue('tailFlag',tailFlag)==2){
            return(danmu+" "+tailText+" "+nowHMS);
        }
        else {
            return(danmu+" "+nowHMS+" "+tailText);
        }
    }
}

function activate(){
    var betcount=$('.GuessGameBox').length;
    var dragDiv=document.getElementById("drag");
    dragDiv.addEventListener("mouseover", over,false);
    dragDiv.addEventListener('mousedown', down, false);
    dragDiv.addEventListener('mousemove', move, false);
    dragDiv.addEventListener('mouseup', up, false);
    dragDiv.addEventListener("mouseout", out,false);
    document.getElementById('bnt_donate').addEventListener('click', function (event) { donate(); }, false);
    document.getElementById('bnt_fullmapsmess').addEventListener('click', function (event) { fullMapsMess(); }, false);
    document.getElementById('bnt_renew').addEventListener('click', function (event) { renew(); }, false);
    document.getElementById('bnt_confirm').addEventListener('click', function (event) { betCredit(); }, false);
    document.getElementById('bnt_help').addEventListener('click', function (event) { help(); }, false);
    document.getElementById('betselect').addEventListener('change', function (event) { select(); }, false);
    document.getElementById('bnt_chatsend').addEventListener('click', function (event) { chatSend(); }, false);
    document.getElementById('color').addEventListener('click', function (event) { sendColor(); }, false);
    document.getElementById('danmuselect').addEventListener('change', function (event) { danmuSelect(); }, false);
    document.getElementById('bnt_hide').addEventListener('click', function (event) { hide(); }, false);
    document.getElementById('bnt_tailsave').addEventListener('click', function (event) { tail(); }, false);
    document.getElementById('bnt_cleanlog').addEventListener('click', function (event) { cleanLog(); }, false);
    document.getElementById('ywselect2').addEventListener('change', function (event) { ywSelect('ywselect2','bnt_ywconfirm2'); }, false);
    document.getElementById('bnt_ywconfirm2').addEventListener('click', function (event) { betYw('ywselect2','ywnum2','bnt_ywconfirm2'); }, false);
    document.getElementById('ywselect1').addEventListener('change', function (event) { ywSelect('ywselect1','bnt_ywconfirm1'); }, false);
    document.getElementById('bnt_ywconfirm1').addEventListener('click', function (event) { betYw('ywselect1','ywnum1','bnt_ywconfirm1'); }, false);
    document.getElementById('ywselect').addEventListener('change', function (event) { ywSelect('ywselect','bnt_ywconfirm'); }, false);
    document.getElementById('bnt_ywconfirm').addEventListener('click', function (event) { betYw('ywselect','ywnum','bnt_ywconfirm'); }, false);
    document.getElementById('watchstyle').addEventListener('change', function (event) { watchStyle(); }, false);
}

function over(e) {
    div.style.cursor="move"
}

function out(e) {
    div.style.cursor="auto"
}

function down(e) {
    e = e || window.event;
    x = e.clientX - div.offsetLeft;
    y = e.clientY - div.offsetTop;
    dragFlag = true;
}

function move(e) {
    if (dragFlag) {
        div.style.cursor="move"
        e = e || window.event;
        div.style.left = e.clientX - x + 'px';
        div.style.top = e.clientY - y + 'px';
    }
}

function up(e) {
    if (dragFlag) {
        GM_setValue('left',div.style.left);
        GM_setValue('top',div.style.top);
    }
    dragFlag = false;
    div.style.cursor="auto"
}

function sighIn(){
    getNow();
    if(m==0||m==30){
        if (sighInFlag) {
            danmu(fullTail("#签到"));
            sighInFlag = false
        }
    }
    else {
        sighInFlag = true;
    }
}

function Qf(time){
    clearInterval(creditQf);
    creditQf=setInterval(function (){
        creditMess();
    },time);
}

function giftCheck(){
    if (giftStatusCheck!=0&&giftOpen==0&&$('span.TreasureNum-val').length==0){
        Qf(3000);
        lastGiftNum=1;
        giftFlag = false;
        qfFlag=true;
        var i=0;
        setTimeout(function(){
            danmu(fullTail("#抢分"));
            qf=setInterval(function(){
                danmu(fullTail("#抢分"));
                i++;
                if(i>2){
                    if(qfFlag){
                        i=0;
                    }
                    else{
                        clearInterval(qf);qf=null;
                        Qf(5000);
                    }
                }
            },1100);
        },100);
    }
}

function exGiftCheck(){
    if ($('span.TreasureNum-val').length!=0){
        giftNum=$('span.TreasureNum-val').text();
        if (giftNum>lastGiftNum){
            Qf(3000);
            lastGiftNum=giftNum;
            giftFlag = false;
            qfFlag=true;
            clearInterval(qf);qf=null;
            clearInterval(exqf);exqf=null;
            var i=0;
            setTimeout(function(){
                danmu(fullTail("#抢分"));
                exqf=setInterval(function(){
                    danmu(fullTail("#抢分"));
                    i++;
                    if(i>2){
                        if(qfFlag){
                            i=0;
                        }
                        else{
                            clearInterval(exqf);exqf=null;
                            Qf(5000);
                        }
                    }
                },1100);
            },100);
        }
        else{
            lastGiftNum=giftNum;
        }
    }
    else{
        lastGiftNum=1;
    }
}

function compareCreditQf(lCredit,nCredit){
    if (nCredit>lCredit){
        qfFlag=true;
    }
    else{
        qfFlag=false;
    }
}

function compareCredit(str){
    myCredit=GM_getValue('myCredit',-1);
    if(myCredit!=lastCredit){
        var diffCredit=lastCredit-myCredit;
        diffCredit>0 ? diffCredit="+"+diffCredit :diffCredit;
        getNow()
        lastCredit=GM_getValue('lastCredit', 0);
        GM_setValue('myCredit', lastCredit);
        console.log("今天相对上次使用本插件时("+str+")"+diffCredit+"积分 当前积分为:"+lastCredit+"\n"+nowYMD+"\n");
        log="今天相对上次使用本插件时("+str+")"+diffCredit+"积分 当前积分为:"+lastCredit+"\n"+nowYMD+"\n\n"+log;
    }
    else{
        if(myCredit==-1){
            log="初次使用,对比记录分析将在次日生成,数据初始化...\n"+nowYMD;
            lastCredit=0;
            creditMess();
            setTimeout(function(){
                GM_setValue('myCredit', lastCredit);
            }, 10000);
        }
        else{
            console.log("今天相对上次使用本插件时("+str+")积分无变化,当前积分为:"+lastCredit+"\n"+nowYMD+"\n");
            log="今天相对上次使用本插件时("+str+")积分无变化,当前积分为:"+lastCredit+"\n"+nowYMD+"\n\n"+log;
        }
    }
}

function danmu(str){
    if($('.ChatSend-button.is-gray').length!=0){
        var reconnectFlag=true;
        var n=$('.Barrage-text.Barrage-notice--red').length-1
        if($("a.js-danmu-reconnect.Barrage-notice--red").eq(n).text()=="点击重新连接弹幕"){
            $('a.js-danmu-reconnect.Barrage-notice--red').eq(n)[0].click();
        }
    }
    if($('div.ChatSend-button').text()=='发送'||$('div.ChatSend-button').text()=='开火'){
        if(document.getElementById("random").checked){
            str = (str == lastText ?str + " " + (Math.ceil(Math.random()*10)-1):str);
        }
        $(".ChatSend-txt").val(str);
        if(reconnectFlag){
            chatSendClick=setInterval(function(){
                $('div.ChatSend-button').click();
                if($('.ChatSend-txt').text().length==0){
                    clearInterval(chatSendClick);
                }
            },200);
        }
        else{
            $('div.ChatSend-button').click();
        }
        lastText = str;
        getNow();
        log=nowHMS+" 发送:"+lastText+"\n"+log;
        console.log(nowHMS+" 发送:"+lastText+"\n");
    }

}

function loopDanmu(){
    if(document.getElementById("loop").checked&&loopFlag){
        clearInterval(loopInterval);
        loopInterval=null;
        intervalTime=Math.ceil(Math.random()*10);
        intervalTime=intervalTime >= 5 ? (intervalTime-5)*1000 : intervalTime*1000;
        console.log("下次发送间隔:"+(intervalTime+3000)/1000 + "秒");
        log=("下次发送间隔:"+(intervalTime+3000)/1000) + "秒\n"+log;
        setTimeout(function (){
            text = GM_getValue('loopText',"小助手NB");
            danmu(text);
            loopInterval=setInterval(loopDanmu,3000);
        },intervalTime);
    }
    else{
        loopFlag=false;
    }
}

function getCookie(cname){
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++){
        var c = ca[i].trim();
        if (c.indexOf(name)==0) return c.substring(name.length,c.length);
    }
    return "";
}