Greasy Fork

Greasy Fork is available in English.

小红书隐藏视频内容

Hide sections containing videos

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        小红书隐藏视频内容
// @namespace    http://your.namespace.com
// @version      1.0
// @description  Hide sections containing videos
// @author       Your Name
// @match        https://www.xiaohongshu.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const playIcons = document.querySelectorAll('span.play-icon');

    const observer = new MutationObserver(mutationsList => {
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList') {
                const newDivs = Array.from(document.querySelectorAll('span.play-icon')).map(span => span.closest('div'));
                newDivs.forEach(div => {
                    if (div) {
                        div.style.visibility = 'hidden';
                    }
                });
                layoutGrid();
            }
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });

    playIcons.forEach(span => {
        const parentDiv = span.closest('div');
        if (parentDiv) {
            parentDiv.style.visibility = 'hidden';
        }
    });

    function layoutGrid() {
        const container = document.querySelector('.container'); // 替换成你的容器元素的选择器
        const gridItems = Array.from(container.children);

        gridItems.forEach(item => {
            if (item.style.visibility === 'hidden') {
                container.removeChild(item);
            }
        });

        container.style.gridAutoFlow = 'dense';
    }
})();