Greasy Fork

Greasy Fork is available in English.

虎牙自动弹幕以及页面精简、斗鱼页面精简 脚本[更多关注 纯净至上公众号]

去除虎牙和斗鱼多余的部分 破解虎牙关键字限制 虎牙自动发送弹幕 namespace主页是公众号教程地址

当前为 2019-09-03 提交的版本,查看 最新版本

// ==UserScript==
// @name        虎牙自动弹幕以及页面精简、斗鱼页面精简 脚本[更多关注 纯净至上公众号]
// @namespace    https://mp.weixin.qq.com/s/H3twfD4wXZuxFjyNQMYepA
// @require			https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// @version      2.2.1
// @description  去除虎牙和斗鱼多余的部分 破解虎牙关键字限制 虎牙自动发送弹幕 namespace主页是公众号教程地址
// @author       Bitle
// @license           MIT
// @match        *://www.huya.com/*
//@match         *://www.douyu.com/*
// @run-at            document-idle
// @grant             unsafeWindow
// @grant             GM_xmlhttpRequest
// @grant             GM_download
// @grant             GM_setClipboard
// @grant             GM_setValue
// @grant             GM_getValue
// @grant             GM_openInTab
// ==/UserScript==

(function() {
    'use strict';
    var $_ = function(para){
        let judgeSelect = para.toString().substring(0,1);
        let valueSelect = para.toString().substring(1);
        var el;
        if(judgeSelect==="."){
            el = document.getElementsByClassName(valueSelect)[0];
        }else if(judgeSelect==="#"){
            el = document.getElementById(valueSelect);
        }
        return el;
    }
    var s = setInterval(function () {
        var a_ = $_('.closeBg-998534');
        var b_ = $_('.layout-Aside');
        var c_ = $_('.layout-Player-toolbar');
        var d_ = $_('#js-player-toolbar');
        var e_ = $_('.layout-Player-barrage');
        var f_ = $_('.ChatTabContainer');
        var g_ = $_('.layout-Player-rank');
        var h_ = $_('.layout-Player-announce');
        var i_ = $_('.layout-Player-guessgame');
        var j_ = $_('#js-bottom');
        var k_ = $_('.UPlayerLotteryEnter');
        var l_ = $_('.LotteryContainer');
        let m_ = $_('.layout-Main');
        let n_ = $_('.layout-Player-main');
        let o_ = $_('.SignBaseComponent-sign-box');
        let p_ = $_('.AppFlow is-show');

        let a = $_('.mod-list');
        let b = $_('.mod-sidebar');
        let c = $_('.player-gift-wrap');
        let d = $_('.player-ctrl-wrap');
        let e = $_('.room-footer');
        let f = $_('.room-gg-chat');
        let g = $_('.room-sidebar-hd');
        let h = $_('.J_input');
        let h2 = document.getElementsByClassName("J_input")[1];
        let i = $_('.roomBlockWords-list');
        let i2 = document.getElementsByClassName("roomBlockWords-list")[1];
        let j = $_('.main-wrap');
        let k = $_(".main-room");
        let l = $_(".chat-room");
        let m = $_(".chat-room__bd");
        //
        if (a_) {
            a_.parentNode.removeChild(a_);
        }
        if (b_) {
            b_.parentNode.removeChild(b_);
        }
        if (c_) {
            c_.parentNode.removeChild(c_);
        }
        if (d_) {
            d_.parentNode.removeChild(d_);
        }
        if (e_) {
            e_.style.top=0;
        }
        if (f_) {
            f_.parentNode.removeChild(f_);
        }
        if (g_) {
            g_.parentNode.removeChild(g_);
        }
        if (h_) {
            h_.parentNode.removeChild(h_);
        }
        if (i_) {
            i_.parentNode.removeChild(i_);
        }
        if(j_){
            j_.parentNode.removeChild(j_);
        }
        if(k_){
            k_.parentNode.removeChild(k_);
        }
        if(l_){
            l_.parentNode.removeChild(l_);
        }
        if(m_){
            m_.style.margin = "0px";
            m_.style.padding = "0px";
        }
        if(n_){
            n_.style.height = "110%";
        }
        if(o_){
            o_.parentNode.removeChild(o_);
        }
        if(p_){
            p_.parentNode.removeChild(p_);
        }
        if(a){
            a.style.padding="0px";
        }
        if(b){
            b.parentNode.removeChild(b);
        }
        if(c){
            c.parentNode.removeChild(c);
        }
        if(d){
            d.style.position = "unset";
            d.style.marginTop = "1px";
        }
        if(e){
            e.parentNode.removeChild(e);
        }
        if(f){
            f.parentNode.removeChild(f);
        }
        if(g){
            g.parentNode.removeChild(g);
        }
        if(h||h2){
            if(h.getAttribute("maxlength")=="10"||h.getAttribute("disabled")==""||h2.getAttribute("maxlength")=="10"||h2.getAttribute("disabled")==""){
                h.removeAttribute("disabled");
                h2.removeAttribute("disabled");
                h.setAttribute("maxlength","n");
                h2.setAttribute("maxlength","n");
            }
        }
        if(i||i2){
            i.style.overflow ="scroll";
            i.style.height ="333px";
            i.style.zIndex = "999999999";
            i2.style.overflow ="scroll";
            i2.style.height ="336px";
            i2.style.zIndex = "999999999";
        }

        if(j){
            if(j.style.paddingLeft!="0px"){
                j.style.padding="55px 0 0 0";
            }
        }
        if(k){
            k.style.paddingLeft = "10px";
        }
        if(l||m){
            l.style.height = "520px";
            m.style.height = "100%";
        }
    },1000);

    var str_div_speed_countDown = (function(){/*
			<div id="open" style="cursor:pointer;width: 40px;height: 40px;border-radius:6px;background:#65c294;position: fixed;right: 100px;bottom:60px;color: #ffffff;text-align: center;line-height: 40px;font-weight: bolder;z-index: 999999999999;">开</div>
    <div id="barrage" style="display:none;position:fixed;top:0;background: #65c294;width: 200px;height: 230px;z-index: 999999999999;">
        <div id="close" style="color: #ffffff;font-size: 15px;height: 30px;line-height:30px;text-align: center;font-weight: bold;border-bottom: 1px solid #eeeeee;cursor: pointer;">自动弹幕</div>
        <div style="margin-top: 3px;height: 30px;">
            <span style="color: #ffffff;font-size: 15px;line-height: 30px;vertical-align:top;margin-left: 3px;">时间(s):</span>
            <textarea id="setTime" placeholder="默认10s" style="width: 80px;vertical-align:top;line-height: 8px;resize: none;color: #232323;padding-top: 9px;"></textarea>
        </div>
        <div style="height: 130px;">
            <span style="color: #ffffff;font-size: 15px;line-height: 30px;vertical-align:top;margin-left: 3px;">输入弹幕:</span>
            <textarea id="barrage_text" placeholder="多个弹幕请换行" style="width: 187px;height: 90px;resize: none;margin-left: 3px;"></textarea>
        </div>
        <div id="comfirm" style="color: #ffffff;font-size: 15px;height: 30px;line-height: 30px;text-align:center;background: green;margin-top: 0;cursor: pointer;">开始执行</div>
    </div>
		*/}).toString().split('/*')[1].split('*/')[0].replace(/[\n]/g, '');

	  $("body").append(str_div_speed_countDown);

//if(window.APP_URL=="https://www.huya.com/"){
$('#barrage').mousedown(function (e) {
        var positionDiv = $(this).offset();
        var distenceX = e.pageX - positionDiv.left;
        var distenceY = e.pageY - positionDiv.top;

        $(document).mousemove(function (e) {
            var x = e.pageX - distenceX;
            var y = e.pageY - distenceY;
            if (x < 0) {
                x = 0;
            } else if (x > $(document).width() - $('#barrage').outerWidth(true)) {
                x = $(document).width() - $('#barrage').outerWidth(true);
            }
            if (y < 0) {
                y = 0;
            } else if (y > $(document).height() - $('#barrage').outerHeight(true)) {
                y = $(document).height() - $('#barrage').outerHeight(true);
            }
            let obj = { x: x, y: y };
            window.localStorage.setItem("coordinate", JSON.stringify(obj));

            $('#barrage').css({
                'left': x + 'px',
                'top': y + 'px'
            });
        });
        $(document).mouseup(function () {
            $(document).off('mousemove');
        });
    });


    $('#open').mousedown(function (e) {
        var positionDiv = $(this).offset();
        var distenceX = e.pageX - positionDiv.left;
        var distenceY = e.pageY - positionDiv.top;

        $(document).mousemove(function (e) {
            var x = e.pageX - distenceX;
            var y = e.pageY - distenceY;
            if (x < 0) {
                x = 0;
            } else if (x > $(document).width() - $('#open').outerWidth(true)) {
                x = $(document).width() - $('#open').outerWidth(true);
            }
            if (y < 0) {
                y = 0;
            } else if (y > $(document).height() - $('#open').outerHeight(true)) {
                y = $(document).height() - $('#open').outerHeight(true);
            }
            let obj = { x: x, y: y };
            window.localStorage.setItem("coordinate_two", JSON.stringify(obj));

            $('#open').css({
                'left': x + 'px',
                'top': y + 'px'
            });
        });
        $(document).mouseup(function () {
            $(document).off('mousemove');
        });
    });
    $("#open").click(function () {
        $("#open").slideToggle();
        $("#barrage").slideToggle();
        let x = JSON.parse(window.localStorage.getItem("coordinate")).x;
        let y = JSON.parse(window.localStorage.getItem("coordinate")).y;
        $('#barrage').css({
            'left': x + 'px',
            'top': y + 'px'
        });
    });
    $("#close").click(function () {
        $("#barrage").slideToggle();
        $("#open").slideToggle();
    });
    let defualtTime = 10;
    let defualtBarrage = [];
    var comfirmStatus = true;
    var stop;
    let countTime = function (time) {
        let time_ = time * 1000;
        let len = $('#barrage_text').val().split("\n").length;
        defualtBarrage = $('#barrage_text').val().split("\n");
        $('#comfirm').text("停止执行");
        stop = setInterval(function () {

            $(".chat-room__input>span").attr("class","btn-sendMsg enable");
    $('#pub_msg_input').val(defualtBarrage[random_(len)]);
    $('.btn-sendMsg').click();
        }, time_);
    }
    let random_ = function (len) {
        let rand = Math.floor(Math.random() * len);
        return rand;
    }
    $('#comfirm').click(function () {
        if (comfirmStatus == true) {
            comfirmStatus = false;
            var reg = new RegExp("^[0-9]*$");
            let value = parseInt($('#setTime').val());
            window.localStorage.setItem("barrageText", JSON.stringify($('#barrage_text').val()));
            if (reg.test(value)) {
                window.localStorage.setItem("countTime", JSON.stringify(value));
                countTime(value);
            } else if ($('#setTime').val() == "") {
                countTime(defualtTime);
            } else {
                alert("时间填写不是数字");
            }
        } else {
            comfirmStatus = true;
            $('#comfirm').text("开始执行")
            clearInterval(stop);
        }

    });

$(function(){
    let x = JSON.parse(window.localStorage.getItem("coordinate_two")).x;
        let y = JSON.parse(window.localStorage.getItem("coordinate_two")).y;
        let countTime = JSON.parse(window.localStorage.getItem("countTime"));
        let barrageText = JSON.parse(window.localStorage.getItem("barrageText"));
        $('#setTime').val(countTime);
        $('#barrage_text').val(barrageText);
        $('#open').css({
            'left': x + 'px',
            'top': y + 'px'
        });
    });

//}

})();