Greasy Fork 支持简体中文。

Nascondi annunci di animali da Subito.it

Nasconde tutti gli annunci con animali da Subito.it

// ==UserScript==
// @name         Nascondi annunci di animali da Subito.it
// @namespace    nascondianimalisubito.brunon.com
// @version      0.1.0
// @description  Nasconde tutti gli annunci con animali da Subito.it
// @author       brunon
// @match        https://www.subito.it/*
// @grant        none
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAACdlBMVEUAAADWHh7WHh7WHh7UHh7WHh7WHh7WHh7VHh7WHh7WHh7WHh7WHh7WHh7UHx/WHh7WHh7WHh7VHh7VHh7UHh7UHh7WHh7WHh7WHh7WHh7WHh7WHh7WHh7VHh7WHh7WHh7WHh7VHh7WHh7VHh7VHh7WHh7WHh7VHh7WHh7VHh7VHx/UHx/WHh7WHh7VHh7WHh7VHh707e3WHh707OvVFBTWHx9bUUf17+/VGRnWGxvWFhb07u719fX18fHUERH3///3/f1cUkjUDg72+Pj3/v73+/v99/fqoaFTST/cHBzpo6NZT0XVHR348vL/+Pns5eXWISH2+vr89fX69PTz5OTXHh368vP38PBWTEFRRzzbOztORDmJPjj28/Ppn59vZVzfWVnUCwv////29/fw6Ony3d3EvLnpnZ1XTUNQRTtMQjfXIyP//P3/+vv05+fz4ODnj4+Ui4ThZWVqYFdYUkfcQkLYKirTy8nvx8fuwsLuv7+7s6/rrq7sqamgl5KakYyCeXJ1a2NiWE9RVUrbPT2HPjfx6eno4uHh2tnx19fd1tXMxMKPh4Dkfn59cmvia2vgYmLfXV1lXFPeT0/dSUncRkbaODjZMTGANS7XJSXbGhr8+Pjwy8vstLSupqGro56GfndzamJSVUpLQDXXHR3WGhrPFBTy6+vj3NvXz86qoJvompromZnolZWck47lh4flhoa9cW7fX19eYlneU1PdTExSVktNUUZFSD7eIyPaICHg5eXd2tjLz82/uLT1rq+2r6urop2dop2VmpLYkpGRlo+KjofOhILFfXtiWE6cUk1gVkxKTkJFOzA9MifhJybZHh3KEQ9jlx2JAAAA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DncLwmCs7gGxsdHewiNBwJSN1wijHyQCXjMcQqtcKKBRuIaDuFBuiiqb7UKol6QmzABCdSLfPM2lsT34NG/uy9Pkq6q+UzeomK9qOEFGiTwRtHpaa2pyGcgfmj0Hz405iJsIp/NqrncVEXzIMHTWLq1XpUPw+MT9c9fC1OAgBi1mq3Ycztv+428nVkN8MQgiA+P+puPjsmjh1IIdJphWRLLVzsQHgkb6K80Zl5cXxSk8LBRM//lqylh9IAIGRI+bMTIiWD+XzRk1vSkkfFxYaDY+MiohEFD+vxXKP0A5xiIIMGVSjAAAAAASUVORK5CYII=
// ==/UserScript==

(function() {
    'use strict';

    // Function to hide items containing specified keywords
    function hideItemsWithKeywords() {
        const declinableWords = ["can", "cagnolin", "gatt", "orfan", "cucciol", "gattin", "micin", "mici", "micett", "conigli","conigliett","cricet","cricetin"];
        const maleCountableWords = ["adorabile", "pastore", "adozione", "canile", "angelo","intelligente","simpatico","bassotto","tigrato","animale"]; // Plurale maschile
        const femaleCountableWords = ["cavia","colombacci"]; // Plurale femminile -e
        const keywords = ["setter", "taglia", "pitbull", "husky", "maschi", "femmine", "maschio", "femmina", "segugio", "segugino", "labrador", "conigli", "una famiglia", "una casa", "cerca", "vuole",
                         "bulldog","jack russel","chihuahua","pomerania", "scottish straight","adottare",];

        declinableWords.forEach(word => {
            ['a', 'e', 'i', 'o'].forEach(ending => {
                keywords.push(word + ending);
            });
        });

        keywords.push(...maleCountableWords);
        keywords.push(...femaleCountableWords);

        maleCountableWords.forEach(word => {
            keywords.push(word.substring(0, word.length - 1) + 'i');
        });

        femaleCountableWords.forEach(word => {
            keywords.push(word.substring(0, word.length - 1) + 'e');
        });

        // Create a regex pattern for the keywords allowing for digits and spaces
        const regexPattern = new RegExp(keywords.map(keyword => `\\b${keyword}\\b`).join('|'), 'i');

        const items = document.querySelectorAll('.items__item');

        // Loop through the elements and hide those containing specified keywords
        items.forEach(item => {
            // Function to check if the item or any of its children contain the keywords using regex
            const containsKeywords = (element) => {
                if (element.nodeType === Node.TEXT_NODE) {
                    const text = element.textContent;
                    return regexPattern.test(text);
                }
                for (const child of element.childNodes) {
                    if (containsKeywords(child)) {
                        return true;
                    }
                }
                return false;
            };

            // Check if the item or any of its children contain the keywords
            if (containsKeywords(item)) {
                item.style.display = 'none';
            }
        });

        // Remove items that contain URLs with src https://www.subito.it/animali/
        const itemLinks = document.querySelectorAll('.items__item a');
        itemLinks.forEach(link => {
            const href = link.getAttribute('href');
            if (href && href.startsWith('https://www.subito.it/animali/')) {
                const item = link.closest('.items__item');
                if (item) {
                    item.style.display = 'none';
                }
            }
        });
    }

    // Wait for the DOMContentLoaded event before running the script
    document.addEventListener('DOMContentLoaded', hideItemsWithKeywords);

    // Use a MutationObserver to monitor changes to the DOM and re-run the script
    const observer = new MutationObserver(hideItemsWithKeywords);
    observer.observe(document.body, { subtree: true, childList: true });
})();