eBay Watch

Add to watch list directly from eBay search result + Stop redirecting to similar item + Remove the sponsor items

目前為 2023-02-12 提交的版本,檢視 最新版本

// ==UserScript==
// @name         eBay Watch
// @namespace    eBay
// @version      1.6.0
// @description  Add to watch list directly from eBay search result + Stop redirecting to similar item + Remove the sponsor items
// @author       denis hebert
// @license      GNU GPL-3.0-or-later
// @match        *://*/mye/*
// @match        *://*/itm/*
// @match        *://*/sch/i.html*
// @match        *://*/d/*
// @run-at       document-end
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ebay.ca
// @grant        none
// ==/UserScript==

'use strict';

(function(w, d, list, n, i, e) {
    // If we're in our named pop-up window (made by clicking any "Add to watch list" in search page - see building of them in the code just below this if)
    if (w.name === "eBay item to watch") { // if it's our temporary named window containing an item
        d.getElementById("atl_btn").click(); // Activate the item "Add to watch list"
        w.close(); // Close that temporary window
    }
    // Add an "Add to watch list" link for each item of the page
    list = d.getElementsByClassName("SECONDARY_INFO");
    n = list.length;
    for (i = 0; i < n; i++)
        list[i].innerHTML += " <a target='eBay item to watch' href='" + list[i].parentNode.previousSibling.href + "'>Add to watch list</a>";
    // Add a No redirecting to similar item at the end of all item href found
    list = d.getElementsByTagName("a");
    n = list.length;
    for (i = 0; i < n; i++) {
        e = list[i];
        if ( "href" in e && e.href.includes("/itm/") )
            e.href += (e.href.includes("?") ? "&" : "?") + "nordt=true#CenterPanelInternal";
    }
    // Remove sponsors when they come
    e = new MutationObserver(function(list, n, i) {
        list = d.querySelectorAll("[id^='placement']");
        n = list.length;
        for (i = 0; i < n; i++)
            list[i].remove();
    });
    e.observe(d, {childList: true, subtree:true});
})(window, document);