Greasy Fork

来自缓存

Greasy Fork is available in English.

TikTok Toggle Comments

Add an ability to hide comments block on full screen TikTok

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         TikTok Toggle Comments
// @namespace    http://alamote.pp.ua/
// @match        https://www.tiktok.com/*
// @grant        none
// @version      1.0.1
// @namespace    AlaMote
// @description  Add an ability to hide comments block on full screen TikTok
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tiktok.com
// @license      MIT
// ==/UserScript==

/*jshint esversion: 6 */

(function() {
    'use strict';

    const interval = setInterval(() => {
        const soundButton = document.querySelector('#app div[class*="DivVoiceControlContainer"] button[class*="ButtonVoiceControlNew"]');
        if (soundButton) {
            clearInterval(interval);

            const style = document.createElement('style');
            style.innerHTML = `
                .comments-button {
                    border: none;
                    background: none rgba(84, 84, 84, 0.5);
                    outline: none;
                    padding: 0px;
                    display: flex;
                    transition: opacity 0.3s ease 0s;
                    cursor: pointer;
                    line-height: 0;
                    border-radius: 100px;
                    height: 40px;
                    width: 40px;
                    margin-top: 8px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    position: absolute;
                    z-index: 1;
                    bottom: 20px;
                    right: 20px;
                }

                .comments-button:hover {
                    background-color: rgba(37, 37, 37, 0.6);
                    opacity: 0.7;
                }
            `;
            document.querySelector('head').append(style);

            soundButton.parentNode.style.bottom = '68px';

            const commentsButton = document.createElement('button');
            commentsButton.classList.add('comments-button');
            commentsButton.addEventListener('click', e => {
                e.stopPropagation();
                e.preventDefault();
                const commentsContainer = document.querySelector('#app div[class*="DivVideoContainer"] + div[class*="DivContentContainer"]');
                if (commentsContainer) {
                    commentsContainer.style.display = commentsContainer.style.display === 'none' ? 'flex' : 'none';
                }
            });
            commentsButton.innerHTML = `<svg width="24" height="24" viewBox="0 0 20 20" fill="white" xmlns="http://www.w3.org/2000/svg"><use xlink:href="#svg-ellipsis-right-fill"></use></svg>`;
            soundButton.parentNode.parentNode.append(commentsButton);
        }
    }, 300);

})();