Skip to content

Instantly share code, notes, and snippets.

@adam-zethraeus
Last active September 10, 2020 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam-zethraeus/a44fc966758a4c90facb8098233cb48a to your computer and use it in GitHub Desktop.
Save adam-zethraeus/a44fc966758a4c90facb8098233cb48a to your computer and use it in GitHub Desktop.
a bookmarklet to copy a url to the current page, with the current selection highlighted. (Chrome only. Because other browser care about timing attacks more than your Google search result experience.)
javascript:
let tempInput = document.createElement("input");
tempInput.value = window.location.href + `#:~:text=${window.getSelection().toString()}`;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment