粉笔网解析视频删除

自动隐藏粉笔网(spa.fenbi.com)题目解析页面的“解析视频”模块。

// ==UserScript==
// @name         粉笔网解析视频删除
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  自动隐藏粉笔网(spa.fenbi.com)题目解析页面的“解析视频”模块。
// @author       yingming006
// @match        https://spa.fenbi.com/ti/exam/solution/*
// @icon         https://spa.fenbi.com/favicon.ico
// @grant        none
// @run-at       document-
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const logPrefix = '[粉笔视频删除器]';

    function hideVideoSections() {
        const videoElements = document.querySelectorAll('app-solution-video');

        if (videoElements.length === 0) {
            return;
        }

        videoElements.forEach(videoEl => {
            const sectionContainer = videoEl.closest('section.result-common-section');

            if (sectionContainer && sectionContainer.style.display !== 'none') {
                console.log(logPrefix, '发现并隐藏解析视频模块。');
                sectionContainer.style.display = 'none';
            }
        });
    }

    const observer = new MutationObserver((mutationsList) => {
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                hideVideoSections();
                break;
            }
        }
    });

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

})();