// ==UserScript==
// @name Facebook Marketplace: Dim Distant Locations
// @description Ads from locations listed below are dimmed for easy avoidance. Victoria, BC is the target audience for this list (we're on an island, constantly being shown ads across an ocean). Edit in your own too-far-away places, but back up your list, as it will get overwritten when I update the scrip!
// @match https://www.facebook.com/*
// @version 0.1
// @author mica
// @namespace greasyfork.org/users/12559
// @license MIT
// ==/UserScript==
var filterList = [
'100 Mile House, BC',
'Abbotsford, BC',
'Alberni-Clayoquot, BC',
'Armstrong, BC',
'Belcarra, BC',
'Burnaby, BC',
'Campbell River, BC',
'Cariboo, BC',
'Castlegar, BC',
'Central Okanagan, BC',
'Chase, BC',
'Chilliwack, BC',
'Coldstream, BC',
'Columbia-Shuswap, BC',
'Comox, BC',
'Coquitlam, BC',
'Courtenay, BC',
'Cumberland, BC',
'Delta, BC',
'Enderby, BC',
'Fraser Valley, BC',
'Fruitvale, BC',
'Hope, BC',
'Invermere, BC',
'Kamloops, BC',
'Kelowna, BC',
'Kent, BC',
'Keremeos, BC',
'Ladysmith, BC',
'Lake Country, BC',
'Langley, BC',
'Langley Twp, BC',
'Lantzville, BC',
'Lillooet, BC',
'Lumby, BC',
'Maple Ridge, BC',
'Mission, BC',
'Nanaimo District, BC',
'Nanaimo, BC',
'Nelson, BC',
'New Westminster, BC',
'North Okanagan, BC',
'North Vancouver District, BC',
'North Vancouver, BC',
'Okanagan-Similkameen, BC',
'Oliver, BC',
'Osoyoos, BC',
'Parksville, BC',
'Penticton, BC',
'Penticton, BC',
'Pitt Meadows, BC',
'Port Alberni, BC',
'Port Coquitlam, BC',
'Port Moody, BC',
'Powell River, BC',
'Princeton, BC',
'Qualicum Beach, BC',
'Quesnel, BC',
'Richmond, BC',
'Salmon Arm, BC',
'Sechelt, BC',
'Sicamous, BC',
'Spallumcheen, BC',
'Squamish, BC',
'Strathcona, BC',
'Summerland, BC',
'Sunshine Coast, BC',
'Surrey, BC',
'Thompson-Nicola, BC',
'Tofino, BC',
'Ucluelet, BC',
'Vancouver, BC',
'Vernon, BC',
'West Kelowna, BC',
'West Vancouver, BC',
'Whistler, BC',
'White Rock, BC',
'Williams Lake, BC'
];
function filter() {
if (location.pathname.includes('marketplace') && !location.pathname.match(/propertyrentals|profile|you|notifications|inbox/g)) {
var elements = document.querySelector('[aria-label="Collection of Marketplace items"]').querySelectorAll('span[dir]:not(.checked)');
elements.forEach((element) => {
if (filterList.includes(element.innerText)) {
element.closest('div:not([class])').style.opacity = '0.1';
}
element.classList.add('checked');
});
}
}
var observer = new MutationObserver(filter);
observer.observe(document.documentElement, { subtree: true, childList: true });
filter();