intrepidOlivia / Pinterest Cleanser

// ==UserScript==
// @name         Pinterest Cleanser
// @namespace    http://pixelstomp.com
// @version      4.0
// @description  Removes sponsored posts from Pinterest. Leaves a chunk of whitespace, but it's worth it. Updated for Pinterest DOM model as of June 2025
// @author       intrepidOlivia
// @match        *://*.pinterest.com/*
// @copyright 2025, intrepidOlivia (https://openuserjs.org//users/intrepidOlivia)
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    setInterval(function() {

    const allPins = document.querySelectorAll('div[data-grid-item="true"]');
    Array.from(allPins).forEach(function(elem) {
const hasAdText = elem.innerText.includes('Sponsored');
        let hasExternalLink = false;
        const anchors = elem.querySelectorAll('a');
        anchors.forEach(function(a) {
const gurl = new URL(a.href);
            if (!gurl.hostname.includes('pinterest')) {
hasExternalLink = true;
            }
        });
      if (hasAdText) {
        elem.innerHTML = '';
      }
    });
    }, 200);
})();