Skip to content

Instantly share code, notes, and snippets.

@astronasutarou
Last active January 9, 2023 21:39
Show Gist options
  • Save astronasutarou/8bf7ba454e12dc81822ac5fe21b3af1a to your computer and use it in GitHub Desktop.
Save astronasutarou/8bf7ba454e12dc81822ac5fe21b3af1a to your computer and use it in GitHub Desktop.
amazon.co.jp の url から余分なものを取り去って綺麗にする
// ==UserScript==
// @name Amazon URL Cleaner
// @namespace http://xr0038.net
// @description Clean Amazon item URL
// @include http://www.amazon.co.jp*/dp/*
// @include https://www.amazon.co.jp*/dp/*
// @include http://www.amazon.co.jp*/gp/*
// @include https://www.amazon.co.jp*/gp/*
// @run-at document-start
// @version 1.2
// ==/UserScript==
if (document.URL.match(/(dp|gp\/product)\/[A-Z0-9]{10}/g)) {
var newurl = document.URL.match(/https?:\/\/(|www\.)amazon\.(.+?)\//g) + document.URL.match(/(dp|gp\/product)\/[A-Z0-9]{10}/g);
console.log(newurl);
if (newurl != document.URL) location.replace(newurl);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment