Amazon URL Cleaner

Show the shortest possible URL for Amazon items.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Amazon URL Cleaner
// @description Show the shortest possible URL for Amazon items.
// @namespace   https://arantius.com/misc/greasemonkey/
// @match       https://www.amazon.com/dp/*
// @match       https://www.amazon.com/*/dp/*
// @match       https://www.amazon.com/gp/product/*
// @match       https://www.amazon.com/*/ASIN/*
// @run-at      document-start
// @version     9
// @grant       none
// @icon        https://www.amazon.com/favicon.ico
// ==/UserScript==

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

var productId = getProductId();
if (productId) {
  history.replaceState(
      {}, document.title, 'https://www.amazon.com/dp/' + productId);
}