WebページのタイトルとURLをワンクリックでコピーするBookmarklet https://qiita.com/xshoji/items/93d5345d4bf282f60817
Last active
June 6, 2019 17:02
-
-
Save apstndb/4d6e0b36b3f98d450bd8581ace90c4d4 to your computer and use it in GitHub Desktop.
Copy URL with hl=en for Google Cloud docs
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: | |
var global = window; | |
global.COPY_TO_CLIPBOARD = global.COPY_TO_CLIPBOARD || {}; | |
global.COPY_TO_CLIPBOARD.getUrl = function () { | |
let url = new URL(location.href); | |
url.searchParams.set("hl", "en"); | |
return url.href; | |
}; | |
global.COPY_TO_CLIPBOARD.copyToClipboard = function() { | |
var copyFrom = document.createElement("textarea"); | |
copyFrom.textContent = this.getUrl(); | |
var bodyElm = document.getElementsByTagName("body")[0]; | |
bodyElm.appendChild(copyFrom); | |
copyFrom.select(); | |
var retVal = document.execCommand('copy'); | |
bodyElm.removeChild(copyFrom); | |
return retVal; | |
}; | |
global.COPY_TO_CLIPBOARD.copyToClipboard(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment