← All examples

JavaScript Developer & QA ebay.com

eBay: show the item ID

Displays the numeric item ID as a corner badge that can be copied with a single click.

Code to copy

// Show the numeric item ID as a copyable badge on item pages
function showItemId() {
  if (document.getElementById('jz-eby-itemid')) { return; }
  const m = window.location.pathname.match(/\/itm\/(?:.*\/)?(\d{6,})/);
  if (!m) { return; }
  const badge = document.createElement('div');
  badge.id = 'jz-eby-itemid';
  badge.textContent = 'Item ID: ' + m[1];
  badge.title = 'Click to copy';
  badge.style.cssText = 'position:fixed;bottom:12px;left:12px;z-index:99999;'
    + 'background:#111;color:#fff;padding:6px 10px;border-radius:6px;'
    + 'font:600 12px sans-serif;cursor:pointer';
  badge.addEventListener('click', function () {
    if (navigator.clipboard) { navigator.clipboard.writeText(m[1]); }
    badge.textContent = 'Copied ' + m[1];
  });
  document.body.appendChild(badge);
}
showItemId();

How to use this example

  1. Copy the code with the button above.
  2. Install JustZix (2 minutes) and open the extension on the target page.
  3. Add a new rule matching that page.
  4. Paste the code into the rule's JavaScript panel and save — it runs on every page visit.

Rate this example

No ratings yet — be the first.

Does this example work?

Snippets are useless without somewhere to paste them.

JustZix takes 2 minutes to install and runs your code on every matching page. No account, no payment.

Download free See use cases