// ==UserScript==
// @name         Hide Instacart Ads
// @namespace    http://tampermonkey.net/
// @version      2025-02-05
// @description  Stop polluting my listings with ads
// @author       Marc Love
// @match        https://*.instacart.com/*
// @icon         https://d2guulkeunn7d8.cloudfront.net/assets/instacart_favicon_48x48-25ac28f848f7cf81a9c8a9aad693a898.png
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function hideAdListItems() {
        document.querySelectorAll('li').forEach(li => {
            if (li.querySelector('img[alt="This is an ad..."]')) {
                li.style.display = 'none';
            }
        });
    }

    // Run function on initial load
    hideAdListItems();

    // Observe for dynamically added elements
    const observer = new MutationObserver(hideAdListItems);
    observer.observe(document.body, { childList: true, subtree: true });

})();