Removes sponsored listings on the search page
当前为
// ==UserScript==
// @name eBay Sponsored Listing Remover
// @namespace http://tampermonkey.net/
// @version 1.52
// @description Removes sponsored listings on the search page
// @author sir rob
// @match *://*.ebay.com/sch/i.html?_nkw=*
// @exclude *://*.ebay.com/sch/i.html?_ssn=*
// @exclude *://*.www.ebay.com/usr/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=ebay.com
// @grant none
// @license GNU GPLv3
// ==/UserScript==
// Changelog:
// v1.0 several attempts at finding actual sponsored listings
// v1.1 first working detection, horribly unreliable and depends on..luck basically
// v1.2 first reliable working detection, marks sponsored listings in red 100% of the time
// v1.3 first version that detects and deletes sponsored listings, then deletes all of the rest of the listings as it finds a new span
// v1.4 reliably deletes sponsored listings, very slow due to how large of a delay it needed
// v1.5 solid build of much faster script, no more delay - just lock in the original span for the listing we sniff
// v1.51 fix script running when viewing user store
// v1.52 fix script running on user store again (of course I only have issues when I post the script)
(function() {
'use strict';
let refClass = null;
function initReference() {
const items = document.querySelectorAll('li.s-item');
if (items.length < 3) return;
const sponsorDiv = items[2].querySelector('div[aria-hidden="true"]');
if (!sponsorDiv) return;
const wrapper = sponsorDiv.closest('span');
if (!wrapper || !wrapper.className) return;
refClass = wrapper.className.trim();
console.log('[eBay Cleaner] refClass locked as:', refClass);
removeByReference();
}
function removeByReference() {
if (!refClass) return;
const selector = 'span.' + refClass.split(/\s+/).join('.');
document.querySelectorAll(selector).forEach(span => {
const li = span.closest('li.s-item');
if (li) {
console.log('[eBay Cleaner] Removing sponsored item by class:', li);
li.remove();
}
});
}
window.addEventListener('load', initReference);
new MutationObserver(removeByReference)
.observe(document.body, { childList: true, subtree: true });
})();