Remove Top Items from Shafa.ua

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();