Hide alcohol items for Tavriav

Hide items with class 'products__item' containing specific words on Tavriav

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Hide alcohol items for Tavriav
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Hide items with class 'products__item' containing specific words on Tavriav
// @author       max5555
// @match        https://www.tavriav.ua/catalog/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const wordsToHide = [
"Пиво", "бокал", "вішалка", "кревет", "спред", "коньяк", "горілка", "корм", "свіча", "підг", "вермут", "лікер", "ром", "кавовий", "джин", "віскі", "вино", "бренді", "сидр", "настоянка"].map(word => word.toLowerCase());

    function hideItemsBasedOnContent() {
        const items = document.querySelectorAll('.products__item');
        for (let item of items) {
            let itemContent = item.textContent.toLowerCase();
            if (wordsToHide.some(word => itemContent.includes(word))) {
                item.style.display = 'none';
            }
        }
    }

    // Hide items after the page has loaded
    window.addEventListener('load', hideItemsBasedOnContent);

    // Also handle any dynamically added items
    const observer = new MutationObserver(hideItemsBasedOnContent);
    observer.observe(document.body, { childList: true, subtree: true });

})();