Keep TickTock live room clean

Remove Douyin/Ticktock live room useless parts.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Keep TickTock live room clean
// @namespace    http://tampermonkey.net/
// @version      0.7
// @description  Remove Douyin/Ticktock live room useless parts.
// @author       You
// @match        https://live.douyin.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=douyin.com
// @grant        GM.addStyle
// @run-at       document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    const CSS_HIDE = '{ display: none !important;}'
    const CSS_OPACITY_0 = '{ opacity: 0 !important; height: 0 !important;}'

    let selectorsToHide = [
        // top row
        "main > div:nth-of-type(1)",
        // top second row
        "main >  pace-island",
        // top avatar row
        //"div[data-e2e=living-container] > div:nth-of-type(1) > div:nth-of-type(1)",
        // left first column
        "#root .app-container >  pace-island > div:nth-of-type(1)",

        ".__playerIsFullChatroom",

        ".__isFullPlayer",
        ".__playerIsFull.__roomInfoBarOuter > div:nth-of-type(4)",

        ".metro",
        // right chat column
        // "div[data-e2e=living-container] > div:nth-of-type(2)",
        // bottom gift row
        "div[data-e2e=living-container] > div:nth-of-type(1) > div:nth-of-type(3)",
        // person list in chat column
        "div[data-e2e=living-container] > div:nth-of-type(2) > div:nth-of-type(1)",
        // bottom suggest div
        "div[data-e2e=living-container] + div",
        // msg in chat column
        ".webcast-chatroom__room-message",
        // bottom right feedback btn
        "#douyin-sidebar",
        // danmu
        "xg-danmu"
    ];

    // use opacity 0 instead of display none since some websites may check the ads divs later
    let selectorsToOpacity = [''];

    addStyle(selectorsToHide, CSS_HIDE);

    addStyle(selectorsToOpacity, CSS_OPACITY_0);

    function addStyle(selectors, style = CSS_HIDE) {
        let str = ``
        if(selectors){
            for (let selector of selectors) {
                str += `${selector} ${style} `;
            }
        }

        console.log(`=======================${str}`)
        GM.addStyle(str);
    }

})();