Youtube live, Chat author name hide/clip

Author name of chat is hide or clip. Possible to change config in source code.

当前为 2020-10-01 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Youtube live, Chat author name hide/clip
// @name:ja      Youtube live, チャット投稿者名 非表示/短縮
// @description  Author name of chat is hide or clip. Possible to change config in source code.
// @description:ja チャット投稿者名が非表示または短縮表示にされます。スクリプトのソース内で設定変更できます。
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       You
// @match        https://www.youtube.com/live_chat*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // ================
    // config
    // ================

    // if true, author name is hide
    var isHideAuthorName = false;
    // if true, author name is display to right side in chat window
    var isAuthorNameRightSide = true;
    var authorNameMaxWidth = 100;
    // if true, user thumbnail is hide
    var isHideThumbnail = false;
    // if true, member badge is hide
    var isHideBadge = false;
    // if true, input panel is hide (you can't post chat / super chat)
    var isHideFooter = false;
    // if true, header is hide
    var isHideHeader = true;
    // if true, show/hidden toggle button is hide
    var isHideToggleButton = false;

    // ================

    setTimeout(function () {
        var stylesheet = "";
        // chat font-weight is bold
        stylesheet += "#message.yt-live-chat-text-message-renderer { font-weight: bold; }";
        // latest moderator chat is fixed to bottom in chat window
        stylesheet += "author-type['moderator']:last { position: absolute; bottom: 0; background: #fff; left: 0; right: 0; z-index: 10000; }";

        if (isHideAuthorName) {
            stylesheet += "#author-name.yt-live-chat-author-chip { display: none; }";
        } else if (isAuthorNameRightSide) {
            stylesheet += "#content #author-name.yt-live-chat-author-chip { position: absolute; right: 10px; top: 0px; opacity: 0.7; transform: scale(0.8); }";
        } else {
            stylesheet += "#author-name.yt-live-chat-author-chip { max-width: " + authorNameMaxWidth + "px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }";
        }
        if (isHideThumbnail) {
            stylesheet += "#author-photo { display: none !important; }";
        }
        if (isHideBadge) {
            stylesheet += "#chat-badges { display: none !important; }";
        }
        if (isHideFooter) {
            stylesheet += "#panel-pages { display: none !important; }";
        }
        if (isHideHeader) {
            stylesheet += "yt-live-chat-header-renderer { display: none !important; }";
        }
        if (isHideToggleButton) {
            stylesheet += "#show-hide-button.ytd-live-chat-frame { display: none !important; }";
        }

        var $style = document.createElement("style");
        $style.innerText = stylesheet;
        document.body.appendChild($style);
    }, 5000);
})();