Remove Top Items from Shafa.ua

Remove all divs with class "b-tile-item" containing span with the word "Top"

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Remove Top Items from Shafa.ua
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Remove all divs with class "b-tile-item" containing span with the word "Top"
// @author       max5555
// @match        https://shafa.ua/*
// @grant        GM_addStyle
// @license MIT

// ==/UserScript==

(function() {
    'use strict';

    // Add styles for the slider
    GM_addStyle(`
        #toggleSwitch {
            position: fixed;
            top: 10px;
            right: 10px;
            z-index: 9999;
            display: flex;
            align-items: center;
        }

        #toggleCheckbox {
            margin-right: 5px;
        }
    `);

    // Add the slider to the page
    let switchContainer = document.createElement('div');
    switchContainer.id = 'toggleSwitch';

    let toggleCheckbox = document.createElement('input');
    toggleCheckbox.type = 'checkbox';
    toggleCheckbox.id = 'toggleCheckbox';
    toggleCheckbox.checked = true;

    let toggleLabel = document.createElement('label');
    toggleLabel.htmlFor = 'toggleCheckbox';
    toggleLabel.textContent = 'Remove Top Items';

    switchContainer.appendChild(toggleCheckbox);
    switchContainer.appendChild(toggleLabel);

    document.body.appendChild(switchContainer);

    // Function to remove the specified elements
    function removeTopDivs() {
        if (!toggleCheckbox.checked) return;  // Don't execute if the feature is toggled off

        let divs = document.querySelectorAll('div.b-tile-item');
        divs.forEach(div => {
            let spans = div.querySelectorAll('span');
            spans.forEach(span => {
                if (span.textContent.includes('Top')) {
                    div.remove();
                }
            });
        });
    }

    // Call the function on DOMContentLoaded
    document.addEventListener('DOMContentLoaded', removeTopDivs);

    // Check and remove any new divs every 2 seconds
    setInterval(removeTopDivs, 2000);
})();