コトバノウタカタ

よしなしごとをつらつらとつづるばしょ。

Amazonリンクを短く。prime videoにも対応。

javascript: (function () {
    w = window;
    t = location.href;
    p = t.match(/(\/dp\/|\/ASIN\/|\/product\/)([a-zA-Z0-9]+)[\/\?]?/);
    if (p == null) {
        p = t.match(/(\/detail\/)([a-zA-Z0-9]+)\//);
        if (p == null){
            alert('no dp, ASIN or product');
            return;
        }
    }
    x = w.prompt('URL ','http://www.amazon.co.jp/dp/'+p[2]);
if (x =='' || x == null) {
        return;
    }
    w.location.href = x;
}
())