Spotless for eBay

Hides sponsored listings, removes sponsored items, cleans links, & prevents tracking

Você precisará instalar uma extensão como Tampermonkey, Greasemonkey ou Violentmonkey para instalar este script.

Você precisará instalar uma extensão como Tampermonkey para instalar este script.

Você precisará instalar uma extensão como Tampermonkey ou Violentmonkey para instalar este script.

Você precisará instalar uma extensão como Tampermonkey ou Userscripts para instalar este script.

Você precisará instalar uma extensão como o Tampermonkey para instalar este script.

Você precisará instalar um gerenciador de scripts de usuário para instalar este script.

(Eu já tenho um gerenciador de scripts de usuário, me deixe instalá-lo!)

Você precisará instalar uma extensão como o Stylus para instalar este estilo.

Você precisará instalar uma extensão como o Stylus para instalar este estilo.

Você precisará instalar uma extensão como o Stylus para instalar este estilo.

Você precisará instalar um gerenciador de estilos de usuário para instalar este estilo.

Você precisará instalar um gerenciador de estilos de usuário para instalar este estilo.

Você precisará instalar um gerenciador de estilos de usuário para instalar este estilo.

(Eu já possuo um gerenciador de estilos de usuário, me deixar fazer a instalação!)

// ==UserScript==
// @name         Spotless for eBay
// @namespace    https://github.com/OsborneLabs
// @version      3.0.0
// @description  Hides sponsored listings, removes sponsored items, cleans links, & prevents tracking
// @author       Osborne Labs
// @license      GPL-3.0-only
// @homepageURL  https://github.com/OsborneLabs/Spotless
// @icon         data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI1MDAiIHdpZHRoPSIyMDcyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAuMzU5IDIxLjY4ODgwMTQ3Nzg4Njg0IDI1MS4yODE5OTk5OTk5OTk5OCAyODIuMzExMTk4NTIyMTEzMTYiPjxwYXRoIGQ9Ik0xNTIuMzM4IDE1Ny4xM2E3MC4zMjcgNzAuMzI3IDAgMSAwLTUzLjggMS42NjJsNi43ODgtMTcuOTM3YTUxLjE0OSA1MS4xNDkgMCAxIDEgMzkuMTI4LTEuMjA5eiIgZmlsbD0iIzQxNDE0MSIvPjxwYXRoIGQ9Ik0uMzU5IDk4LjQwNWg1Ny4xMVYzMDRoLTM5LjExYy05Ljk0MSAwLTE4LTguMDU5LTE4LTE4eiIgZmlsbD0iI2VhMzIzYyIvPjxwYXRoIGQ9Ik0yNTEuNjQxIDk4LjQwNWgtNTcuMTA5VjMwNGgzOS4xMDljOS45NDEgMCAxOC04LjA1OSAxOC0xOHoiIGZpbGw9IiM4OGI2MjEiLz48cGF0aCBkPSJNMTk0LjUzMSA5OC40MDVIMTI2VjMwNGg2OC41MzF6IiBmaWxsPSIjZjVhZTAzIi8+PHBhdGggZD0iTTEyNiA5OC40MDVINTcuNDY4VjMwNEgxMjZ6IiBmaWxsPSIjMDA2NGQxIi8+PC9zdmc+
// @match        https://*.ebay.com/*
// @match        https://*.ebay.at/*
// @match        https://*.ebay.be/*
// @match        https://*.ebay.ca/*
// @match        https://*.ebay.ch/*
// @match        https://*.ebay.com.au/*
// @match        https://*.ebay.com.hk/*
// @match        https://*.ebay.com.my/*
// @match        https://*.ebay.com.sg/*
// @match        https://*.ebay.co.uk/*
// @match        https://*.ebay.de/*
// @match        https://*.ebay.es/*
// @match        https://*.ebay.fr/*
// @match        https://*.ebay.ie/*
// @match        https://*.ebay.it/*
// @match        https://*.ebay.nl/*
// @match        https://*.ebay.pl/*
// @run-at       document-start
// @supportURL   https://github.com/OsborneLabs/Spotless/issues
// @grant        none
// ==/UserScript==

/* jshint esversion: 11 */

