Facebook Marketplace: Hide Unwanted Categories

Removes items from the categories listed. Edit to taste, but back up your list, as future updates will overwrite it

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

// ==UserScript==
// @name         Facebook Marketplace: Hide Unwanted Categories 
// @description  Removes items from the categories listed. Edit to taste, but back up your list, as future updates will overwrite it
// @match        https://www.facebook.com/*
// @version      0.6
// @author       mica
// @namespace    greasyfork.org/users/12559
// @license      MIT
// ==/UserScript==

var list = [
'Auto Parts',
'Baby & Kids Items',
'Books, Movies & Music',
'Cell Phones',
'Mobile phones',
'Home Sales',
'Jewelry & Accessories',
'Kids\' Clothing',
'Property Rentals',
'Women\'s',
'Women\'s clothing & shoes'
];// ^ leave comma off the last one & prefix any ' with \

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.map(item => item.toUpperCase()).includes(element.innerText.toUpperCase())) {
                element.closest('div[class=""]').remove();
            }
            element.classList.add('catChecked')
        });
    }
}

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