onliner catalog fold feature

fold items in onliner.by catalog automatically

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         onliner catalog fold feature
// @namespace    http://tampermonkey.net/
// @version      2025-07-16
// @description  fold items in onliner.by catalog automatically
// @author       vp
// @match        https://catalog.onliner.by/*
// @icon         https://gc.onliner.by/favicon.ico
// @grant        none
// @license      MIT
// ==/UserScript==
(function() {
    'use strict';

    const exclude = function(value) {
        console.log('script is running');

        if (!value) {
            console.log('nothing to exclude, exiting');
            return;
        }

        const exclusionTerms = value.split(',');

        document.querySelectorAll('.catalog-form__offers-unit').forEach(function(el) {
            exclusionTerms.forEach(function(term) {
                if (el.innerText.includes(term)) {
                    el.style.display = 'none';
                }
            });
        });
    }

    const setup = function() {
        const panel = document.createElement('div');
        const label = document.createElement('label');
        const input = document.createElement('input');
        const button = document.createElement('button');

        panel.style.margin = '0 0 25px 5px';
        label.innerText = 'Exclude:';
        input.id = 'exclusion-terms';
        button.innerText = 'OK';
        button.onclick = function() { setInterval(exclude, 1000, input.value) };

        panel.append(label);
        panel.append(input);
        panel.append(button);

        document.querySelector('.catalog-form__offers').prepend(panel);
    }

    setup();
})();