Last active
October 14, 2023 19:23
-
-
Save tecsoc/8be7b4e14d401c45003248a08fab597d to your computer and use it in GitHub Desktop.
正規URLをコピーするブックマークレット
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
javascript:(() => { | |
const canonicalLink = document.querySelector('link[rel="canonical"]'); | |
if (!canonicalLink) { | |
alert("Canonical URLが見つかりませんでした"); | |
return; | |
} | |
const textToCopy = canonicalLink.href; | |
const hiddenInput = document.createElement("input"); | |
hiddenInput.value = textToCopy; | |
document.body.appendChild(hiddenInput); | |
hiddenInput.select(); | |
document.execCommand("copy"); | |
document.body.removeChild(hiddenInput); | |
alert("Canonical URLがコピーされました: " + textToCopy); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment