0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

amazonの商品ページURLをトリミングしてクリップボードにコピーするBookmarklet

Last updated at Posted at 2018-12-30

Amazonの商品ページのURLは醜い

他の人にそのまま投げつけようものなら迷惑がられるので、その際は商品名などが入ったURLパス部分や無くても問題ないパラメーター部分を消してから送るのが社会人としてのマナーだ

しかし平成も終わるというのに手動でやるのは面倒だし冬休みで暇なのでブックマークレットを作ってみた。(平成も終わるのにブックマークレットかよというのは一旦忘れよう)

以下をBookmarkletとして登録して、Amazonの商品ページに行って発動させるとトリミングされたURLがクリップボードにコピーされた状態になる

javascript: var ta = document.createElement('textarea');var reg = /(www.amazon.[a-z]+.?[a-z]*)\/(.*?)\//;var fp = location.href.match(reg)[2];console.log(fp);if (fp.match(/%/)) {  ta.value = location.href.replace(reg, '$1/').replace(/[a-z]+=.*$/, '');} else {  ta.value = location.href.match(/.*[\/|?]/)[0].replace(/\?/, '');}document.body.appendChild(ta);ta.select();document.execCommand('copy');ta.parentElement.removeChild(ta);

一応GitHubであげといたのでバグ等あったらIssueなりPRなりいただけると幸いです。
https://github.com/s-ichikawa/amazon-url-trimmer

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?