(function() {
    "use strict";

    const SCRIPT_NAME = "Spotless";
    const SCRIPT_NAME_DEBUG = "SPOTLESS FOR EBAY";
    const SCRIPT_VERSION = typeof GM_info !== 'undefined' ? GM_info.script.version : 'unknown';
    const STORAGE_KEY_HIDE_SPONSORED = "hideSponsoredContent";
    const STORAGE_KEY_PANEL_MINIMIZED = "panelMinimized";
    const DETECT_SPONSORED_KEYWORDS = ['sponsored', 'anzeige', 'gesponsord', 'patrocinado', 'sponsorisé', 'sponsorizzato', 'sponsorowane', '助贊'];
    const UI_ICON_SET = {
        alert: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10.9084921,2.78216375 C11.9482635,2.20625071 13.2462954,2.54089334 13.8841246,3.52240345 L13.9669228,3.66023048 L21.725879,17.6684928 C21.9106772,18.0021332 22.0076302,18.3772743 22.0076302,18.7586748 C22.0076302,19.9495388 21.0824686,20.9243197 19.911679,21.003484 L19.7576302,21.0086748 L4.24187791,21.0086748 C3.86056733,21.0086748 3.48551176,20.9117674 3.15192815,20.7270522 C2.11208877,20.1512618 1.7070482,18.8734454 2.20060302,17.8120352 L2.27350053,17.668725 L10.0302967,3.66046274 C10.2348245,3.291099 10.5391525,2.98673515 10.9084921,2.78216375 Z M12.0004478,16.0017852 C11.4489016,16.0017852 11.0017852,16.4489016 11.0017852,17.0004478 C11.0017852,17.5519939 11.4489016,17.9991104 12.0004478,17.9991104 C12.5519939,17.9991104 12.9991104,17.5519939 12.9991104,17.0004478 C12.9991104,16.4489016 12.5519939,16.0017852 12.0004478,16.0017852 Z M11.9982876,7.99806092 C11.4854518,7.99824566 11.0629195,8.38443798 11.0053334,8.88179743 L10.9986476,8.99842097 L11.0004479,13.9993002 L11.0072176,14.1159189 C11.0651617,14.6132367 11.487972,14.9991248 12.0008078,14.9989403 C12.5136436,14.9987555 12.9361759,14.6125632 12.993762,14.1152038 L13.0004478,13.9985802 L12.9986476,8.99770102 L12.9918779,8.88108232 C12.9339337,8.38376446 12.5111234,7.99787644 11.9982876,7.99806092 Z" fill-rule="nonzero"/></svg>`,
        arrow: `<svg id="arrowIcon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6.1018 8C5.02785 8 4.45387 9.2649 5.16108 10.0731L10.6829 16.3838C11.3801 17.1806 12.6197 17.1806 13.3169 16.3838L18.8388 10.0731C19.5459 9.2649 18.972 8 17.898 8H6.1018Z"/></svg>`,
        heart: `<svg class="heart-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12.8198687,5.57958759 L11.9991485,6.40209417 L11.1758977,5.57884333 C9.07682963,3.47977526 5.67356786,3.47977526 3.5744998,5.57884333 C1.47543173,7.6779114 1.47543173,11.0811732 3.5744998,13.1802412 L11.4698687,21.0756101 C11.7627619,21.3685033 12.2376356,21.3685033 12.5305288,21.0756101 L20.4319958,13.1787767 C22.5263889,11.0727481 22.5299763,7.6790351 20.4305288,5.57958759 C18.3276384,3.4766972 14.9227559,3.47670037 12.8198687,5.57958759 Z"/></svg>`,
        locked: `<svg class="lock-icon lock-icon-animation" id="lockedIcon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g transform="scale(0.045) translate(20 20)"><path d="M418.4,232.7h-23.3v-93.1C395.1,62.5,332.6,0,255.5,0S115.9,62.5,115.9,139.6v93.1H92.6c-12.8,0-23.3,10.4-23.3,23.3v232.7c0,12.9,10.4,23.3,23.3,23.3h325.8c12.8,0,23.3-10.4,23.3-23.3V256C441.7,243.1,431.2,232.7,418.4,232.7z M348.6,232.7H162.4v-93.1c0-51.4,41.7-93.1,93.1-93.1s93.1,41.7,93.1,93.1V232.7z"/></g></svg>`,
        megaphone: `<svg class="megaphone-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28"><path d="M26.0008 7.35334C26.0008 5.54646 24.2879 4.23059 22.5421 4.69622L4.04548 9.62939C2.84171 9.95045 2.00415 11.0407 2.00415 12.2865V15.7136C2.00415 16.9594 2.84171 18.0496 4.04548 18.3707L7 19.1587V19.5C7 21.9853 9.01472 24 11.5 24C13.2899 24 14.8357 22.955 15.5606 21.4419L22.5421 23.3039C24.2879 23.7695 26.0008 22.4536 26.0008 20.6468V7.35334ZM8.50057 19.5589L14.0722 21.0449C13.5474 21.9168 12.5918 22.5 11.5 22.5C9.86282 22.5 8.53195 21.1886 8.50057 19.5589Z"/></svg>`,
        unlocked: `<svg class="lock-icon lock-icon-animation" id="unlockedIcon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g transform="scale(0.045) translate(20 20)"><path d="M418.9,232.7h-256v-93.1c0-51.4,41.7-93.1,93.1-93.1s93.1,41.7,93.1,93.1v23.3h46.5v-23.3C395.6,62.5,333.1,0,256,0c-77.1,0-139.6,62.5-139.6,139.6v93.1H93.1c-12.8,0-23.3,10.4-23.3,23.3v232.7c0,12.9,10.4,23.3,23.3,23.3h325.8c12.8,0,23.3-10.4,23.3-23.3V256C442.2,243.1,431.8,232.7,418.9,232.7z"/></g></svg>`,
        update: `<svg class="update-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g transform="rotate(90 12 12)"><path d="M7.94822962,5.02850432 C8.2831456,5.46765091 8.19865,6.09515261 7.75950341,6.4300686 C6.03254452,7.74713709 5,9.78703304 5,12 C5,15.4973075 7.56475199,18.395585 10.9159977,18.9165744 L10.2071068,18.2071068 C9.81658249,17.1834175 9.81658249,17.1834175 10.2071068,16.7928932 C10.5976311,16.4023689 11.2307961,16.4023689 11.6213203,16.7928932 L14.1213203,19.2928932 C14.5118446,19.6834175 14.5118446,20.3165825 14.1213203,20.7071068 L11.6213203,23.2071068 C11.2307961,23.5976311 10.5976311,23.5976311 10.2071068,23.2071068 C9.81658249,22.8165825 9.81658249,22.1834175 10.2071068,21.7928932 L11.0502786,20.9504867 C6.52614758,20.4760098 3,16.6497928 3,12 C3,9.15643984 4.32881972,6.5312223 6.54666534,4.83977811 C6.98581193,4.50486213 7.61331363,4.58935773 7.94822962,5.02850432 Z M9.87867966,3.29289322 L12.3786797,0.792893219 C12.7692039,0.402368927 13.4023689,0.402368927 13.7928932,0.792893219 C14.1533772,1.15337718 14.1811067,1.72060824 13.8760818,2.11289944 L13.7928932,2.20710678 L12.9497214,3.0495133 C17.4738524,3.52399021 21,7.35020716 21,12 C21,14.7198329 19.7848559,17.243156 17.7284056,18.9418543 C17.3026041,19.2935809 16.6722931,19.2335313 16.3205666,18.8077299 C15.96884,18.3819284 16.0288896,17.7516174 16.454691,17.3998909 C18.0559569,16.0771906 19,14.1168256 19,12 C19,8.50269253 16.435248,5.60441498 13.0840023,5.08342564 L13.7928932,5.79289322 C14.1834175,6.18341751 14.1834175,6.81658249 13.7928932,7.20710678 C13.4324093,7.56759074 12.8651782,7.59532028 12.472887,7.29029539 L12.3786797,7.20710678 L9.87867966,4.70710678 C9.51819569,4.34662282 9.49046616,3.77939176 9.79549105,3.38710056 L9.87867966,3.29289322 L12.3786797,0.792893219 L9.87867966,3.29289322 Z"/></g></svg>`,
        woman: `<svg class="error-icon" viewBox="-63.58 0 322.04 322.04" xmlns="http://www.w3.org/2000/svg"><defs><style>.a{fill:#FFFFFF;}.b{fill:#AD7B59;}.c{fill:#211715;}.d{fill:#F4B3B3;}</style></defs><path class="a" d="M45.6,316.683a7.981,7.981,0,0,0,1.078.728,5.368,5.368,0,0,0,5.787-.1,24.26,24.26,0,0,0,2.324-2.864c2.786-3.109,7.837-2.433,12.1-2.491a27.34,27.34,0,0,0,15.046-4.767l7.285.55a291.062,291.062,0,0,1,1.284-29.26c-6.224-.673-15.978-1.877-21.686-3.082-1.578,2.607-3.089,5-4.479,7.065-3.849,5.721-13.28,13.541-19.589,16.326a15.449,15.449,0,0,1-7.276,1.227,9.6,9.6,0,0,0,.588,4.221,47.911,47.911,0,0,0,4.512,8.847A14.54,14.54,0,0,0,45.6,316.683Z"/><path class="b" d="M147.616,165.172c14.368,4.129,25.76-9.387,25.036-19.209a48.13,48.13,0,0,0-4.1-16.253c-2.966-7.073-8.756-21.457-10.8-47.692.182-7.992-1.282-19.425-1.881-23.818-2.078-15.225-10.02-31.864-20.474-40.721-4.519-3.83-5.879-5.666-10.673-7.88l-5.373-2.483-2.626-.872A71.585,71.585,0,0,0,87.8,2.618C68.123,3.889,51.262,15.16,43.969,23.1c-12.1,13.178-18.82,36.257-15.779,67.285,1.366,21.075.621,36.389-1.24,45.183a101.305,101.305,0,0,0-1.7,21.967c.547,9.834,11.89,19.924,27.374,15.579,0,0,30.387,7.744,51.121,5.309C125.816,175.835,147.616,165.172,147.616,165.172Z"/><path class="a" d="M142.065,78.474l-3.716-4.192c-7.227-1.7-15.9-13.377-18.967-18.326-2.154-3.478-4.751-11.177-6.751-16.553C104.976,50.812,94.862,59.2,81.924,63.82c-3.073,1.135-.762-9-.509-13.729-7.8,8.72-22.676,23.41-30.679,30.869l-5.838,5.7a7.2,7.2,0,0,0-7.043-2.35,7.026,7.026,0,0,0-4.823,3.676,9.922,9.922,0,0,0-.78,4.053A29.765,29.765,0,0,0,36.3,107.588a18.924,18.924,0,0,0,5.294,6.09c1.842,1.283,4.462,2.713,7.614,1.416a54.272,54.272,0,0,0,6.6,13.389c2.354,2.461,4.51,4.727,4.51,4.727a49.018,49.018,0,0,0,15.958,11.562,61.043,61.043,0,0,1-.828,7.289c-.6,3.429-.413,6.493-5.179,8.215-.347.125-20.438,6.425-19.591,6.353,0,8.539,18.476,20.983,43.143,20.983,28.222,0,46.754-12.888,46.754-20.575l-.405-.167c-.482-.2-14-6.63-14.316-6.744-4.767-1.721-4.579-4.786-5.179-8.214a69.061,69.061,0,0,1-1.016-9.271c11.913-6.384,20.678-23.933,22.1-28.735.183-.7.535-1.947.859-3.443,2.142-.524,5.27-.627,6.908-2.116a18.914,18.914,0,0,0,4.467-6.72A29.762,29.762,0,0,0,156,85.691a9.91,9.91,0,0,0-1.3-3.919,7.022,7.022,0,0,0-5.255-3.025,7.414,7.414,0,0,0-5.513,1.84Z"/><path class="c" d="M145.321,82.565c2.007-1.945,5.611-1.984,7.313.418.962,1.358,1.1,3.336,1.218,4.943a27.756,27.756,0,0,1-.157,5.841A25.58,25.58,0,0,1,150.062,104a7.574,7.574,0,0,1-2.894,3.019,25.634,25.634,0,0,1-4.9,1.068c-3.021.634-1.743,5.262,1.276,4.628a42.59,42.59,0,0,0,4.567-.952,9.336,9.336,0,0,0,4.258-2.9,26,26,0,0,0,5.138-10.029,31.6,31.6,0,0,0,1.066-11.8c-.4-3.85-1.5-7.7-5.213-9.582a9.932,9.932,0,0,0-11.433,1.723c-2.222,2.154,1.174,5.546,3.394,3.394Z"/><path class="c" d="M140.923,103.992a28.359,28.359,0,0,1-1.755,10.109c-.151.421-.319.836-.485,1.252-.216.543.138-.291-.117.274-.124.274-.244.551-.369.824-.552,1.207-1.147,2.394-1.771,3.565a60.729,60.729,0,0,1-12.171,16.357A24.493,24.493,0,0,1,115,141.991c-2.952.884-1.695,5.518,1.276,4.628,7.45-2.231,13.218-8.031,17.818-14.055a68.576,68.576,0,0,0,9.441-16.481,31.76,31.76,0,0,0,2.192-12.091c-.094-3.081-4.894-3.095-4.8,0Z"/><path class="c" d="M45.118,83.6a9.815,9.815,0,0,0-10.738-.442c-3.449,2.109-4.537,5.688-4.534,9.546.007,7.481,2.74,15.762,8.161,21.091,3,2.945,7.049,5.025,11.3,3.819,2.967-.842,1.706-5.475-1.276-4.629-3.065.87-5.888-1.589-7.734-3.779a25.078,25.078,0,0,1-4.782-9.775,26.173,26.173,0,0,1-.836-5.414,10.63,10.63,0,0,1,.508-4.969c1.4-2.916,5.17-3.041,7.509-1.3a2.416,2.416,0,0,0,3.284-.861,2.457,2.457,0,0,0-.861-3.283Z"/><path class="c" d="M45.364,110.546a59.8,59.8,0,0,0,8.738,19.68,2.465,2.465,0,0,0,3.284.861,2.422,2.422,0,0,0,.861-3.284,55.986,55.986,0,0,1-8.255-18.533c-.763-2.991-5.394-1.723-4.628,1.276Z"/><path class="c" d="M110.523,40.608c2.187,5.929,4,12.335,7.49,17.66a64.745,64.745,0,0,0,11.275,13.376,21.113,21.113,0,0,0,8.423,4.952c3,.752,4.275-3.876,1.276-4.628-4.747-1.191-8.882-5.9-12.033-9.663a47.228,47.228,0,0,1-7.775-12.243c-1.454-3.533-2.7-7.147-4.027-10.73a2.464,2.464,0,0,0-2.952-1.676,2.42,2.42,0,0,0-1.677,2.952Z"/><path class="c" d="M110.531,38.231A61.968,61.968,0,0,1,94.549,54.692,58.072,58.072,0,0,1,84.29,60.345c-.866.367-1.746.709-2.632,1.027-.658.236-.485.083.074.168a1.6,1.6,0,0,1,.578.2c.046.027.683.687.477.431.227.282.134.355.021-.072-.139-.523-.014.247-.033-.21-.027-.64-.035-1.273,0-1.914.16-3.312.848-6.574,1.044-9.882a2.424,2.424,0,0,0-4.1-1.7C70.052,59.179,59.626,69.387,49.039,79.263c-2.263,2.112,1.137,5.5,3.395,3.394C63.02,72.781,73.446,62.573,83.112,51.788l-4.1-1.7c-.2,3.308-.884,6.57-1.044,9.882-.133,2.728.531,7.159,4.385,6.221a34.64,34.64,0,0,0,6.2-2.53,58.7,58.7,0,0,0,5.722-3.076,62.8,62.8,0,0,0,10.639-8.207,71.8,71.8,0,0,0,9.763-11.727c1.734-2.566-2.423-4.971-4.145-2.423Z"/><path class="c" d="M117.363,3.93A75.888,75.888,0,0,0,84.81.489,72.431,72.431,0,0,0,54.532,11.464a56.962,56.962,0,0,0-17.545,16.78,71.333,71.333,0,0,0-9.612,24.275c-2.622,12.426-2.8,25.266-1.585,37.87a2.467,2.467,0,0,0,2.4,2.4,2.417,2.417,0,0,0,2.4-2.4c-1.839-19.039-.86-40,8.873-56.994A48.916,48.916,0,0,1,53.983,17.6,69.862,69.862,0,0,1,81.258,5.842a70.309,70.309,0,0,1,34.829,2.716c2.94.971,4.2-3.663,1.276-4.628Z"/><path class="c" d="M160.152,82.018a130.226,130.226,0,0,0-1.022-16.895,112.859,112.859,0,0,0-2.342-14.79c-2.857-11.509-8.326-22.995-16.586-31.617-2.134-2.228-4.543-4.192-6.86-6.224a31.364,31.364,0,0,0-7.406-4.965,2.468,2.468,0,0,0-3.284.861,2.419,2.419,0,0,0,.861,3.283,26.012,26.012,0,0,1,6.057,3.885c2,1.732,4.055,3.442,5.964,5.276A54,54,0,0,1,145.2,33.793a73.36,73.36,0,0,1,6.5,16.049,70.019,70.019,0,0,1,1.8,8.609c.027.193.053.387.08.58.093.68-.069-.526.029.215q.081.618.161,1.237.211,1.644.4,3.289a135.163,135.163,0,0,1,1.176,18.246c-.061,3.09,4.739,3.09,4.8,0Z"/><path class="c" d="M25.79,90.389c.554,8.63.855,17.286.627,25.933a113.094,113.094,0,0,1-1.5,17.21,114.085,114.085,0,0,0-2.144,21.114,22.3,22.3,0,0,0,1.6,9.1,20.044,20.044,0,0,0,5.291,7.1c6.556,5.634,15.411,6.816,23.6,4.582,2.977-.812,1.713-5.444-1.276-4.629-6.226,1.7-13.083,1.173-18.336-2.859a16.077,16.077,0,0,1-4.961-6.234,15.1,15.1,0,0,1-.964-3.347c-.01-.067-.033-.237-.057-.558-.027-.341-.04-.683-.053-1.025-.032-.827-.044-1.654-.043-2.481a109.673,109.673,0,0,1,1.993-19.6,116.177,116.177,0,0,0,1.612-16.932c.308-9.125,0-18.267-.584-27.375a2.457,2.457,0,0,0-2.4-2.4,2.421,2.421,0,0,0-2.4,2.4Z"/><path class="c" d="M155.352,82.018c1.113,14.063,3.417,28.167,8.2,41.481,1.806,5.028,4.2,9.855,5.514,15.05a41.567,41.567,0,0,1,1.089,6.276,16.547,16.547,0,0,1-.027,3.954,17.816,17.816,0,0,1-3.431,7.546,17.314,17.314,0,0,1-18.444,6.532c-2.981-.827-4.254,3.8-1.277,4.629a21.749,21.749,0,0,0,20.628-5.094c4.7-4.282,7.947-10.662,7.392-17.116a50.359,50.359,0,0,0-3.03-13.449c-.84-2.239-1.815-4.427-2.683-6.657a124.054,124.054,0,0,1-4.771-15.128,172.942,172.942,0,0,1-4.361-28.024,2.46,2.46,0,0,0-2.4-2.4,2.419,2.419,0,0,0-2.4,2.4Z"/><path class="c" d="M58.616,134.907c7.371,7.694,16.722,13.852,27.566,14.754a2.42,2.42,0,0,0,2.4-2.4,2.449,2.449,0,0,0-2.4-2.4c-9.519-.792-17.75-6.645-24.171-13.348-2.142-2.235-5.533,1.162-3.4,3.394Z"/><path class="d" d="M188.043,302.019c5.713-21.03,5.039-59.62,2.379-87.11a66.674,66.674,0,0,0-1.5-10.556c-1.615-5.763-4.339-11.805-8.3-15.111-2.016-2.168-8.977-6.725-11.557-8.125-9.6-5.217-18.318-9.839-27.99-14.356a.37.37,0,0,0-.1.042c-10.234,5.973-30.168,11.3-45.3,11.243C78.748,178,60.749,172.31,49.664,166.068c-13.328,4.948-28.737,11.085-37.53,17.526-4.525,3.888-7.948,9.8-9.145,18.477-2.21,24.208,1.9,49.313,10.07,72.468,2.5,7.078,5.574,14.221,11.022,19.383s13.805,7.9,20.671,4.868c6.309-2.785,15.74-10.605,19.589-16.326,1.391-2.067,2.9-4.458,4.479-7.065,5.948,1.256,15.292,2.51,21.469,3.167l.194.065c-1.4,13.023-1.867,39.138-.233,39.5,18.212.8,49.856,3.276,77.4-.642,12.809-1.822,18.666-9.673,19.917-13.814Q187.814,302.868,188.043,302.019Z"/><path class="c" d="M155.144,209.439c-.707,7.418-.811,14.927-1.121,22.37-.273,6.56-.557,13.121-.793,19.683-.257,7.146-.212,14.3-.212,21.451,0,3.089,4.8,3.094,4.8,0,0-9.246.1-18.47.465-27.708.334-8.5.67-17,1.071-25.5.161-3.428.264-6.876.59-10.294a2.417,2.417,0,0,0-2.4-2.4,2.451,2.451,0,0,0-2.4,2.4Z"/><path class="c" d="M91.727,274.281q25.167.476,50.336.849,7.862.108,15.724.2c3.089.035,3.091-4.765,0-4.8q-25.737-.294-51.47-.773-7.294-.133-14.59-.272c-3.09-.059-3.09,4.741,0,4.8Z"/><path class="c" d="M188.022,214.909a392.348,392.348,0,0,1,1.584,57.592,154.621,154.621,0,0,1-2.984,25.219c-.373,1.7-.789,3.395-1.291,5.063-.068.227-.143.451-.215.676-.04.125-.094.246-.14.369-.123.329.263-.545.012-.035-.265.537-.532,1.065-.846,1.576a13.946,13.946,0,0,1-2.418,3.029,19.883,19.883,0,0,1-3.847,3.042,30.948,30.948,0,0,1-12.6,3.971c-5.421.695-10.871,1.144-16.328,1.428-10.672.555-21.37.479-32.047.122-4.74-.158-9.478-.375-14.215-.612q-3.164-.157-6.326-.322-1.425-.073-2.85-.143a11.075,11.075,0,0,0-2.829-.133l-.144-.006a2.221,2.221,0,0,1,1.314.636c-.146-.145-.041-.13.306.405-.073-.112-.273-.312.012.075.259.353.056.183.019-.011-.024-.13-.065-.258-.093-.387-.055-.253-.163-1.3-.079-.38-.038-.416-.094-.83-.129-1.246-.2-2.346-.242-4.708-.264-7.061-.058-6.3.132-12.6.478-18.893.161-2.942.36-5.883.643-8.816.113-1.165.24-2.328.392-3.488-.094.717.034-.224.055-.364q.045-.309.1-.617c.074-.453.154-.9.25-1.353.065-.307.135-.614.221-.917.118-.411.351-.915.043-.236a2.475,2.475,0,0,0-.861-3.284,2.421,2.421,0,0,0-3.284.861,18.066,18.066,0,0,0-1.211,5.1c-.381,2.78-.638,5.575-.843,8.374-.484,6.6-.731,13.233-.78,19.855-.021,2.764-.009,5.531.11,8.293a27.807,27.807,0,0,0,.58,5.652,3.462,3.462,0,0,0,1.455,2.228,5.052,5.052,0,0,0,2.44.414q1.518.069,3.035.146c4.468.222,8.935.463,13.4.668,10.654.489,21.323.79,31.988.568,5.71-.119,11.419-.386,17.111-.872,5.442-.465,11.174-.8,16.417-2.411,6.832-2.1,13.624-6.762,16.275-13.654a54.75,54.75,0,0,0,2.415-10.1c.776-4.406,1.316-8.855,1.719-13.309,1.8-19.868,1.233-40.026-.347-59.889q-.271-3.412-.6-6.821a2.466,2.466,0,0,0-2.4-2.4,2.417,2.417,0,0,0-2.4,2.4Z"/><path class="c" d="M90.289,276.166a209.377,209.377,0,0,1-20.918-3.1,2.458,2.458,0,0,0-2.953,1.676,2.424,2.424,0,0,0,1.677,2.952,222.4,222.4,0,0,0,22.194,3.273,2.415,2.415,0,0,0,2.4-2.4,2.454,2.454,0,0,0-2.4-2.4Z"/><path class="c" d="M35.065,300.205c-.158,4.459,2.256,8.817,4.479,12.547s5.031,7.511,9.728,7.839a6.767,6.767,0,0,0,5.542-2.233c1.085-1.25,1.738-2.765,3.368-3.4,3.353-1.312,7.373-.385,10.88-.715a30.045,30.045,0,0,0,14.086-4.978c2.542-1.725.143-5.885-2.422-4.145a25.808,25.808,0,0,1-10.577,4.191c-3.388.527-6.825-.019-10.221.392A12.169,12.169,0,0,0,55,311.2c-1.623.984-2.433,2.408-3.614,3.815-2.149,2.56-5.369-1.068-6.522-2.808a47.762,47.762,0,0,1-3.4-6.071,12.605,12.605,0,0,1-1.6-5.933c.109-3.089-4.691-3.085-4.8,0Z"/><path class="c" d="M49.529,169.192a103.809,103.809,0,0,0,37.7,10.878c12.618,1.188,25.424-.77,37.516-4.4a96.216,96.216,0,0,0,9.144-3.219c1.378-.57,2.747-1.162,4.091-1.81q.912-.44,1.808-.912.394-.21.785-.426c.17-.094.338-.19.506-.286q-1.433.025-.4.206c3,.757,4.273-3.871,1.276-4.629a4.91,4.91,0,0,0-4.063.706c-1.1.6-2.225,1.158-3.364,1.681a77,77,0,0,1-7.38,2.887,116.1,116.1,0,0,1-17.844,4.488,89.036,89.036,0,0,1-38.112-2.036,95.15,95.15,0,0,1-19.241-7.274c-2.74-1.418-5.17,2.723-2.423,4.144Z"/><path class="c" d="M117.277,143.209a87.834,87.834,0,0,0,1.517,12.079,9.149,9.149,0,0,0,6.051,7.014c.942.375-.6-.3.067.02.251.121.506.235.759.354q1.2.56,2.389,1.125,3.234,1.529,6.467,3.06c1.471.7,2.93,1.443,4.427,2.082a2.482,2.482,0,0,0,3.284-.861,2.417,2.417,0,0,0-.861-3.284c-3.176-1.354-6.265-2.952-9.385-4.428-1.515-.716-3.023-1.448-4.548-2.142a17.175,17.175,0,0,1-2.294-1.086,3.192,3.192,0,0,1-1.47-2.038,37.966,37.966,0,0,1-.813-4.514,65.976,65.976,0,0,1-.79-7.381c-.159-3.073-4.96-3.092-4.8,0Z"/><path class="c" d="M35.789,222.453l7.1,3.57a2.552,2.552,0,0,0,1.85.242,2.4,2.4,0,0,0,.573-4.387l-7.1-3.57a2.55,2.55,0,0,0-1.849-.242,2.4,2.4,0,0,0-.574,4.387Z"/><path class="c" d="M73.86,144.946c-.144,2.176-.372,4.326-.731,6.477a30.619,30.619,0,0,1-.719,3.9,3.687,3.687,0,0,1-.516,1.121,4.336,4.336,0,0,1-1.589,1.217,9.151,9.151,0,0,1-1.382.524c-4.333,1.376-8.671,2.739-13,4.132-1.881.606-3.782,1.18-5.635,1.868a2.466,2.466,0,0,0-1.677,2.952,2.421,2.421,0,0,0,2.953,1.677c4.288-1.592,8.717-2.859,13.076-4.241,4.116-1.3,9.845-2.215,11.847-6.555a18.911,18.911,0,0,0,1.221-5.036c.436-2.671.772-5.336.951-8.038a2.4,2.4,0,1,0-4.8,0Z"/><path class="c" d="M129.149,164.048c11.579,4.942,22.819,10.58,33.9,16.54a112.447,112.447,0,0,1,12.17,7.333,42.258,42.258,0,0,1,4.242,3.486,21.306,21.306,0,0,1,4.488,6.409c2.672,5.437,3.547,11.125,4.069,17.093a2.463,2.463,0,0,0,2.4,2.4,2.417,2.417,0,0,0,2.4-2.4c-.5-5.774-1.24-11.291-3.463-16.683a29.73,29.73,0,0,0-8.981-12.4,79.985,79.985,0,0,0-11.509-7.55c-5.646-3.061-11.315-6.083-17.053-8.967q-9.977-5.014-20.244-9.405a2.482,2.482,0,0,0-3.284.861,2.416,2.416,0,0,0,.861,3.283Z"/><path class="c" d="M5.3,202.709c1.05-7.347,3.937-14.462,10.344-18.627,7.1-4.614,15.006-8,22.834-11.152,4.774-1.922,9.592-3.731,14.421-5.509a2.464,2.464,0,0,0,1.676-2.952,2.42,2.42,0,0,0-2.952-1.676c-9.011,3.316-18.016,6.726-26.711,10.813a99.229,99.229,0,0,0-11.259,6.053,26.021,26.021,0,0,0-8.139,7.955A34.39,34.39,0,0,0,.675,201.433a2.481,2.481,0,0,0,1.676,2.952A2.418,2.418,0,0,0,5.3,202.709Z"/><path class="a" d="M60.334,205.279c2.017-3.117,7.481-10.037,7.852-12.037a27.029,27.029,0,0,0,.05-7.886c-1.161-8.658-1.8-20.485-3.32-25.635a53.2,53.2,0,0,0-5.449-13.071,106.17,106.17,0,0,0-7.682-11.536,7.991,7.991,0,0,1-1.622-4.161,3.332,3.332,0,0,1,2.145-3.363,7.068,7.068,0,0,1,4.6.1c4.513,2.445,7.507,6.061,10.9,11.331,2.334,3.628,9.663,13.293,11.794,17.044l.212.33c1.794-1.032,3.542-1.8,6-2.91,1.09-.492,4.4-1.6,5.6-1.437a7.962,7.962,0,0,1,6.815,7.121c2.3-.586,4.219.764,5.548,2.349,1.181,1.409,2.264,3.622,1.106,8.031h0a6.964,6.964,0,0,1,4.056,6.185c.17,2.347.387,4.414-.911,7.024-1.347,2.706-4.827,1.069-5.82-.188l-.382-.183c1,3.533,2.474,9.748.691,14.269-.641,1.627-5.989,5.681-8.259,7.1-3,4.667-5.926,14.222-6.963,17.037"/><path class="c" d="M77.335,160.926a37.74,37.74,0,0,1,5.906-3.624c1.047-.511,2.111-.987,3.173-1.466.176-.079.923-.4.4-.188.155-.063.31-.123.467-.18.479-.174.961-.339,1.449-.488,1.843-.564,2.629-.86,4.322.112a5.668,5.668,0,0,1,2.776,4.081,2.449,2.449,0,0,0,3.038,2.314,2.6,2.6,0,0,1,2.179.675,4.492,4.492,0,0,1,1.438,1.7c.02.035.212.418.134.243s.143.426.141.418a5.531,5.531,0,0,1,.193.924,10.113,10.113,0,0,1-.383,3.467c-.747,3,3.881,4.277,4.628,1.276.754-3.024.959-6.4-.8-9.132-1.939-3.025-5.181-4.956-8.811-4.2l3.038,2.314a10.776,10.776,0,0,0-3.72-7.208,9.077,9.077,0,0,0-7.581-2.1,31.408,31.408,0,0,0-7.014,2.586,41.316,41.316,0,0,0-7.4,4.33,2.475,2.475,0,0,0-.861,3.284,2.418,2.418,0,0,0,3.284.861Z"/><path class="c" d="M85.324,167.307c1.147-.583,2.314-1.125,3.489-1.65q1.026-.459,2.061-.9l.953-.406c.634-.269-.447.186.186-.078l.471-.2c2.119-.884,4.251-1.737,6.385-2.586a2.46,2.46,0,0,0,1.676-2.952,2.425,2.425,0,0,0-2.952-1.676c-4.943,1.965-9.947,3.889-14.691,6.3a2.417,2.417,0,0,0-.861,3.284,2.456,2.456,0,0,0,3.283.861Z"/><path class="c" d="M106.1,167.481c-2.928-1.289-5.98-.563-8.919.33-1.371.417-2.745.808-4.077,1.341-1.507.6-3.054,1.338-4.5,1.946a2.481,2.481,0,0,0-1.676,2.952,2.415,2.415,0,0,0,2.952,1.677A78.56,78.56,0,0,1,97.8,172.64a35.43,35.43,0,0,1,3.577-.968c.157-.031.316-.059.474-.084-.245.028-.223.025.066-.007.3-.023.607-.047.913-.044.138,0,.973.144.44.016.11.027.913.3.405.073a2.477,2.477,0,0,0,3.284-.861,2.419,2.419,0,0,0-.861-3.284Z"/><path class="c" d="M100.513,184.271a7.048,7.048,0,0,0,3.836,2.2,5.132,5.132,0,0,0,5.539-2.129,11.577,11.577,0,0,0,1.58-6.383,15.458,15.458,0,0,0-.932-5.779,9.161,9.161,0,0,0-4.439-4.7,2.4,2.4,0,1,0-2.423,4.145,9.26,9.26,0,0,1,1.265.751c-.315-.221-.14-.11.057.069a6.527,6.527,0,0,1,.483.487c.075.085.149.171.219.26l-.17-.216c.134.064.293.441.366.569a2.2,2.2,0,0,1,.308.609l-.109-.255c.042.108.081.218.118.328a10.594,10.594,0,0,1,.3,1.216q.063.407-.008-.085c.014.126.025.252.034.379.023.272.041.545.059.818a21.04,21.04,0,0,1,.019,2.8q-.047.418.008-.03c-.016.1-.034.206-.054.308q-.072.369-.172.731c-.082.293-.182.578-.288.863.142-.38-.151.318-.156.327a3.348,3.348,0,0,1-.168.3q-.224.327.09-.109a2.271,2.271,0,0,1-.21.206q.431-.314.2-.167c-.463.306.438-.078.023.013-.646.142.406.037-.021.03l-.408,0c-.412,0,.6.135-.046-.024-.16-.039-.313-.095-.47-.142-.554-.166.392.218,0,0-.065-.036-.816-.4-.794-.475q.48.381.2.152c-.057-.048-.114-.1-.168-.151a3.578,3.578,0,0,1-.278-.3,2.407,2.407,0,0,0-3.394,0,2.467,2.467,0,0,0,0,3.394Z"/><path class="c" d="M98.921,180.961a54.476,54.476,0,0,1,1.865,7.922,17.2,17.2,0,0,1-.01,5.135,11.262,11.262,0,0,1-.291,1.189c-.049.163-.094.336-.159.493.027-.064.112-.3,0,0a1.086,1.086,0,0,1-.138.212c-.2.27.259-.3.009-.016q-.318.364-.659.706a33.355,33.355,0,0,1-3.265,2.811c-1.116.86-2.382,1.564-3.462,2.459-1.179.976-1.875,2.846-2.508,4.211-.775,1.67-1.473,3.379-2.134,5.1-1.139,2.965-2.092,5.992-3.181,8.975a2.422,2.422,0,0,0,1.676,2.952,2.45,2.45,0,0,0,2.952-1.676c2.022-5.537,3.548-11.436,6.721-16.464l-.861.861a51.367,51.367,0,0,0,6.075-4.561c1.912-1.654,3.3-3.264,3.823-5.8,1.1-5.345-.4-10.658-1.82-15.782-.823-2.973-5.455-1.71-4.628,1.276Z"/><path class="c" d="M81.673,154.857a131.911,131.911,0,0,0-7.478-10.879c-2.846-3.965-5.394-8.215-8.5-11.979-3.262-3.956-8.462-8.7-14.026-6.723-3.332,1.186-4.542,4.7-3.52,7.922.914,2.884,3.144,5.246,4.851,7.69a63.117,63.117,0,0,1,9.6,19.471c.808,2.978,5.44,1.714,4.628-1.276a62.9,62.9,0,0,0-7.346-16.462c-1.426-2.315-2.988-4.538-4.585-6.737-.774-1.067-3.942-4.507-2.415-5.891a2.991,2.991,0,0,1,1.923-.332,5.068,5.068,0,0,1,2.738,1.226,23.6,23.6,0,0,1,5,4.8c2.656,3.287,4.85,7.01,7.317,10.448a135.059,135.059,0,0,1,7.67,11.145c1.538,2.678,5.687.263,4.144-2.423Z"/><path class="c" d="M62.406,206.49c1.554-2.38,3.295-4.636,4.916-6.971,1.536-2.211,3.048-4.33,3.388-7.053.49-3.917-.195-7.771-.617-11.658-.41-3.77-.749-7.548-1.171-11.318a63.04,63.04,0,0,0-1.692-10.407c-.851-2.963-5.485-1.7-4.628,1.276a50.074,50.074,0,0,1,1.392,8.006c.424,3.614.752,7.238,1.13,10.858s1.07,7.287.964,10.947a20.642,20.642,0,0,1-.216,2.434,3.61,3.61,0,0,1-.111.385c.155-.6-.034.06-.134.254a30.78,30.78,0,0,1-2,3.2c-1.752,2.568-3.669,5.025-5.368,7.628s2.461,5,4.144,2.422Z"/><path class="c" d="M.589,202.071c-2.111,23.542,1.576,47.465,9.028,69.817,3.326,9.979,7.449,20.9,16.738,26.823A22.254,22.254,0,0,0,40.6,302.328c4.677-.553,8.741-3.024,12.491-5.737a63.492,63.492,0,0,0,10.672-9.512,65.569,65.569,0,0,0,6.191-8.93c4.222-6.858,8.134-13.91,11.907-21.023,3.514-6.626,6.927-13.319,10.033-20.148,1.087-2.39,2.161-4.8,3.058-7.269.5-1.378,1.155-3.036.736-4.513-.6-2.117-2.944-3.636-4.617-4.828a96.213,96.213,0,0,0-8.392-5.186c-6.806-3.861-13.787-7.405-20.748-10.975q-2.049-1.05-4.092-2.11a2.465,2.465,0,0,0-3.284.861c-3.624,5.458-6.9,11.157-10.127,16.856S38,231.257,35.177,237.168a2.465,2.465,0,0,0,.861,3.283,2.421,2.421,0,0,0,3.284-.861c2.827-5.91,6.024-11.653,9.251-17.353s6.5-11.4,10.127-16.856l-3.284.861c6.266,3.261,12.583,6.424,18.807,9.765,3.288,1.765,6.559,3.565,9.755,5.49,1.28.772,2.549,1.563,3.786,2.4q.777.526,1.532,1.085c.1.075.2.152.3.229-.059-.045-.388-.311-.059-.041.214.174.428.348.636.53.312.275.589.578.886.868.414.4-.231-.333-.036-.057.251.358.139.382.021-.077.139.542,0-.807-.034-.11.035-.813.028-.206-.083.229a21.812,21.812,0,0,1-.71,2.16c-.173.467-.355.93-.541,1.392q-.137.34-.277.68c-.048.118-.1.236-.147.354a1.413,1.413,0,0,1-.067.159c-2.608,6.091-5.577,12.031-8.607,17.92-3.628,7.051-7.409,14.027-11.4,20.877-1.764,3.024-3.571,6.024-5.468,8.967a43.926,43.926,0,0,1-7.084,8.457,56.65,56.65,0,0,1-10.518,7.889,14.964,14.964,0,0,1-11.769,1.655c-9.7-2.636-14.826-12.044-18.109-20.805C8.387,255.332,4.137,232.7,4.878,210.323q.138-4.132.511-8.252a2.418,2.418,0,0,0-2.4-2.4,2.452,2.452,0,0,0-2.4,2.4Z"/><path class="c" d="M97.628,98.464q.4,1.215.76,2.446a18.236,18.236,0,0,1,.658,2.608l-.086-.638a2.325,2.325,0,0,1,0,.514l.085-.638a1.534,1.534,0,0,1-.059.231l.242-.573a1.2,1.2,0,0,1-.112.2l.375-.486a.722.722,0,0,1-.109.112l.486-.375a2.98,2.98,0,0,1-.566.321l.573-.242a2.576,2.576,0,0,1-.6.166l.638-.086a6.341,6.341,0,0,1-1.135-.063,2.4,2.4,0,0,0-2.4,2.4,2.458,2.458,0,0,0,2.4,2.4,8.771,8.771,0,0,0,.943.078,4.967,4.967,0,0,0,2.3-.654,3.274,3.274,0,0,0,1.657-2.154,5.21,5.21,0,0,0-.1-2.309c-.368-1.531-.82-3.042-1.316-4.535a2.542,2.542,0,0,0-1.1-1.435,2.4,2.4,0,0,0-3.526,2.711Z"/><path class="c" d="M70.307,86.561c-.639,2.681.279,8.694,5.292,8.887,6.579-.465,6.457-7.8,4.019-11.093C77.622,81.658,72.213,80.832,70.307,86.561Z"/><path class="c" d="M123.016,83.155c.978,2.577.842,8.658-4.105,9.494-6.584.386-7.407-6.9-5.414-10.483C115.13,79.234,120.388,77.719,123.016,83.155Z"/><path class="c" d="M93.853,125.132a17.84,17.84,0,0,1,2.887-1.482,17.563,17.563,0,0,1,2.083-.637,11.564,11.564,0,0,1,1.6-.283,39.725,39.725,0,0,1,4.254-.122c.588.018,1.176.051,1.761.107.151.014.3.03.451.048q-.422-.062-.014,0c.24.043.479.085.717.138a2.4,2.4,0,0,0,1.276-4.628,27.246,27.246,0,0,0-8.731-.315,20.354,20.354,0,0,0-8.7,3.029,2.4,2.4,0,0,0,2.422,4.145Z"/></svg>`
    };

    // Icon Designs by Mariusz Ostrowski, Microsoft, & Soco St

    const state = {
        ui: {
            hidingEnabled: localStorage.getItem(STORAGE_KEY_HIDE_SPONSORED) !== "false",
            highlightedSponsoredContent: [],
            bannerUpdateScheduled: false,
            isContentProcessing: false,
            updateScheduled: false
        },
        observer: {
            generalCleanupObserver: null,
            sponsoredCarouselObserver: null,
            generalCleanupObserverInitialized: false,
            mainObserverInitialized: false,
            sponsoredCarouselObserverInitialized: false
        }
    };

    function createStyles() {
        const style = document.createElement("style");
        style.textContent = `
            :root {
                --color-app-bubble: #E74C3C;
                --color-app-icon-default: white;
                --color-app-icon-heart-hover: red;
                --color-app-icon-megaphone-hover: gold;
                --color-app-switch-off: #CCC;
                --color-app-switch-on: #2AA866;
                --color-app-switch-thumb: white;
                --color-highlight-background: rgba(255, 230, 230, 0.30);
                --color-highlight-border: #D95C5C;
                --color-panel-default: rgba(34, 50, 70, 0.85);
                --color-panel-divider: rgba(255, 255, 255, 0.1);
                --color-panel-footer-tooltip: rgba(15, 20, 30, 0.90);
                --color-panel-row-default: rgba(20, 30, 45, 0.50);
                --color-panel-shadow: 0 8px 20px rgba(0, 0, 0, 0.20);
                --color-text-default: white;
                --color-text-link-panel-default: var(--color-text-link-panel-hover);
                --color-text-link-panel-hover: lightblue;
                --color-text-link-seller-hover: #2854D9;
                --font-app-default: "Segoe UI", sans-serif;
                --size-text-body-default: 14px;
                --size-text-body-error-subtitle: 12px;
                --size-text-body-error-title: 19px;
                --size-text-footer-default: 12px;
                --size-text-header-title: 24px;
                --size-thickness-highlight-border: 2px;
            }
            @media (max-width: 768px) {
                #panelWrapper {
                    position: fixed;
                    right: unset;
                    bottom: 5px;
                    left: 50%;
                    width: 90% !important;
                    padding: 0 16px;
                    transform: translateX(-50%);
                }
                #panelHeader h2.panel-title {
                    position: static;
                    bottom: auto;
                }
            }
            #panelWrapper {
                position: fixed;
                right: 5px;
                bottom: 10px;
                z-index: 99998;
                width: 100%;
                max-width: 320px;
                padding: 0 16px;
                font-family: var(--font-app-default);
            }
            #panelWrapper, #panelBox, #panelBox * {
                box-sizing: border-box;
            }
            #panelBox {
                display: none;
            }
            #panelBox.show {
                display: flex;
                flex-direction: column;
                gap: 0;
                width: 100%;
                padding: 16px;
                color: var(--color-text-default);
                background: var(--color-panel-default);
                border-radius: 16px;
                box-shadow: var(--color-panel-shadow);
                backdrop-filter: blur(10px);
                will-change: transform;
                transform: translate3d(0, 0, 0);
                transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
            }
            #panelBox:hover {
                transform: translate3d(0, -2px, 0);
            }
            #panelBox.minimized {
                overflow: hidden;
                padding: 12px;
            }
            #panelBox.minimized #arrowIcon {
                transform: rotate(180deg);
            }
            #panelHeader {
                display: flex;
                align-items: center;
                gap: 8px;
                height: 30px;
            }
            #panelHeader h2.panel-title {
                display: flex;
                align-items: center;
                margin: 0;
                color: var(--color-text-default);
                font-size: var(--size-text-header-title);
                font-weight: 600;
            }
            h2.panel-title, #lockIconContainer {
                position: relative;
                bottom: 1px;
            }
            h2.panel-title, .panel-body-row, .panel-footer, .error-page {
                user-select: none;
            }
            .panel-page-container {
                position: relative;
                width: 100%;
            }
            .panel-body-row {
                display: flex;
                align-items: center;
                justify-content: space-between;
                margin: 0;
                padding: 12px 16px;
                background: var(--color-panel-row-default);
                border-radius: 16px;
                backdrop-filter: blur(12px);
                font-size: var(--size-text-body-default);
            }
            .panel-body-row + .panel-body-row {
                margin-top: 5px;
            }
            hr.section-divider {
                flex-grow: 1;
                margin: 12px 0;
                border: none;
                border-top: 1px solid var(--color-panel-divider);
            }
            .panel-footer {
                display: flex;
                align-items: center;
                justify-content: flex-end;
                gap: 6px;
                height: 10px;
                color: var(--color-text-default);
                font-size: var(--size-text-footer-default);
            }
            #minimizePanelButton {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 18px;
                height: 18px;
                margin-left: auto;
                padding: 0;
                background: none;
                border: none;
                cursor: pointer;
            }
            #lockIconContainer {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 26px;
                height: 26px;
            }
            .lock-icon {
                width: 26px;
                height: 26px;
                padding: 4px;
                fill: var(--color-app-icon-default);
            }
            .lock-icon-animation {
                position: absolute;
                top: 0;
                left: 0;
                width: 26px;
                height: 26px;
                opacity: 0;
                transform: rotate(0deg);
                transition: opacity 0.4s ease, transform 0.4s ease;
            }
            .lock-icon-animation.active {
                opacity: 1;
                transform: rotate(360deg);
            }
            #arrowIcon {
                width: 28px;
                height: 28px;
                fill: var(--color-app-icon-default);
                transition: transform 0.3s ease;
            }
            .footer-icon-tooltip {
                position: relative;
                display: inline-flex;
                align-items: center;
                justify-content: center;
            }
            .footer-icon-tooltip::after {
                position: absolute;
                bottom: calc(100% + 8px);
                left: 50%;
                z-index: 99999;
                padding: 6px 8px;
                color: var(--color-text-default);
                background: var(--color-panel-footer-tooltip);
                border-radius: 8px;
                content: attr(data-tooltip);
                font-size: 11px;
                white-space: nowrap;
                opacity: 0;
                pointer-events: none;
                transform: translateX(-50%) translateY(4px);
                transition: opacity 0.2s ease, transform 0.2s ease;
            }
            .footer-icon-tooltip::before {
                position: absolute;
                bottom: calc(100% + 3px);
                left: 50%;
                z-index: 99998;
                border: 5px solid transparent;
                content: "";
                opacity: 0;
                pointer-events: none;
                transform: translateX(-50%) translateY(4px);
                transition: opacity 0.2s ease, transform 0.2s ease;
            }
            .footer-icon-tooltip:hover::after, .footer-icon-tooltip:hover::before {
                opacity: 1;
                transform: translateX(-50%) translateY(0);
            }
            .error-icon {
                position: relative;
                top: 0;
                left: 0;
                width: 50px;
                height: 50px;
                fill: var(--color-app-icon-default);
                flex-shrink: 0;
            }
            .update-icon, .megaphone-icon, .heart-icon {
                display: block;
                fill: var(--color-app-icon-default);
            }
            .update-icon {
                width: 12px;
                height: 12px;
                transform-origin: center;
                transition: transform 0.45s ease, fill 0.25s ease;
            }
            .update-icon:hover {
                fill: var(--color-text-link-panel-hover);
                transform: rotate(360deg);
            }
            .megaphone-icon {
                width: 11px;
                height: 11px;
                transition: fill 0.25s ease;
            }
            .megaphone-icon:hover {
                fill: var(--color-app-icon-megaphone-hover);
            }
            .heart-icon {
                width: 11px;
                height: 11px;
            }
            .heart-icon:hover {
                fill: var(--color-app-icon-heart-hover);
            }
            #countBubble {
                min-width: 20px;
                padding: 3px 8px;
                color: var(--color-text-default);
                background-color: var(--color-app-bubble);
                border-radius: 999px;
                font-size: 12px;
                font-weight: bold;
                text-align: center;
            }
            .switch {
                position: relative;
                display: inline-block;
                width: 42px;
                height: 22px;
            }
            .switch input {
                width: 0;
                height: 0;
                opacity: 0;
            }
            .switch-label {
                margin-right: 10px;
            }
            .slider {
                position: absolute;
                top: 0;
                right: 0;
                bottom: 0;
                left: 0;
                cursor: pointer;
                background-color: var(--color-app-switch-off);
                border-radius: 34px;
                transition: 0.3s;
            }
            .slider:before {
                position: absolute;
                top: 2px;
                left: 2px;
                width: 18px;
                height: 18px;
                content: "";
                background-color: var(--color-app-switch-thumb);
                border-radius: 50%;
                transition: 0.3s;
            }
            input:checked + .slider {
                background-color: var(--color-app-switch-on);
            }
            input:checked + .slider:before {
                transform: translateX(20px);
            }
            #creatorPage {
                display: flex;
                align-items: center;
                color: var(--color-text-default);
                transition: color 0.3s ease;
            }
            #creatorPage:hover, .outbound-status-page:hover, .outbound-update-page:hover {
                color: var(--color-text-link-panel-hover);
            }
            .outbound-status-page, .outbound-update-page {
                color: var(--color-text-link-panel-default);
                text-decoration: underline;
            }
            .outbound-status-page:visited, .outbound-update-page:visited {
                color: var(--color-text-link-panel-default);
            }
            .enhanced-seller-info {
                text-decoration: none !important;
            }
            .enhanced-seller-info:hover {
                color: var(--color-text-link-seller-hover) !important;
            }
            .error-page {
                font-size: var(--size-text-body-error-title);
            }
            .error-content-row {
                display: flex;
                align-items: center;
                justify-content: space-between;
                width: 100%;
            }
            .error-icon-container {
                flex: 0 0 45%;
                display: flex;
                justify-content: flex-end;
            }
            .error-icon-container svg {
                width: auto;
                height: auto;
                max-width: 100%;
                max-height: 110px;
                fill: var(--color-app-icon-default);
            }
            .error-text-container {
                flex: 0 0 55%;
                text-align: left;
                line-height: 1.2;
            }
            .error-page p {
                text-align: left;
                font-size: var(--size-text-body-error-subtitle);
            }
            .sponsored-highlight {
                background-color: var(--color-highlight-background);
                border: var(--size-thickness-highlight-border) dashed var(--color-highlight-border) !important;
            }
            .sponsored-hidden, .sponsored-hidden-banner, .sponsored-hidden-carousel {
                display: none !important;
            }
        `;
        document.head.appendChild(style);
    }

    async function init() {
        initScriptObservers();
        createStyles();
        buildPanel();
        updatePanelVisibility();
        repairSiteButtons();
        if (determineCarouselDetection()) {
            removeSponsoredCarousels();
        }
        await processSponsoredContent();
        disableSiteTelemetry();
        requestIdleCallback(cleanGeneralURLs, {
            timeout: 1500
        });
    }

    function isValidSearchResultsPage() {
        const url = new URL(location.href);
        const params = url.searchParams;
        const isAdvancedSearchPage = url.href.includes("ebayadvsearch");
        const isSellerPage = params.has("_ssn");
        const isVisuallySimilarPage = params.get("_vss") === "1";
        const isCompletedPage = params.get("LH_Complete") === "1";
        const isSoldPage = params.get("LH_Sold") === "1";
        return (
            isSearchResultsPage() && !isAdvancedSearchPage && !isVisuallySimilarPage && !isSellerPage && !isCompletedPage && !isSoldPage
        );
    }

    function isListingPage() {
        return /^https:\/\/([a-z0-9-]+\.)*ebay\.[a-z.]+\/itm\/\d+/.test(location.href);
    }

    function isLiveStreamPage() {
        return /^https:\/\/([a-z0-9-]+\.)*ebay\.[a-z.]+\/ebaylive\/events\/[A-Za-z0-9]+\/stream\/?$/i.test(location.href);
    }

    function isSearchResultsPage() {
        return /^https:\/\/([a-z0-9-]+\.)*ebay\.[a-z.]+\/(sch|shop)\//i.test(location.href) ||
            /^https:\/\/([a-z0-9-]+\.)*ebay\.[a-z.]+\/b\/[^/]+\/\d+\/bn_\d+/i.test(location.href);
    }

    function determineCarouselDetection() {
        return isListingPage();
    }

    function observeURLMutation({
        onURLChange
    } = {}) {
        if (!window.__urlMutationObserver) {
            let previousURL = location.href;
            const listeners = new Set();
            const handleURLChange = () => {
                const currentURL = location.href;
                if (currentURL !== previousURL) {
                    previousURL = currentURL;
                    for (const cb of listeners) {
                        try {
                            cb(currentURL);
                        } catch (err) {
                            console.error(`${SCRIPT_NAME_DEBUG} v${SCRIPT_VERSION}: LISTENER ERROR OCCURED\n`, err);
                        }
                    }
                    updatePanelVisibility();
                    scheduleHighlightUpdate();
                }
            };
            ["pushState", "replaceState"].forEach(method => {
                const original = history[method];
                if (original.__isWrapped) return;

                function wrapped(...args) {
                    const result = original.apply(history, args);
                    handleURLChange();
                    return result;
                }
                wrapped.__isWrapped = true;
                history[method] = wrapped;
            });
            window.addEventListener("popstate", handleURLChange);
            window.addEventListener("hashchange", handleURLChange);
            window.__urlMutationObserver = {
                addListener(cb) {
                    if (typeof cb === 'function') {
                        listeners.add(cb);
                    }
                },
                removeListener(cb) {
                    listeners.delete(cb);
                }
            };
        }
        if (typeof onURLChange === 'function') {
            window.__urlMutationObserver.addListener(onURLChange);
        }
    }

    function initScriptObservers() {
        observeURLMutation();
        initGeneralURLCleanupObserver();
        if (isSearchResultsPage()) {
            initSponsoredBannerObserver();
        }
        if (determineCarouselDetection()) {
            initSponsoredCarouselObserver();
        }
    }

    function initMainObserver() {
        if (state.observer.mainObserverInitialized) return;
        observer.observe(document.body, {
            childList: true,
            subtree: true,
        });
        state.observer.mainObserverInitialized = true;
    }

    function initSanitizePageObserver() {
        const CONFIG = {
            DOM_QUIET_MS: 900,
            FALLBACK_MS: 6000,
            NETWORK_IDLE_POLL_MS: 100,
            NETWORK_IDLE_GRACE_MS: 350,
            NETWORK_IDLE_TIMEOUT_MS: 8000,
            RAF_STABILIZATION_FRAMES: 2,
            PHASE_SPACING_MS: [0, 500, 1200],
            SUMMARY_PRINT_MS: 1000,
            COLD_LOAD_EXTRA_DELAY_MS: 800,
            WARM_LOAD_EXTRA_DELAY_MS: 150,
        };
        const LOAD_TYPE = (() => {
            const nav = performance.getEntriesByType('navigation')[0];
            if (!nav) return 'COLD';
            return (nav.type === 'reload' || nav.type === 'back_forward') ? 'WARM' : 'COLD';
        })();
        let settleObserver = null;
        let quietTimer = null;
        let fallbackTimer = null;
        let summaryTimer = null;
        let pendingRequests = 0;
        let cleanupStats = [];
        let cleanupInProgress = false;
        let isCleaningUp = false;
        let frameworkReady = false;

        function checkFrameworkReady() {
            const filtersContainer = document.querySelector('.x-refine__main, .srp-controls');
            if (!document.querySelector('.srp-main, .srp-main-content')) return true;
            return !!filtersContainer;
        }
        async function waitUntilReady() {
            if (frameworkReady) return;
            const start = performance.now();
            while (!checkFrameworkReady() && (performance.now() - start < 8000)) {
                await new Promise(r => setTimeout(r, 100));
            }
            await new Promise(r => requestAnimationFrame(r));
            frameworkReady = true;
        }

        function scheduleSummaryPrint() {
            clearTimeout(summaryTimer);
            summaryTimer = setTimeout(() => {
                if (!cleanupStats.length) return;
                const total = cleanupStats.length;
                const avgDelay = cleanupStats.reduce((a, b) => a + b.actual, 0) / total;
                const avgExec = cleanupStats.reduce((a, b) => a + b.exec, 0) / total;
                const maxDelay = Math.max(...cleanupStats.map(s => s.actual));
                const maxExec = Math.max(...cleanupStats.map(s => s.exec));
                console.log(
                    `${SCRIPT_NAME_DEBUG} v${SCRIPT_VERSION} - CLEANING SUMMARY · ` +
                    `LOAD: ${LOAD_TYPE} | RUNS: ${String(total).padStart(2, '0')} | ` +
                    `AVG DELAY: ${avgDelay.toFixed(2)}ms | MAX DELAY: ${maxDelay.toFixed(2)}ms | ` +
                    `AVG EXEC: ${avgExec.toFixed(2)}ms | MAX EXEC: ${maxExec.toFixed(2)}ms`
                );
                cleanupStats = [];
            }, CONFIG.SUMMARY_PRINT_MS);
        }

        function trackRequestStart() {
            pendingRequests++;
        }

        function trackRequestEnd() {
            pendingRequests = Math.max(0, pendingRequests - 1);
        }
        const origFetch = window.fetch;
        window.fetch = async (...args) => {
            trackRequestStart();
            try {
                return await origFetch(...args);
            } finally {
                trackRequestEnd();
            }
        };
        const origXHROpen = XMLHttpRequest.prototype.open;
        const origXHRSend = XMLHttpRequest.prototype.send;
        XMLHttpRequest.prototype.open = function(...args) {
            this.__spotlessTracked = false;
            return origXHROpen.apply(this, args);
        };
        XMLHttpRequest.prototype.send = function(...args) {
            if (!this.__spotlessTracked) {
                this.__spotlessTracked = true;
                trackRequestStart();
                this.addEventListener('loadend', () => {
                    trackRequestEnd();
                }, {
                    once: true
                });
            }
            return origXHRSend.apply(this, args);
        };
        async function stabilizeFrames(count) {
            for (let i = 0; i < count; i++) {
                await new Promise(requestAnimationFrame);
            }
        }

        function getAdaptiveGraceDelay() {
            const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
            let delay = (LOAD_TYPE === 'COLD') ? CONFIG.COLD_LOAD_EXTRA_DELAY_MS : CONFIG.WARM_LOAD_EXTRA_DELAY_MS;
            if (connection) {
                if (connection.effectiveType === '2g') delay += 1200;
                else if (connection.effectiveType === '3g') delay += 500;
            }
            return delay;
        }
        async function waitForNetworkIdle() {
            const start = performance.now();
            while (pendingRequests > 0 && performance.now() - start < CONFIG.NETWORK_IDLE_TIMEOUT_MS) {
                await new Promise(r => setTimeout(r, CONFIG.NETWORK_IDLE_POLL_MS));
            }
            await stabilizeFrames(CONFIG.RAF_STABILIZATION_FRAMES);
            await new Promise(r => setTimeout(r, CONFIG.NETWORK_IDLE_GRACE_MS));
            await stabilizeFrames(CONFIG.RAF_STABILIZATION_FRAMES);
            await new Promise(r => setTimeout(r, getAdaptiveGraceDelay()));
        }

        function runCleanupWithLogging(label, scheduledAt, expectedDelay) {
            if (isCleaningUp) return;
            isCleaningUp = true;
            const actualStart = performance.now();
            const execStart = performance.now();
            try {
                disableSiteTelemetryAttributes();
            } finally {
                isCleaningUp = false;
            }
            cleanupStats.push({
                label,
                expected: expectedDelay,
                actual: actualStart - scheduledAt,
                exec: performance.now() - execStart
            });
            scheduleSummaryPrint();
        }

        function runCleanupPhases() {
            CONFIG.PHASE_SPACING_MS.forEach((delay, index) => {
                const scheduledAt = performance.now();
                setTimeout(() => {
                    runCleanupWithLogging(`PHASE ${index + 1}`, scheduledAt, delay);
                }, delay);
            });
        }
        async function finalizeDOMSettled() {
            if (cleanupInProgress) return;
            cleanupInProgress = true;
            try {
                await waitUntilReady();
                await waitForNetworkIdle();
                runCleanupPhases();
            } finally {
                cleanupInProgress = false;
            }
        }

        function scheduleAfterDOMSettled() {
            let done = false;
            async function finalize() {
                if (done) return;
                done = true;
                if (settleObserver) {
                    settleObserver.disconnect();
                    settleObserver = null;
                }
                clearTimeout(quietTimer);
                clearTimeout(fallbackTimer);
                await finalizeDOMSettled();
            }
            if (settleObserver) {
                clearTimeout(quietTimer);
                quietTimer = setTimeout(finalize, CONFIG.DOM_QUIET_MS);
                return;
            }
            settleObserver = new MutationObserver(() => {
                clearTimeout(quietTimer);
                quietTimer = setTimeout(finalize, CONFIG.DOM_QUIET_MS);
            });
            settleObserver.observe(document.body, {
                childList: true,
                subtree: true
            });
            quietTimer = setTimeout(finalize, CONFIG.DOM_QUIET_MS);
            fallbackTimer = setTimeout(finalize, CONFIG.FALLBACK_MS);
        }
        const observer = new MutationObserver(() => {
            if (isCleaningUp) return;
            if (!frameworkReady) {
                if (checkFrameworkReady()) frameworkReady = true;
                else return;
            }
            if (typeof cleanListingURLs === 'function') cleanListingURLs();
            scheduleAfterDOMSettled();
        });

        function startObservers() {
            observer.observe(document.body, {
                childList: true,
                subtree: true,
                attributes: true,
                attributeFilter: ['href'],
            });
            finalizeDOMSettled();
        }
        if (document.body) {
            startObservers();
        } else {
            window.addEventListener('DOMContentLoaded', startObservers, {
                once: true
            });
        }
        return {
            resetDelayState: () => {
                if (settleObserver) {
                    settleObserver.disconnect();
                    settleObserver = null;
                }
                clearTimeout(quietTimer);
                clearTimeout(fallbackTimer);
            }
        };
    }

    function initSponsoredBannerObserver() {
        const observer = new MutationObserver(() => {
            if (state.ui.bannerUpdateScheduled) return;
            state.ui.bannerUpdateScheduled = true;
            requestAnimationFrame(() => {
                state.ui.bannerUpdateScheduled = false;
                removeSponsoredBanners(document);
            });
        });
        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    }

    function initSponsoredCarouselObserver() {
        const carouselState = state.observer;
        if (carouselState.sponsoredCarouselObserverInitialized) return;
        carouselState.sponsoredCarouselObserverInitialized = true;
        const targetContainer =
            document.querySelector('[data-results-container], main, .srp-results') ||
            document.body;
        if (!targetContainer) return;
        const observer = new MutationObserver(() => {
            removeSponsoredCarousels();
        });
        observer.observe(targetContainer, {
            childList: true,
            subtree: true
        });
        carouselState.sponsoredCarouselObserver = observer;
    }

    function initGeneralURLCleanupObserver() {
        if (state.observer.generalCleanupObserverInitialized) return;
        state.observer.generalCleanupObserverInitialized = true;
        const observer = new MutationObserver(() => {
            document
                .querySelectorAll('#ebay-autocomplete li[data-type="r"]')
                .forEach(li => {
                    const value = li.getAttribute("data-value");
                    if (!value || value === "nullfalse") {
                        li.remove();
                    }
                });
            if (state.ui.isContentProcessing || state.ui.updateScheduled) return;
            state.ui.updateScheduled = true;
            requestIdleCallback(() => {
                state.ui.updateScheduled = false;
                state.ui.isContentProcessing = true;
                try {
                    cleanGeneralURLs();
                } finally {
                    state.ui.isContentProcessing = false;
                }
            }, {
                timeout: 1000
            });
        });
        observer.observe(document.body, {
            subtree: true,
            childList: true
        });
        state.observer.generalCleanupObserver = observer;
    }

    async function buildPanel() {
        const wrapper = document.createElement("div");
        wrapper.id = "panelWrapper";
        const panelBox = document.createElement("div");
        panelBox.id = "panelBox";
        const header = buildPanelHeader();
        const sponsoredCount = await processSponsoredContent();
        const body = determinePanelState(sponsoredCount, state.ui.hidingEnabled);
        const footer = buildPanelFooter();
        const createDivider = () => {
            const hr = document.createElement("hr");
            hr.className = "section-divider";
            return hr;
        };
        panelBox.append(
            header,
            createDivider(),
            body,
            createDivider(),
            footer
        );
        wrapper.appendChild(panelBox);
        document.body.appendChild(wrapper);
        const isPanelMinimized =
            localStorage.getItem(STORAGE_KEY_PANEL_MINIMIZED) === "true";
        setPanelMinimized(isPanelMinimized);
        const minimizeButton = document.getElementById("minimizePanelButton");
        if (minimizeButton) {
            minimizeButton.addEventListener("click", () => {
                const newState = !panelBox.classList.contains("minimized");
                localStorage.setItem(STORAGE_KEY_PANEL_MINIMIZED, String(newState));
                setPanelMinimized(newState);
            });
        }
        const toggleInput = document.getElementById("toggleSponsoredContentSwitch");
        if (!toggleInput) {
            updatePanelLockIcon();
            return;
        }
        toggleInput.addEventListener("change", ({
            target
        }) => {
            const enabled = target.checked;
            state.ui.hidingEnabled = enabled;
            localStorage.setItem(STORAGE_KEY_HIDE_SPONSORED, String(enabled));
            updatePanelLockIcon();
            scheduleHighlightUpdate();
        });
        updatePanelLockIcon();
    }

    function buildPanelHeader() {
        const header = document.createElement("div");
        header.id = "panelHeader";
        header.innerHTML = `
            <div id="lockIconContainer">
                ${UI_ICON_SET.locked}
                ${UI_ICON_SET.unlocked}
            </div>
            <h2 class="panel-title" aria-level="1">${SCRIPT_NAME}</h2>
            <button id="minimizePanelButton" aria-label="Expands or minimizes the Spotless panel">
                ${UI_ICON_SET.arrow}
            </button>
        `;
        return header;
    }

    function buildPanelFooter() {
        const footer = Object.assign(document.createElement("div"), {
            className: "panel-footer",
        });
        const creatorLink = Object.assign(document.createElement("a"), {
            id: "creatorPage",
            href: "https://github.com/OsborneLabs/Spotless",
            target: "_blank",
            rel: "noopener noreferrer",
            textContent: "Osborne",
        });
        creatorLink.style.textDecoration = "none";
        const separator = Object.assign(document.createElement("span"), {
            textContent: " · ",
        });
        const updateLink = Object.assign(document.createElement("a"), {
            href: "https://greasyfork.org/en/scripts/541981-spotless-for-ebay",
            target: "_blank",
            rel: "noopener noreferrer",
            innerHTML: UI_ICON_SET.update,
        });
        updateLink.className = "footer-icon-tooltip";
        updateLink.dataset.tooltip = "Update";
        const supportLink = Object.assign(document.createElement("a"), {
            href: "https://github.com/OsborneLabs/Spotless/issues",
            target: "_blank",
            rel: "noopener noreferrer",
            innerHTML: UI_ICON_SET.megaphone,
        });
        supportLink.className = "footer-icon-tooltip";
        supportLink.dataset.tooltip = "Submit an issue";
        const donateLink = Object.assign(document.createElement("a"), {
            href: "https://ko-fi.com/OsborneLabs",
            target: "_blank",
            rel: "noopener noreferrer",
            innerHTML: UI_ICON_SET.heart,
        });
        donateLink.className = "footer-icon-tooltip";
        donateLink.dataset.tooltip = "Donate";
        footer.append(creatorLink, separator, updateLink, supportLink, donateLink);
        return footer;
    }

    function createPanelRow(innerHTML = "") {
        const row = document.createElement("div");
        row.className = "panel-body-row";
        row.innerHTML = innerHTML;
        return row;
    }

    function createSponsoredCountRow() {
        const row = createPanelRow(`
            <span>Sponsored listings</span>
            <span id="countBubble">0</span>
        `);
        row.id = "countSponsoredContentRow";
        return row;
    }

    function createSponsoredToggleRow() {
        const row = createPanelRow(`
            <span class="switch-label">Hide all sponsored</span>
            <label class="switch" aria-label="Toggles the visibility of sponsored listings">
                <input type="checkbox" id="toggleSponsoredContentSwitch" ${state.ui.hidingEnabled ? "checked" : ""}>
                <span class="slider"></span>
            </label>
        `);
        row.id = "toggleSponsoredContentRow";
        return row;
    }

    function buildPanelHomePage() {
        const pageContainer = Object.assign(document.createElement("div"), {
            id: "panelPagecontainer",
            className: "panel-page-container",
        });
        const homePage = Object.assign(document.createElement("div"), {
            id: "homePage",
            className: "panel-page",
        });
        homePage.style.display = "block";
        const countRow = createSponsoredCountRow();
        const toggleRow = createSponsoredToggleRow();
        homePage.append(countRow, toggleRow);
        pageContainer.append(homePage);
        return pageContainer;
    }

    function buildPanelErrorPage() {
        const errorPage = Object.assign(document.createElement("div"), {
            className: "error-page panel-page",
        });
        const errorContent = Object.assign(document.createElement("div"), {
            className: "error-content-row",
        });
        const iconWrapper = Object.assign(document.createElement("div"), {
            className: "error-icon-container",
        });
        iconWrapper.innerHTML = UI_ICON_SET.woman;
        const textWrapper = Object.assign(document.createElement("div"), {
            className: "error-text-container",
        });
        const message = Object.assign(document.createElement("div"), {
            className: "error-message-text",
            innerHTML: "<span>No sponsored listings found</span>"
        });
        const links = document.createElement("p");
        const updateLink = Object.assign(document.createElement("a"), {
            textContent: "Update",
            href: "https://greasyfork.org/en/scripts/541981-spotless-for-ebay",
            target: "_blank",
            rel: "noopener noreferrer",
            className: "outbound-update-page",
        });
        const statusLink = Object.assign(document.createElement("a"), {
            textContent: "check status",
            href: "https://github.com/OsborneLabs/Spotless#ebay",
            target: "_blank",
            rel: "noopener noreferrer",
            className: "outbound-status-page",
        });
        links.append(updateLink, " or ", statusLink);
        textWrapper.append(message, links);
        errorContent.append(iconWrapper, textWrapper);
        errorPage.append(errorContent);
        return errorPage;
    }

    function updatePanelVisibility() {
        const panelBox = document.getElementById("panelBox");
        if (!panelBox) return;
        const isSearchResultsPage = isValidSearchResultsPage();
        if (isSearchResultsPage) {
            panelBox.classList.add("show");
        } else {
            panelBox.classList.remove("show");
        }
    }

    function setPanelMinimized(minimized) {
        const panelBox = document.getElementById("panelBox");
        if (!panelBox) return;
        const panelPage = panelBox.querySelector(".panel-page");
        const sectionDivider = panelBox.querySelectorAll(".section-divider");
        const panelFooter = panelBox.querySelector(".panel-footer");
        panelBox.classList.toggle("minimized", minimized);
        if (panelPage) panelPage.style.display = minimized ? "none" : "block";
        sectionDivider.forEach(el => {
            el.style.display = minimized ? "none" : "";
        });
        if (panelFooter) panelFooter.style.display = minimized ? "none" : "";
    }

    function updatePanelLockIcon() {
        const locked = document.getElementById("lockedIcon");
        const unlocked = document.getElementById("unlockedIcon");
        locked.classList.toggle("active", state.ui.hidingEnabled);
        unlocked.classList.toggle("active", !state.ui.hidingEnabled);
    }

    function determinePanelState(sponsoredCount) {
        if (!validateSponsoredCount(sponsoredCount)) {
            return buildPanelErrorPage();
        }
        return buildPanelHomePage();
    }

    async function processSponsoredContent() {
        if (state.ui.isContentProcessing) {
            return 0;
        }
        state.ui.isContentProcessing = true;
        try {
            observer.disconnect();
            resetSponsoredContent();
            const detectedSponsoredElements = new Set();
            const separatorSizeMethod =
                detectSponsoredListingBySeparatorSize();
            separatorSizeMethod.forEach((li) => {
                detectedSponsoredElements.add(li);
            });
            if (detectedSponsoredElements.size === 0) {
                const spriteClassMethod =
                    detectSponsoredListingBySpriteClass();
                spriteClassMethod.forEach((li) => {
                    detectedSponsoredElements.add(li);
                });
            }
            if (detectedSponsoredElements.size === 0) {
                const ariaGroupMethod =
                    detectSponsoredListingByAriaGroup();
                ariaGroupMethod.forEach((li) => {
                    detectedSponsoredElements.add(li);
                });
            }
            if (detectedSponsoredElements.size === 0) {
                const homoglyphMethod =
                    detectSponsoredListingByHomoglyph();
                homoglyphMethod.forEach((li) => {
                    detectedSponsoredElements.add(li);
                });
                const fontFamilyMethod =
                    detectSponsoredListingByFontGroup();
                fontFamilyMethod.forEach((li) => {
                    detectedSponsoredElements.add(li);
                });
                const translateYMethod =
                    detectSponsoredListingByTranslateY();
                translateYMethod.forEach((li) => {
                    detectedSponsoredElements.add(li);
                });
                const invertMethod =
                    detectSponsoredListingByInvertStyle();
                if (invertMethod?.elements) {
                    invertMethod.elements.forEach((li) => {
                        detectedSponsoredElements.add(li);
                    });
                }
                const svgMethod =
                    await detectSponsoredListingBySVG();
                svgMethod.forEach((el) => {
                    const li = el.closest("li");
                    if (li) {
                        detectedSponsoredElements.add(li);
                    }
                });
            }
            requestAnimationFrame(() => {
                const count =
                    detectedSponsoredElements.size;
                const sponsoredDetectionValid =
                    validateSponsoredCount(count);
                if (sponsoredDetectionValid) {
                    for (const el of detectedSponsoredElements) {
                        if (
                            !el.hasAttribute(
                                "data-sponsored-processed"
                            )
                        ) {
                            designateSponsoredContent(el);
                            highlightSponsoredContent(el);
                            hideShowSponsoredContent(
                                el,
                                state.ui.hidingEnabled
                            );
                        }
                    }
                }
                updatePanelVisibility();
                updateSponsoredCount(count);
                removeSponsoredRibbons();
                cleanListingURLs();
                cleanGeneralURLs();
                cleanGeneralClutter();
                enhanceSellerInfo();
                initMainObserver();
                state.ui.isContentProcessing = false;
            });
            return detectedSponsoredElements.size;
        } catch (err) {
            console.error(`${SCRIPT_NAME_DEBUG} v${SCRIPT_VERSION}: UNABLE TO PROCESS SPONSORED CONTENT, SEE CONSOLE ERROR\n`, err);
            state.ui.isContentProcessing = false;
            initMainObserver();
            return 0;
        }
    }

    function validateSponsoredCount(sponsoredCount) {
        const listings = getListingElements();
        const totalCount = listings.length;
        if (totalCount === 0) return false;
        const MIN_SPONSORED_COUNT = 2;
        const MAX_PERCENT_COUNT = 0.5;
        const sponsoredPercent = sponsoredCount / totalCount;
        return sponsoredCount >= MIN_SPONSORED_COUNT && sponsoredPercent <= MAX_PERCENT_COUNT;
    }

    function updateSponsoredCount(count) {
        const countBubble = document.getElementById("countBubble");
        if (countBubble) countBubble.textContent = count;
    }

    function scheduleHighlightUpdate() {
        if (state.ui.updateScheduled || state.ui.isContentProcessing) return;
        state.ui.updateScheduled = true;
        requestAnimationFrame(() => {
            processSponsoredContent().finally(() => {
                state.ui.updateScheduled = false;
            });
        });
    }

    function getListingElements() {
        return Array.from(document.querySelectorAll("li")).filter((el) => {
            const classes = el.className.split(/\s+/);
            const isClassicListing = classes.some(
                (cls) => /^s-[\w-]+$/.test(cls)
            );
            const isItemCardListing = classes.some(
                (cls) => cls.includes("item-card")
            );
            return isClassicListing || isItemCardListing;
        });
    }

    function detectSponsoredListingBySeparatorSize() {
        const listings = getListingElements();
        const result = [];
        listings.forEach((listing) => {
            const el = listing.querySelector('.s-card__sep span[aria-labelledby]');
            if (!el) return;
            const inner = el.querySelector('span');
            if (!inner) return;
            const rect = inner.getBoundingClientRect();
            if (rect.width > 0 && rect.height > 0) {
                result.push(listing);
            }
        });
        return result;
    }

    function detectSponsoredListingByAriaGroup() {
        const listings = getListingElements();
        if (!listings.length) return [];
        const tokenMap = new Map();
        listings.forEach((listing) => {
            const el = listing.querySelector('.s-card__sep span[aria-labelledby]');
            if (!el) return;
            const inner = el.querySelector('span');
            if (!inner) return;
            const rect = inner.getBoundingClientRect();
            if (rect.width <= 0 || rect.height <= 0) {
                return;
            }
            const aria = el.getAttribute('aria-labelledby');
            if (!aria) return;
            const tokens = aria
                .split(/\s+/)
                .filter(token => token.startsWith('s-'));
            if (!tokens.length) return;
            tokens.forEach((token) => {
                if (!tokenMap.has(token)) {
                    tokenMap.set(token, []);
                }
                tokenMap.get(token).push(listing);
            });
        });
        const groups = [...tokenMap.entries()]
            .map(([token, arr]) => ({
                token,
                count: arr.length,
                items: arr
            }))
            .sort((a, b) => a.count - b.count);
        if (!groups.length) return [];
        const counts = groups.map(g => g.count);
        const min = counts[0];
        const second = counts[1] ?? min;
        let selectedGroups;
        if (second >= min * 2) {
            selectedGroups = [groups[0]];
        } else {
            const threshold = min * 1.5;
            selectedGroups = groups.filter(
                g => g.count <= threshold
            );
        }
        const resultSet = new Set();
        selectedGroups.forEach((g) => {
            g.items.forEach((listing) => {
                resultSet.add(listing);
            });
        });
        return [...resultSet];
    }

    function detectSponsoredListingBySpriteClass() {
        const listings = getListingElements();
        if (!listings.length) {
            return [];
        }
        const classMap = new Map();
        listings.forEach((listing) => {
            const badge = listing.querySelector(
                '.s-card__sep span[aria-labelledby]'
            );
            if (!badge) {
                return;
            }
            const activeClasses = [...badge.classList]
                .filter(cls => cls.startsWith('s-'));
            if (!activeClasses.length) {
                return;
            }
            activeClasses.forEach((cls) => {
                if (!classMap.has(cls)) {
                    classMap.set(cls, []);
                }
                classMap.get(cls).push(listing);
            });
        });

        function selectRareGroups(map) {
            const groups = [...map.entries()]
                .map(([key, items]) => ({
                    key,
                    count: items.length,
                    items
                }))
                .sort((a, b) => a.count - b.count);
            if (!groups.length) {
                return [];
            }
            const counts = groups.map(g => g.count);
            const min = counts[0];
            const second = counts[1] ?? min;
            let selectedGroups;
            if (second >= min * 2) {
                selectedGroups = [groups[0]];
            } else {
                const threshold = min * 1.5;
                selectedGroups = groups.filter(
                    g => g.count <= threshold
                );
            }
            const resultSet = new Set();
            selectedGroups.forEach((group) => {
                group.items.forEach((listing) => {
                    resultSet.add(listing);
                });
            });
            return [...resultSet];
        }
        return selectRareGroups(classMap);
    }

    function detectSponsoredListingByHomoglyph() {
        const label = {
            'Ѕ': 's',
            'А': 'a',
            'Е': 'e',
            'О': 'o',
            'Р': 'p',
            'С': 'c',
            'а': 'a',
            'е': 'e',
            'о': 'o',
            'р': 'p',
            'с': 'c',
            'ѕ': 's'
        };

        function normalizeText(c) {
            if (label[c]) return label[c];
            return c
                .normalize('NFKC')
                .replace(/[\u200B-\u200D\u061C\uFEFF\u2063]/g, '')
                .toLowerCase();
        }

        function extractText(el) {
            if (!el || !el.innerText) return [];
            return el.innerText
                .split('')
                .map(normalizeText)
                .filter(c => /^[a-z]$/.test(c));
        }

        function isSubsequence(letters, word) {
            let i = 0;
            for (const c of letters) {
                if (c === word[i]) {
                    i++;
                    if (i === word.length) return true;
                }
            }
            return false;
        }
        const sponsoredListings = [];
        document
            .querySelectorAll('li[data-viewport]')
            .forEach(li => {
                const label = li.querySelector('.su-sponsored-label');
                if (!label) return;

                const letters = extractText(label);
                if (!letters.length) return;

                if (
                    DETECT_SPONSORED_KEYWORDS.some(keyword =>
                        isSubsequence(letters, keyword)
                    )
                ) {
                    sponsoredListings.push(li);
                }
            });
        return sponsoredListings;
    }

    function detectSponsoredListingByFontGroup() {
        const listings = getListingElements();
        if (!listings.length) return new Set();
        const groups = new Map();
        const fontCache = new WeakMap();
        for (const li of listings) {
            const badgeSpan = li.querySelector('div[role="heading"] > span[aria-hidden="true"]');
            if (!badgeSpan) continue;
            const wrapper = badgeSpan.parentElement;
            if (!wrapper) continue;
            let fontFamily = fontCache.get(wrapper);
            if (!fontFamily) {
                fontFamily = getComputedStyle(wrapper).fontFamily;
                if (!fontFamily) continue;
                fontFamily = fontFamily
                    .replace(/["']/g, "")
                    .trim()
                    .toLowerCase();
                fontCache.set(wrapper, fontFamily);
            }
            if (!groups.has(fontFamily)) groups.set(fontFamily, []);
            groups.get(fontFamily).push(li);
        }
        let sponsoredGroup = null;
        let minSize = Infinity;
        for (const arr of groups.values()) {
            if (arr.length < minSize) {
                minSize = arr.length;
                sponsoredGroup = arr;
            }
        }
        return new Set(sponsoredGroup || []);
    }

    function detectSponsoredListingByTranslateY() {
        const listings = getListingElements();
        if (!listings.length) return [];
        const listingCache = new WeakMap();
        const groups = new Map();
        const translateYMap = new Map();
        for (const sheet of document.styleSheets) {
            let rules;
            try {
                rules = sheet.cssRules;
            } catch {
                continue;
            }
            if (!rules) continue;
            for (const rule of rules) {
                const sel = rule.selectorText;
                if (!sel) continue;
                const m = rule.cssText.match(/translateY\((-?\d+)\s*px\)/i);
                if (m) translateYMap.set(sel, Number(m[1]));
            }
        }
        for (const listing of listings) {
            if (listingCache.has(listing)) {
                const v = listingCache.get(listing);
                (groups.get(v) || groups.set(v, []).get(v)).push(listing);
                continue;
            }
            const span = listing.querySelector("span[role='heading']");
            if (!span) continue;
            const cls = Array.from(span.classList).find(c => c.startsWith("s-"));
            if (!cls) continue;
            const selector = `span.${cls} > div`;
            const val = translateYMap.get(selector);
            if (val == null) continue;
            listingCache.set(listing, val);
            (groups.get(val) || groups.set(val, []).get(val)).push(listing);
        }
        let sponsoredGroup = null;
        let minCount = Infinity;
        for (const [val, arr] of groups.entries()) {
            if (arr.length < minCount) {
                minCount = arr.length;
                sponsoredGroup = val;
            }
        }
        return sponsoredGroup != null ? groups.get(sponsoredGroup) : [];
    }

    function detectSponsoredListingByInvertStyle() {
        const invertStyleMatch = /div\.([a-zA-Z0-9_-]+)(?:\s+div)?\s*\{[^}]*color:\s*(black|white);[^}]*filter:\s*invert\(([-\d.]+)\)/g;
        const sponsoredGroups = {};
        const classToInvertMap = {};
        const styleTags = Array.from(document.querySelectorAll("style"));
        styleTags.forEach(styleTag => {
            const css = styleTag.textContent;
            let match;
            while ((match = invertStyleMatch.exec(css)) !== null) {
                const [_, className, color, invertValue] = match;
                if (!classToInvertMap[className]) {
                    classToInvertMap[className] = [];
                }
                classToInvertMap[className].push({
                    color,
                    invert: parseFloat(invertValue)
                });
            }
        });
        const containers = Array.from(document.querySelectorAll('div[role="text"]')).filter(container => {
            return container.querySelector('div[aria-hidden="true"]');
        });
        containers.forEach(container => {
            const targetDiv = container.querySelector('div[aria-hidden="true"]');
            if (!targetDiv) return;
            const ancestorDiv = container.closest("div[class*='_']");
            if (!ancestorDiv) return;
            const classList = Array.from(ancestorDiv.classList);
            const dynamicClass = classList.find(cls => classToInvertMap[cls]);
            if (!dynamicClass) return;
            const candidates = classToInvertMap[dynamicClass];
            const invertEntry = candidates?.[0];
            if (!invertEntry) return;
            const key = invertEntry.invert;
            if (!sponsoredGroups[key]) {
                sponsoredGroups[key] = [];
            }
            sponsoredGroups[key].push(container);
        });
        const groupEntries = Object.entries(sponsoredGroups);
        if (groupEntries.length === 0) {
            return {
                invert: null,
                elements: [],
                allGroups: []
            };
        }
        const sortedGroups = groupEntries.sort((a, b) => a[1].length - b[1].length);
        const [sponsoredInvert, sponsoredList] = sortedGroups[0];
        const sponsoredElements = sponsoredList
            .map(container => container.closest("li"))
            .filter(Boolean);
        return {
            invert: parseFloat(sponsoredInvert),
            elements: sponsoredElements,
            allGroups: groupEntries
        };
    }

    function detectSponsoredListingBySVG(batchSize = 10) {
        return new Promise((resolve) => {
            const listings = getListingElements();
            const sponsoredElements = [];
            let index = 0;

            function processBatch() {
                const end = Math.min(index + batchSize, listings.length);
                const batch = listings.slice(index, end);
                let processedInBatch = 0;
                if (batch.length === 0) {
                    resolve(sponsoredElements);
                    return;
                }
                batch.forEach((listing) => {
                    let svgDivSpan = listing.querySelector(".s-item__sep span[aria-hidden='true']");
                    let backgroundImage;
                    if (svgDivSpan) {
                        backgroundImage = getComputedStyle(svgDivSpan.parentElement).backgroundImage;
                    } else {
                        const svgDivB = listing.querySelector(".s-card__sep b[style*='data:image/svg+xml']");
                        if (!svgDivB) return done();
                        backgroundImage = getComputedStyle(svgDivB).backgroundImage;
                    }
                    const match = backgroundImage.match(/url\("data:image\/svg\+xml;base64,([^"]+)"\)/);
                    if (!match || !match[1]) return done();
                    const base64 = match[1];
                    const svgString = atob(base64);
                    const img = new Image();
                    const canvas = document.createElement("canvas");
                    const ctx = canvas.getContext("2d");
                    img.src = "data:image/svg+xml;base64," + btoa(svgString);
                    img.onload = () => {
                        canvas.width = img.naturalWidth || 20;
                        canvas.height = img.naturalHeight || 20;
                        ctx.drawImage(img, 0, 0);
                        const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
                        const colors = new Set();
                        const sampleWidth = 15;
                        const sampleHeight = 15;
                        for (let y = 0; y < sampleHeight && y < canvas.height; y++) {
                            for (let x = 0; x < sampleWidth && x < canvas.width; x++) {
                                const i = (y * canvas.width + x) * 4;
                                const r = imageData[i];
                                const g = imageData[i + 1];
                                const b = imageData[i + 2];
                                const a = imageData[i + 3];
                                if (a > 0) {
                                    colors.add(`${r},${g},${b}`);
                                    if (colors.size > 1) break;
                                }
                            }
                            if (colors.size > 1) break;
                        }
                        if (colors.size > 1) {
                            sponsoredElements.push(listing);
                        }
                        done();
                    };
                    img.onerror = done;

                    function done() {
                        processedInBatch++;
                        if (processedInBatch === batch.length) {
                            index += batchSize;
                            setTimeout(processBatch, 0);
                        }
                    }
                });
            }
            if (listings.length === 0) {
                resolve([]);
            } else {
                processBatch();
            }
        });
    }

    function designateSponsoredContent(el) {
        el.setAttribute("data-sponsored", "true");
        el.setAttribute("data-sponsored-processed", "true");
        state.ui.highlightedSponsoredContent.push(el);
    }

    function resetSponsoredContent() {
        const elements = state.ui.highlightedSponsoredContent;
        elements.forEach(el => {
            el.classList.remove("sponsored-hidden");
            el.removeAttribute("data-sponsored");
            el.removeAttribute("data-sponsored-processed");
            el.style.border = "";
            el.style.backgroundColor = "";
        });
        elements.length = 0;
    }

    function highlightSponsoredContent(element) {
        element.setAttribute("data-sponsored", "true");
        element.classList.add("sponsored-highlight");
    }

    function hideShowSponsoredContent(element, hide) {
        element.classList.toggle("sponsored-hidden", hide);
    }

    function removeSponsoredBanners(root = document) {
        if (!(root instanceof Element || root instanceof Document)) {
            return;
        }
        const banners = Array.from(
            root.querySelectorAll(
                ".s-answer-region-center-top.s-answer-region > :not(.sponsored-hidden-banner)"
            )
        ).filter(el => el.offsetHeight >= 140);
        banners.forEach(banner => {
            banner.classList.add("sponsored-hidden-banner");
        });
    }

    function removeSponsoredRibbons() {
        document.querySelectorAll('.x-breadcrumb, .x-pda-placements')
            .forEach(el => el.remove());
        const whitelisted = ['statusmessage', 'x-alert', 'x-sme-atf', 'x-vi-evo-cvip-container'];
        const ribbons = document.querySelectorAll('.x-evo-atf-top-river.vi-grid.vim > .d-vi-evo-region.vim > div');
        ribbons.forEach(ribbon => {
            const isWhitelisted = whitelisted.some(pattern =>
                ribbon.classList.value.includes(pattern)
            );
            if (!isWhitelisted) ribbon.remove();
        });
    }

    function removeSponsoredCarousels() {
        if (!determineCarouselDetection()) return;
        const SPONSORED_CAROUSEL_MEDIA_BLOCKLIST = /^https:\/\/video\.ebaycdn\.net\//i;
        const normalizeText = text =>
            text
            .trim()
            .normalize("NFKC")
            .replace(/[\u200B-\u200D\u061C\uFEFF]/g, '')
            .toLowerCase();
        const labelSponsored = carousel => {
            if (carousel.classList.contains('sponsored-hidden-carousel')) return;
            carousel.classList.add('sponsored-hidden-carousel');
            disableSiteTelemetryAttributes(carousel);
            carousel.style.display = 'none';
            carousel.querySelectorAll('video, audio, source').forEach(el => el.remove());
            carousel.querySelectorAll('[data-src], [data-video-src]').forEach(el => {
                el.removeAttribute('data-src');
                el.removeAttribute('data-video-src');
            });
            const observer = new MutationObserver(mutations => {
                for (const m of mutations) {
                    for (const node of m.addedNodes) {
                        if (!(node instanceof HTMLElement)) continue;
                        if (node.matches?.('video, audio, source')) {
                            node.remove();
                            continue;
                        }
                        node.querySelectorAll?.('video, audio, source')
                            .forEach(n => n.remove());
                    }
                }
            });
            observer.observe(carousel, {
                childList: true,
                subtree: true
            });
        };
        document
            .querySelectorAll('[class*="x-atc-layer"][class*="--ads"]')
            .forEach(el => el.remove());

        const carousels = document.querySelectorAll('[data-viewport]');
        carousels.forEach(carousel => {
            if (carousel.classList.contains('sponsored-hidden-carousel')) return;
            if (carousel.closest('.lightbox-dialog, .ux-overlay, [role="dialog"]')) return;
            const title = carousel.querySelector('h2, h3, h4');
            if (
                title &&
                DETECT_SPONSORED_KEYWORDS.some(kw =>
                    normalizeText(title.textContent).includes(kw)
                )
            ) {
                labelSponsored(carousel);
                return;
            }
            const textElements = Array.from(carousel.querySelectorAll('div, span'));
            if (
                textElements.some(el =>
                    DETECT_SPONSORED_KEYWORDS.some(kw =>
                        normalizeText(el.textContent).includes(kw)
                    )
                )
            ) {
                labelSponsored(carousel);
                return;
            }
            const characters = textElements
                .map(el => normalizeText(el.textContent))
                .filter(t => t.length === 1 && /^\p{L}$/u.test(t));

            if (
                DETECT_SPONSORED_KEYWORDS.some(kw => {
                    let i = 0;
                    for (const char of characters) {
                        if (char === kw[i]) {
                            if (++i === kw.length) return true;
                        }
                    }
                    return false;
                })
            ) {
                labelSponsored(carousel);
            }
        });
        if (!window.__ebaySponsoredMediaBlocked) {
            window.__ebaySponsoredMediaBlocked = true;
            const origFetch = window.fetch;
            window.fetch = function(input, init) {
                const url = typeof input === 'string' ? input : input?.url;
                if (
                    url &&
                    SPONSORED_CAROUSEL_MEDIA_BLOCKLIST.test(url) &&
                    document.querySelector('.sponsored-hidden-carousel')
                ) {
                    return Promise.reject();
                }
                return origFetch.call(this, input, init);
            };
            const origOpen = XMLHttpRequest.prototype.open;
            XMLHttpRequest.prototype.open = function(method, url, ...rest) {
                if (
                    url &&
                    SPONSORED_CAROUSEL_MEDIA_BLOCKLIST.test(url) &&
                    document.querySelector('.sponsored-hidden-carousel')
                ) {
                    this.abort();
                    return;
                }
                return origOpen.call(this, method, url, ...rest);
            };
        }
    }

    function disableSiteTelemetryAttributes(context = document) {
        const TELEMETRY_ATTRIBUTES_SELECTOR = '[trackableid], [trackablemoduleid]';
        const TELEMETRY_ATTRIBUTES_REGEXES = [/^data-atf/i, /^data-gr\d$/i, /^data-s-[a-z0-9]+$/i];
        const TELEMETRY_ATTRIBUTES_BLOCKLIST = new Set([
            '_sp', 'ads-tracking-metadata', 'adstrackingmetadata', 'data-hscroll', 'data-uvcc', 'data-click',
            'data-clientpresentationmetadata', 'data-config', 'data-defertimer', 'data-interactions', 'data-listingid',
            'data-operationid', 'data-pulsardata', 'data-testid', 'data-track', 'data-tracking', 'data-uvccoptoutkey',
            'data-vi-scrolltracking', 'data-vi-tracking', 'data-view', 'modulemeta', 'moduleid', 'onload', 'semantichints',
            'trackingcontext'
        ]);
        const RULESET = [{
                match: el =>
                    el.hasAttribute('trackable-id') &&
                    (el.closest('.carousel') || el.classList.contains('dp_banner_container')),
                run: el => {
                    el.removeAttribute('trackable-id');
                }
            },
            {
                match: el => el.hasAttribute('data-viewport'),
                run: el => {
                    el.setAttribute('data-viewport', '{}');
                    if (el.matches('li')) {
                        el.removeAttribute('data-listingid');
                        el.removeAttribute('data-view');
                        el.removeAttribute('id');
                    }
                    if (el.matches(TELEMETRY_ATTRIBUTES_SELECTOR)) {
                        el.removeAttribute('trackableid');
                        el.removeAttribute('trackablemoduleid');
                    }
                    const tracked = el.querySelectorAll(TELEMETRY_ATTRIBUTES_SELECTOR);
                    for (let i = 0; i < tracked.length; i++) {
                        tracked[i].removeAttribute('trackableid');
                        tracked[i].removeAttribute('trackablemoduleid');
                    }
                }
            },
            {
                match: el =>
                    el.tagName === 'INPUT' &&
                    el.type === 'hidden' &&
                    el.id &&
                    el.id.toLowerCase().startsWith('clientsideexperiments'),
                run: el => el.remove()
            },
            {
                match: el => el.tagName === 'IMG' && el.hasAttribute('onerror'),
                run: el => el.removeAttribute('onerror')
            }
        ];
        let rootNodes;
        if (isSearchResultsPage() && context === document) {
            rootNodes = document.querySelectorAll(
                '.x-header, .srp-main, .srp-main-content, .x-footer'
            );
        } else {
            rootNodes = [context];
        }
        for (const root of rootNodes) {
            const allNodes = root.querySelectorAll('*');
            for (const el of allNodes) {
                if (
                    el.closest('[class*="refine"]') ||
                    el.closest('[role="dialog"]')
                ) {
                    continue;
                }
                for (let i = 0; i < RULESET.length; i++) {
                    const rule = RULESET[i];
                    if (rule.match(el)) {
                        rule.run(el);
                    }
                }
                const attrs = el.attributes;
                for (let i = attrs.length - 1; i >= 0; i--) {
                    const name = attrs[i].name;
                    if (
                        TELEMETRY_ATTRIBUTES_BLOCKLIST.has(name) ||
                        TELEMETRY_ATTRIBUTES_REGEXES.some(rx => rx.test(name))
                    ) {
                        el.removeAttribute(name);
                    }
                }
            }
        }
    }

    function disableSiteTelemetryNetworkRequests() {
        const TELEMETRY_NETWORK_BLOCKLIST = [
            /:\/\/(?:www\.)?ebayrtm\.com\b/i,
            /:\/\/backstory\.ebay\./i,
            /:\/\/devicebind\.ebay\./i,
            /:\/\/ebay\.com\/scl\/js\/scandalloader\.js/i,
            /:\/\/ebaystatic\.com\/cr\/v\/.*\/logs.*\.bundle\.js/i,
            /:\/\/edgetrksvc\.ebay\./i,
            /:\/\/event\..*\.shoplive\.cloud/i,
            /:\/\/ir\.ebaystatic\.com\/cr\/ebay-rum\//i,
            /:\/\/ir\.ebaystatic\.com\/rs\/c\/.*tracking\//i,
            /:\/\/ir\.ebaystatic\.com\/rs\/c\/scandal\//i,
            /:\/\/pulsar\.ebay\.com/i,
            /:\/\/secureir\.ebaystatic\.com\b/i
        ];
        const loggedDomains = new Set();

        function shouldBlock(url) {
            return (
                typeof url === 'string' &&
                TELEMETRY_NETWORK_BLOCKLIST.some(rx => rx.test(url))
            );
        }

        function logOnce(url) {
            let domain;
            try {
                domain = new URL(url).hostname;
            } catch {
                domain = url;
            }
            if (!loggedDomains.has(domain)) {
                console.debug(
                    `${SCRIPT_NAME_DEBUG} v${SCRIPT_VERSION} - TELEMETRY REQUEST BLOCKED:`,
                    url
                );
                if (domain) loggedDomains.add(domain);
            }
        }

        function handleBlockedRequest(url, fallback) {
            if (!shouldBlock(url)) {
                return false;
            }
            logOnce(url);
            if (typeof fallback === 'function') {
                fallback();
            }
            return true;
        }
        const origFetch = window.fetch;
        if (origFetch) {
            window.fetch = function(resource, ...args) {
                const url = typeof resource === 'string' ? resource : resource?.url;
                if (handleBlockedRequest(url)) {
                    return Promise.reject(
                        new TypeError('blocked-telemetry-request')
                    );
                }
                return origFetch.call(this, resource, ...args);
            };
        }
        const origOpen = XMLHttpRequest.prototype.open;
        const origSend = XMLHttpRequest.prototype.send;
        XMLHttpRequest.prototype.open = function(method, url, ...args) {
            this.__telemetryBlocked = shouldBlock(url);
            this.__telemetryURL = url;
            return origOpen.call(this, method, url, ...args);
        };
        XMLHttpRequest.prototype.send = function(...args) {
            if (handleBlockedRequest(this.__telemetryURL, () => this.abort())) {
                return;
            }
            return origSend.call(this, ...args);
        };
        if (navigator.sendBeacon) {
            const origBeacon = navigator.sendBeacon;
            navigator.sendBeacon = function(url, ...args) {
                if (handleBlockedRequest(url)) {
                    return true;
                }
                return origBeacon.call(this, url, ...args);
            };
        }
    }

    function disableSiteTelemetry() {
        disableSiteTelemetryNetworkRequests(true);
    }

    function enhanceSellerInfo() {
        const listings = getListingElements();
        const hostname = window.location.hostname.replace(/^www\./, "");
        for (const listing of listings) {
            const sellerElements = listing.querySelectorAll(
                ".su-card-container__attributes__secondary .s-card__attribute-row," +
                ".s-card__program-badge-container--sellerOrStoreInfo"
            );
            for (const container of sellerElements) {
                let username, feedback, targetEl = container;
                const spans = container.querySelectorAll("span.su-styled-text");
                if (spans.length >= 2) {
                    username = spans[0].textContent.trim();
                    feedback = spans[1].textContent.trim();
                    targetEl = spans[0].parentElement;
                } else {
                    const combined = container.querySelector("span.su-styled-text.default");
                    if (!combined) continue;
                    const parts = combined.textContent.trim().split(/\s{2,}/);
                    if (parts.length < 2) continue;
                    [username, feedback] = parts;
                    const wrapper = document.createElement("span");
                    const userSpan = document.createElement("span");
                    const feedbackSpan = document.createElement("span");
                    userSpan.textContent = username;
                    feedbackSpan.textContent = feedback;
                    wrapper.append(userSpan, " ", feedbackSpan);
                    combined.replaceWith(wrapper);
                    targetEl = wrapper;
                }
                if (!username) continue;
                if (!targetEl.querySelector("a.enhanced-seller-info")) {
                    const sellerLink = document.createElement("a");
                    sellerLink.className = "enhanced-seller-info";
                    sellerLink.href = `https://${hostname}/usr/${encodeURIComponent(username)}`;
                    sellerLink.target = "_blank";
                    sellerLink.rel = "noopener noreferrer";
                    sellerLink.textContent = username;
                    targetEl.firstChild?.replaceWith(sellerLink);
                }
                const feedbackNode = targetEl.children[1];
                if (
                    feedbackNode &&
                    feedbackNode.textContent.trim() === feedback &&
                    !feedbackNode.querySelector("a.enhanced-seller-info")
                ) {
                    const feedbackLink = document.createElement("a");
                    feedbackLink.className = "enhanced-seller-info";
                    feedbackLink.href = `https://${hostname}/fdbk/feedback_profile/${encodeURIComponent(username)}`;
                    feedbackLink.target = "_blank";
                    feedbackLink.rel = "noopener noreferrer";
                    feedbackLink.textContent = feedback;
                    feedbackNode.replaceWith(feedbackLink);
                    const bullet = document.createElement("span");
                    bullet.textContent = " · ";
                    bullet.style.padding = "0 0.15em";
                    targetEl.insertBefore(bullet, feedbackLink);
                }
            }
        }
    }

    function repairSiteButtons() {
        document.addEventListener("click", function(e) {
            const button = e.target.closest(".switch__button");
            if (!button) return;
            const container = button.closest(".filter__menu--switch");
            if (!container) return;
            const input = container.querySelector('input[type="checkbox"]');
            if (!input) return;
            e.preventDefault();
            e.stopPropagation();
            input.checked = !input.checked;
            input.dispatchEvent(new Event("input", {
                bubbles: true
            }));
            input.dispatchEvent(new Event("change", {
                bubbles: true
            }));
        });
    }

    function cleanListingURLs() {
        const url = /^https:\/\/((?:[a-z0-9-]+\.)*)ebay\.([a-z.]+)\/itm\/(\d+)(?:[/?#].*)?/i;
        const links = document.querySelectorAll("a[href*='/itm/']");
        links.forEach((link) => {
            const match = link.href.match(url);
            if (match) {
                let subdomains = match[1] || "";
                const tld = match[2];
                const itemId = match[3];
                const parts = subdomains.split(".").filter(Boolean).filter(p => p !== "www");
                const subdomain = parts.length ? parts.join(".") + "." : "";
                const cleanURL = `https://${subdomain}ebay.${tld}/itm/${itemId}`;
                if (link.href !== cleanURL) {
                    link.href = cleanURL;
                }
            }
        });
    }

    function cleanGeneralURLs() {
        const observer = state.observer.generalCleanupObserver;
        if (observer) observer.disconnect();
        const TRACKING_PARAM_BLOCKLIST = [
            '_blrs', '_from', '_odkw', '_osacat', '_sacat', '_trksid', 'campaign', 'campid', 'cspheader', 'descgauge',
            'domain', 'excSoj', 'excTrk', 'iid', 'item', 'lsite', 'mkcid', 'mkevt', 'mkrid', 'oneClk', 'promoted_items',
            'rt', 'sacat', 'secureDesc', 'siteid', 'source', 'sr', 'templateId', 'toolid'
        ];
        const cleanParam = key =>
            TRACKING_PARAM_BLOCKLIST.includes(key) ||
            key.startsWith("utm_") ||
            key.startsWith("_trk");
        const skipFrames = isLiveStreamPage();
        try {
            const url = new URL(location.href);
            const params = url.searchParams;
            for (const key of Array.from(params.keys())) {
                if (cleanParam(key)) params.delete(key);
            }
            const clean = `${url.origin}${url.pathname}${url.search}${url.hash}`;
            if (clean !== location.href) {
                history.replaceState(null, "", clean);
            }
        } catch {}
        document.querySelectorAll("a[href]").forEach(link => {
            try {
                const url = new URL(link.href);
                const params = url.searchParams;
                for (const key of Array.from(params.keys())) {
                    if (cleanParam(key)) params.delete(key);
                }
                const cleanURL = `${url.origin}${url.pathname}${url.search}${url.hash}`;
                if (link.href !== cleanURL) link.href = cleanURL;
            } catch {}
        });
        if (!skipFrames) {
            document.querySelectorAll("iframe[src]").forEach(iframe => {
                try {
                    const url = new URL(iframe.src);
                    const params = url.searchParams;
                    for (const key of Array.from(params.keys())) {
                        if (cleanParam(key)) params.delete(key);
                    }
                    const cleanSrc = `${url.origin}${url.pathname}${url.search}${url.hash}`;
                    if (iframe.src !== cleanSrc) {
                        iframe.src = cleanSrc;
                    }
                } catch {}
            });
        }
        document.querySelectorAll("form").forEach(form => {
            const cleanForm = () => {
                try {
                    if (form.action) {
                        const url = new URL(form.action, location.href);
                        const params = url.searchParams;
                        for (const key of Array.from(params.keys())) {
                            if (cleanParam(key)) params.delete(key);
                        }
                        form.action = `${url.origin}${url.pathname}${url.search}${url.hash}`;
                    }
                } catch {}
                form.querySelectorAll("input[name], select[name], textarea[name]")
                    .forEach(el => {
                        if (cleanParam(el.name)) el.remove();
                    });
            };
            cleanForm();
            form.addEventListener("submit", cleanForm, true);
        });
        if (observer) {
            observer.observe(document.body, {
                subtree: true,
                childList: true
            });
        }
    }

    function cleanGeneralClutter() {
        const GENERAL_CLUTTER_SELECTORS = [
            '.d-sell-now--filmstrip-margin', '.dp-ads-module-container', '.dynamic-banner', '.madrona-banner',
            '.s-faq-list', '.s-feedback', '.srp-river-answer--CAQ_PLACEHOLDER', '.su-faqs', '.x-goldin-module',
            '[class*="EBAY_LIVE_ENTRY"]', '[class*="LIVE_EVENTS_CAROUSEL"]', '[class*="START_LISTING_BANNER"]'
        ];
        document
            .querySelectorAll(GENERAL_CLUTTER_SELECTORS.join(','))
            .forEach(el => el.remove());
        document
            .querySelectorAll('.dp-hero-live-event-module')
            .forEach(hero => {
                const container = hero.closest('.page-grid-container');
                if (container) {
                    container.remove();
                }
            });
    }

    const observer = new MutationObserver(() => {
        updatePanelVisibility();
        scheduleHighlightUpdate();
    });
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', initSanitizePageObserver);
    } else {
        initSanitizePageObserver();
    }

    window.addEventListener("storage", ({
        key,
        newValue
    }) => {
        if (!key) return;
        if (key === STORAGE_KEY_HIDE_SPONSORED) {
            const isEnabled = newValue === "true";
            if (isEnabled === state.ui.hidingEnabled) return;
            state.ui.hidingEnabled = isEnabled;
            const toggleInput = document.getElementById(
                "toggleSponsoredContentSwitch"
            );
            if (toggleInput) toggleInput.checked = isEnabled;
            updatePanelLockIcon();
            scheduleHighlightUpdate();
            return;
        }
        if (key === STORAGE_KEY_PANEL_MINIMIZED) {
            setPanelMinimized(newValue === "true");
        }
    });

    const initAfterDOM = async () => {
        init();
    };

    if (["complete", "interactive"].includes(document.readyState)) {
        initAfterDOM();
    } else {
        window.addEventListener("DOMContentLoaded", initAfterDOM);
    }

})();