Last active
October 1, 2023 12:41
-
-
Save kabo2468/c55f57b9d1e4b73caa10ffa66e8b348f to your computer and use it in GitHub Desktop.
Amazonのクソ長いURLを短くするuserscript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name amazon_short_url | |
// @description Amazon URL Shorter | |
// @namespace amazon_short_url | |
// @match https://www.amazon.co.jp/* | |
// @version 2 | |
// ==/UserScript== | |
(function () { | |
const asin = document.getElementById('ASIN'); | |
const title = document.getElementById('title_feature_div'); | |
if (asin) { | |
const link = document.createElement('a'); | |
const url = 'https://amazon.jp/dp/' + asin.value; | |
link.setAttribute('href', 'javascript:void(0)'); | |
link.appendChild(document.createTextNode(url)); | |
link.addEventListener('click', () => { | |
navigator.clipboard | |
.writeText(url) | |
.then(() => alert('コピーしました。')) | |
.catch((e) => alert('コピーできませんでした。\n' + e)); | |
}); | |
const add = document.getElementById('centerCol'); | |
add.insertBefore(link, title); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment