Ebay URL Cleaner/ shorter

Show the shortest possible URL for Ebay items.

< Commentaires sur Ebay URL Cleaner/ shorter

Avis: OK - le script fonctionne, mais souffre de quelques problèmes

§
Posté le: 2024-02-29

This version fixes the endless reload loop when selecting item specifics:

// ==UserScript==
// @name        Ebay URL Cleaner/ shorter
// @description Show the shortest possible URL for Ebay items.
// @namespace   https://arantius.com/misc/greasemonkey/
// @match       https://www.ebay.com/itm/*
// @run-at      document-start
// @version     1.1
// @grant       none
// @icon        https://pages.ebay.com/favicon.ico
// ==/UserScript==

function getProductId() {
  var m;
  m = document.location.href.match(/(?:.+\/)?itm\/([^/?]+)/);
  if (m) return m[1];
}

function getVariant() {
  var m;
  m = document.location.search.match(/var=\d+/);
  if (m) return '?' + m[0];
  else return '';
}

var productId = getProductId();
if (productId) {
  var url = 'https://www.ebay.com/itm/' + productId + getVariant();
  if (location.href != url) {
    history.replaceState({}, document.title, url);
  }
}

Poster une réponse

Connectez-vous pour poster une réponse.