Skip to content

Instantly share code, notes, and snippets.

@error9900
Last active March 27, 2025 17:22
Show Gist options
  • Save error9900/a88650bba0f9b6a96d4c31ad9aa9d05d to your computer and use it in GitHub Desktop.
Save error9900/a88650bba0f9b6a96d4c31ad9aa9d05d to your computer and use it in GitHub Desktop.
Miscellaneous bits of JavaScript potentially useful for bookmarklets
// https://en.wikipedia.org/wiki/Bookmarklet
// https://en.wikipedia.org/wiki/URL#Syntax
// https://developer.mozilla.org/en-US/docs/Web/API/Location
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard
// Clean URL
// Copy just the origin and pathname from the current URL to the clipboard,
// then browse to that "clean" URL, i.e. remove query(s) and fragment(s)
javascript:clean_url=location.origin+location.pathname;navigator.clipboard.writeText(clean_url);location.href=clean_url;false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment