Greasy Fork

Greasy Fork is available in English.

Douyin live stream optimization(优化网页)

抖音网页版优化,自动关闭弹幕,自动屏蔽礼物,删除礼物栏,自动切换原画

当前为 2024-08-04 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Douyin live stream optimization(优化网页)
// @namespace    http://tampermonkey.net/
// @version      0.8
// @description  抖音网页版优化,自动关闭弹幕,自动屏蔽礼物,删除礼物栏,自动切换原画
// @match        https://live.douyin.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 模拟按下 B 键
    function simulateBKeyPress() {
        var event = new KeyboardEvent('keydown', {
            key: 'b',
            code: 'KeyB',
            keyCode: 66, // B 键的键码
            charCode: 0,
            which: 66, // B 键的键码
            shiftKey: false,
            ctrlKey: false,
            metaKey: false,
            bubbles: true // 事件是否应该冒泡
        });
        document.dispatchEvent(event);
        console.log('模拟按下 B 键');
    }

    // 点击按钮
    function clickButton() {
        var button = document.querySelector('.psKR9RS0 .WoNKVQmY.Z20k_Nsy');
        if (button) {
            button.click();
            console.log('按钮已点击');
        } else {
            console.log('按钮未找到');
        }
    }

    // 删除特定的礼物容器
    function removeGiftItems() {
        var giftContainer = document.querySelector('.fIHFYwJt[data-e2e="gifts-container"]');
        if (giftContainer) {
            giftContainer.remove();
            console.log('礼物容器已删除');
        } else {
            console.log('未找到礼物容器');
        }
    }

    function removeNewElement1() {
    var newElement1 = document.querySelector('.LE4P00KT');
    if (newElement1) {
        newElement1.remove();
        console.log('新的指定元素 1 已删除');
    } else {
        console.log('未找到新的指定元素 1');
    }
}

    // 删除特定的 HTML 内容
    function removeSpecialContent() {
        var specialContents = document.querySelectorAll('div._192Y0el > div.ljM5iqdR');
        specialContents.forEach(function(content) {
            content.remove();
        });
        console.log('特殊内容已删除');

        // 删除新的指定元素 1
        var newElement1 = document.querySelector('.LE4P00KT');
        if (newElement1) {
            newElement1.remove();
            console.log('新的指定元素 1 已删除');
        } else {
            console.log('未找到新的指定元素 1');
        }

        // 删除新的指定元素 2
        var newElement2 = document.querySelector('.mDjtvQMS.GiftEffectPlugin');
        if (newElement2) {
            newElement2.remove();
            console.log('新的指定元素 2 已删除');
        } else {
            console.log('未找到新的指定元素 2');
        }
        // 删除新的指定元素 3
        var newElement3 = document.querySelector('.mDjtvQMS.GiftEffectPlugin');
        if (newElement3) {
            newElement3.remove();
            console.log('新的指定元素 3 已删除');
        } else {
            console.log('未找到新的指定元素 3');
        }
    }

    // 判断 URL 是否包含特定字符串
    if (window.location.href.includes("https://live.douyin.com/")) {
        setTimeout(simulateBKeyPress, 5000); // 延迟5秒按下 B 键
        setTimeout(clickButton, 5000); // 延迟5秒点击按钮,确保按键事件触发之后
        setTimeout(removeGiftItems, 5000); // 延迟5秒删除礼物容器,确保前面的操作已完成
        setTimeout(removeSpecialContent, 5000); // 延迟5秒删除特殊内容
        setInterval(removeNewElement1, 1000);
    }
})();