Greasy Fork

Greasy Fork is available in English.

Bilibili Live 全屏发弹幕

Bilibili直播 全屏发弹幕

当前为 2018-09-23 提交的版本,查看 最新版本

// ==UserScript==
// @name         Bilibili Live 全屏发弹幕
// @namespace    http://greasyfork.icu/zh-CN/users/196399-xyabc120
// @icon         http://static.hdslb.com/images/favicon.ico
// @version      1.0
// @description  Bilibili直播 全屏发弹幕
// @author       Mr.ZHAO
// @include      https://live.bilibili.com/*
// @require      https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// @grant        GM_addStyle
// @compatible   chrome  支持
// @compatible   firefox 支持
// @license      MIT;
// ==/UserScript==

(function() {
    'use strict';

    var $ = window.jQuery;
    if (!window.jQuery) {
        (function waitForJquery(){
            if (!window.jQuery){
                setTimeout(waitForJquery, 100);
            } else {
                $ = window.jQuery;
                addFullscreenListener();
            }
        })();
    } else {
        addFullscreenListener();
    }

    var fullStyle = `
    .full-container {
        position: fixed!important;
        left: 0; right: 0; bottom: 0;
        height: 78px;
        width: 100%;
        max-width: calc(100% - 830px);
        display: block;
        margin: 0 auto;
        background: linear-gradient(90deg,transparent,rgba(0,0,0,.7),transparent);
    }
    .full-container > div{ width: 450px; margin: 0 auto;}
    .full-container textarea.chat-input{ height:35px; width: 350px;}
    .full-container .chat-input-ctnr{ position: absolute }
    .full-container .right-action button{ height:35px; }
    .full-container .left-action, .full-container #chatHelper, .full-container .icon-clear, .full-container .icon-unlock-1{ display: none }
   `;
    GM_addStyle(fullStyle);

    function addFullscreenListener(){
        var MutationObserver = window.MutationObserver;
        var observer = new MutationObserver(toggleStyle);
        observer.observe(document.body, { attributes: true, childList: false, characterData: false });
    }

    function toggleStyle(){
        var className = "full-container";
        var control = $("#chat-control-panel-vm");
        if($(document.body).hasClass("fullscreen-fix")){
            $(".bilibili-live-player-video-controller").append(control.addClass(className));
        } else {
            $(".aside-area").append(control.removeClass(className));
        }
    }
})();