Skip to content

Instantly share code, notes, and snippets.

@kabo2468
Last active October 1, 2023 12:41
Show Gist options
  • Save kabo2468/c55f57b9d1e4b73caa10ffa66e8b348f to your computer and use it in GitHub Desktop.
Save kabo2468/c55f57b9d1e4b73caa10ffa66e8b348f to your computer and use it in GitHub Desktop.
Amazonのクソ長いURLを短くするuserscript
// ==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