Hide Promotion Advertisement at Codewars Site

Remove certain elements from the page

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Hide Promotion Advertisement at Codewars Site
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Remove certain elements from the page
// @author       aspen138
// @match        *://*.codewars.com/kata/*
// @icon         https://www.google.com/s2/favicons?domain=codewars.com
// @license      MIT
// @grant        none
// ==/UserScript==



(function() {
    'use strict';

    // Function to remove elements and adjust styles
    function adjustElements() {
        const descriptionFooter = document.querySelector('.description-footer');
        const partnerDisplay = document.getElementById('partner-display');
        const textCenter = document.querySelector('.text-center');
        const bonusPointsHeader = document.getElementById('bonus-points-not-really-but-just-for-fun');
        const descriptionFullHeight = document.querySelector('.description.h-full');
        const descriptionContent = descriptionFullHeight ? descriptionFullHeight.querySelector('.description-content') : null;

        if (descriptionFooter) {
            descriptionFooter.remove();
        }

        if (partnerDisplay) {
            partnerDisplay.remove();
        }

        if (textCenter) {
            textCenter.remove();
        }

        if (bonusPointsHeader) {
            bonusPointsHeader.remove();
        }

        if (descriptionContent) {
            descriptionContent.style.height = '100%';
            descriptionContent.style.display = 'flex';
            descriptionContent.style.flexDirection = 'column';
        }
    }

    // Initial adjustment
    adjustElements();

    // Listen for URL changes
    window.addEventListener('popstate', adjustElements);
    window.addEventListener('hashchange', adjustElements);

    // Observe DOM changes
    const observer = new MutationObserver(() => {
        adjustElements();
    });

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

    // Reapply adjustments every 5 seconds
    setInterval(adjustElements, 5000);

})();