Facebook Marketplace: Hide Unwanted Categories

Removes items from the categories listed. Edit the list for what you want hidden (prefixing any ' with \), but back it up, as it will get overwritten at the next update

目前為 2024-01-23 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Facebook Marketplace: Hide Unwanted Categories 
// @description  Removes items from the categories listed. Edit the list for what you want hidden (prefixing any ' with \), but back it up, as it will get overwritten at the next update
// @match        https://www.facebook.com/*
// @version      0.5
// @author       mica
// @namespace    greasyfork.org/users/12559
// @license      MIT
// ==/UserScript==

var list = [
'Auto Parts',
'Baby & Kids Items',
'Books, Movies & Music',
'Mobile phones',
'Home Sales',
'Jewelry & Accessories',
'Kids\' Clothing',
'Property Rentals',
'Women\'s',
'Women\'s clothing & shoes'
];// ^ no comma for the last one!

function filter() {
    if (location.pathname.includes('marketplace') && !location.pathname.match(/category|profile|you|notifications|inbox/g)) {
        document.querySelectorAll('[aria-label="Collection of Marketplace items"] span[dir]:not(.catChecked)').forEach((element) => {
            if (list.includes(element.innerText)) {
                element.closest('div[class=""]').remove();
            }
            element.classList.add('catChecked')
        });
    }
}

var observer = new MutationObserver(filter);
observer.observe(document.documentElement, { subtree: true, childList: true });