Greasy Fork is available in English.

抖音净化

净化抖音网页版界面,只留下播放窗口、评论按钮和作者头像,其他元素统统移除,我只想安安静静的用网页刷短视频

// ==UserScript==
// @name         抖音净化
// @namespace    douyin_clear_bbc
// @version      1.0.1
// @license      gpl-3.0
// @description  净化抖音网页版界面,只留下播放窗口、评论按钮和作者头像,其他元素统统移除,我只想安安静静的用网页刷短视频
// @author       DogDogGo
// @match        https://www.douyin.com/*
// ==/UserScript==

(function () {
    'use strict';
    // 普通移除列表
    var need_to_remove = [
        '#island_e62be',
        '#douyin-sidebar',
        '.xgplayer-playswitch', //右侧翻页键
        '#douyin-header',   // 顶栏
        '#douyin-temp-sidebar', // 右下角问号
        'div.comment-input-container', // 评论输入框
        '.comment-item-stats-container', // 评论区点赞分享按钮
        'div[data-e2e="video-player-digg"]', // 视频右下点赞
        'div[data-e2e="video-player-collect"]', // 视频右下 收藏
        'div[data-e2e="video-player-share"]', // 视频右下分享
        'div[data-e2e="video-play-more"]', // 视频右下更多
        '.login-clarity-new',   // 画质切换登录提示
    ]
    var need_to_hide = [
        '.danmakuContainer', // 弹幕发送框
        '.xgplayer-page-full-screen',   // 网页全屏
        'g[opacity="0.18"]',    // 视频右侧半圆展开按钮
        '.xgplayer-watch-later', // 稍后再看
        '.xgplayer-fullscreen', //   全屏
    ]
    var need_to_click = [
        'div.related-video-card-login-guide__footer-close', // 评论区登录提示
        '#login-pannel > div.dy-account-close',  // 全屏登录窗口
    ]
    // 处理方法
    function clean_item(item_css, type = 1) {
        let items = document.querySelectorAll(item_css)
        items.forEach((item) => {
            if (item != null) { if (type == 1) { item.remove() } else if (type == 2) { item.style.display = "none" } else if (type == 3) { item.click() } }
        })
    }

    // 净化函数主体
    function clean_web() {
        // 普通移除
        need_to_remove.forEach((bad_item) => { clean_item(bad_item) })
        // 普通隐藏
        need_to_hide.forEach((bad_item) => { clean_item(bad_item, 2) })
        // 普通点击
        need_to_click.forEach((bad_item) => { clean_item(bad_item, 3) })


        // 其他特殊处理
        document.querySelector("title").innerText = "抖音清爽Pro"

        let go_on_watch = [...document.querySelectorAll('div')].find(el => el.textContent.includes('继续观看'))
        if (go_on_watch != undefined) { go_on_watch.click() }
        let more_icon = [...document.querySelectorAll('div.dy-tip-container')].find(el => el.textContent.includes('相关'))
        if (more_icon != undefined) { more_icon.remove() }
        let i_known = [...document.querySelectorAll('.semi-button-content')].find(el => el.textContent.includes('我知道了'))
        if (i_known != undefined) { i_known.remove() }
        try { document.querySelector("div[data-e2e='feed-comment-icon']").style.marginBottom = "30px" } catch { }
        try { document.querySelector("#slidelist > div.fullscreen_capture_feedback").style.height = "100%" } catch { }
        try { document.querySelector("#slidelist > div.fullscreen_capture_feedback").style.setProperty("padding", "0", "important") } catch { }
        try { document.querySelector("#douyin-right-container").style.setProperty("padding-top", "0", "important") } catch { }
    }

    // 主循环执行净化
    setInterval(() => { clean_web() }, 1000)
})();