eBay Extras

Replaces default navigation buttons, adds a notification bar when searching for 'US only' or when searching for 'Sold items', removes certain ads

目前為 2021-08-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            eBay Extras
// @version         1.2
// @description     Replaces default navigation buttons, adds a notification bar when searching for 'US only' or when searching for 'Sold items', removes certain ads
// @author          asheroto
// @license         MIT
// @icon            https://www.ebay.com/favicon.ico
// @match           https://*.ebay.com/*
// @namespace       https://greasyfork.org/en/scripts/388337-ebay-extras
// @grant           GM_addElement
// ==/UserScript==

// ==OpenUserScript==
// @author          asheroto
// ==/OpenUserScript==

/* jshint esversion: 6 */

(function () {
  // Insert nav buttons function
  function addLink(text, url) {
    let bodChild = document.createElement("li");
    bodChild.classList.add("gh-t");
    bodChild.classList.add("gh-divider-l");
    bodChild.id = "gh-p-3";
    bodChild.innerHTML = '<a href="' + url + '" class="gh-p"> ' + text + "</a>";
    document.getElementById("gh-p-3").parentNode.insertBefore(bodChild, document.getElementById("gh-p-3").nextSibling);
  }

  // Insert nav buttons
  addLink("Orders", "https://www.ebay.com/sh/ord/?filter=status:ALL_ORDERS");
  addLink("Active Listings", "https://www.ebay.com/sh/lst/active");
  addLink("Purchases", "https://www.ebay.com/myb/PurchaseHistory");
  addLink("Watch List", "https://www.ebay.com/myb/WatchList");
  addLink("Messages", "https://mesg.ebay.com/mesgweb/ViewMessages/0");
  let userId = document.body.innerHTML.match(/id:"(.*?)"}/);
  if (userId) {
    let userFeedbackId = userId[1];
    addLink("My Feedback", "https://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&ftab=AllFeedback&userid=" + userFeedbackId);
  }
  addLink("Leave Feedback", "https://www.ebay.com/fdbk/leave_feedback");
  addLink("Account Settings", "https://my.ebay.com/ws/eBayISAPI.dll?MyEbay&CurrentPage=MyeBayMyAccounts&ssPageName=STRK:ME:MAX");

  // Remove buttons
  document.getElementById("gh-p-4").style.display = "none";
  document.getElementById("gh-p-1").style.display = "none";
  document.getElementById("gh-p-3").style.display = "none";

  // Function for top bar
  function addTopBar(atext) {
    let elChild = document.createElement("div");
    elChild.style.background = "black";
    elChild.style.color = "white";
    elChild.innerHTML = "<center><font size=4>" + atext + "</font></center>";
    document.body.insertBefore(elChild, document.body.firstChild);
  }
  // Notify if searching US only
  if (window.location.toString().includes("LH_PrefLoc=1")) {
    addTopBar("Showing items from USA");
  }

  // Notify if searching sold items
  if (window.location.toString().includes("LH_Sold=1")) {
    addTopBar("Showing Sold + Completed Items");
  }

  window.onload = function () {
    // Remove ads
    let ad1 = document.getElementById("gh-ti");
    if (ad1) {
      try {
        ad1.remove();
      }
      catch (err) {}
    }
    let ad2 = document.getElementsByClassName("topRtm")[0];
    if (ad2) {
      try {
        ad2.remove();
      }
      catch (err) {}
    }
    let ad3 = document.getElementsByClassName("hl-leaderboard-ad")[0];
    if (ad3) {
      try {
        ad3.remove();
      }
      catch (err) {}
    }
    let ad4 = document.getElementsByClassName("leaderboard_ad");
    if (ad4) {
      try {
        ad4[0].remove();
      }
      catch (err) {}
    }
    let ad5 = document.getElementById("myEbayBody");
    if (ad5) {
      try {
        ad5.firstChild.nextSibling.remove();
      }
      catch (err) {}
    }
    let ad6 = document.getElementsByClassName("vi-lb-placeholder");
    if (ad6) {
      try {
        ad6[0].remove();
      }
      catch (err) {}
    }
  };
})();