Skip to content

Instantly share code, notes, and snippets.

@apstndb
Last active June 6, 2019 17:02
Show Gist options
  • Save apstndb/4d6e0b36b3f98d450bd8581ace90c4d4 to your computer and use it in GitHub Desktop.
Save apstndb/4d6e0b36b3f98d450bd8581ace90c4d4 to your computer and use it in GitHub Desktop.
Copy URL with hl=en for Google Cloud docs
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