Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name eBay Seller Orders - Message Buyer Shortcut
- // @namespace ebay-message-buyer
- // @version 1.0
- // @description Adds a legacy "Message Buyer" link to each eBay order block on the seller sold orders page
- // @match https://www.ebay.com/sh/ord/*
- // @match https://www.ebay.com/sh/ord
- // @grant none
- // ==/UserScript==
- (function () {
- 'use strict';
- function insertMessageBuyerLinks() {
- const orderRows = document.querySelectorAll("tr[id^='orderid_']");
- orderRows.forEach(row => {
- try {
- const itemIdElem = row.querySelector(".order-line-actions");
- const buyerElem = row.querySelector(".buyer-modal-trigger-wrapper button span:last-child");
- if (!itemIdElem || !buyerElem) return;
- const itemId = itemIdElem.dataset.itemid;
- const username = buyerElem.textContent.trim();
- if (!itemId || !username) return;
- const messageUrl = `https://www.ebay.com/contact/sendmsg?recipient=${encodeURIComponent(username)}&message_type_id=14&item_id=${encodeURIComponent(itemId)}`;
- // Create the link
- const link = document.createElement("a");
- link.href = messageUrl;
- link.textContent = "Message Buyer";
- link.target = "_blank";
- link.style.display = "inline-block";
- link.style.marginBottom = "6px";
- link.style.fontWeight = "bold";
- // Insert above the order-status block
- const orderStatusDiv = row.querySelector(".order-status");
- if (orderStatusDiv) {
- orderStatusDiv.parentNode.insertBefore(link, orderStatusDiv);
- }
- } catch (e) {
- console.error("Message Buyer Insert Error:", e);
- }
- });
- }
- // Run once DOM is ready
- const observer = new MutationObserver((_, obs) => {
- if (document.querySelector("tr[id^='orderid_']")) {
- insertMessageBuyerLinks();
- obs.disconnect();
- }
- });
- observer.observe(document.body, { childList: true, subtree: true });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement