Skip to content

Instantly share code, notes, and snippets.

@nawada
Created June 23, 2020 06:26
Show Gist options
  • Save nawada/2a05cef44128d0c908568fd3524cb648 to your computer and use it in GitHub Desktop.
Save nawada/2a05cef44128d0c908568fd3524cb648 to your computer and use it in GitHub Desktop.
var newUrl=new URL(location);
newUrl.hash=`:~:text=${encodeURIComponent(getSelection().toString())}`;
var input=document.createElement('input');
input.value=newUrl;
document.querySelector('body').appendChild(input);
input.select();
document.execCommand('copy');
input.remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment