Create a bookmarklet

Bookmarklets are snippets of code that can be saved as a bookmark. Use them to extract data, modify the appearance or change the behavior of a website. Convert, minify and wrap JavaScript code to create a bookmarklet.

Face with waiting expression Nothing to see yet!

Loading takeymakey...
TakeyMakey code
Want this tool to do something else? Edit the code below and make it do whatever you want.
export const take = [
  { type: "code", label: "Bookmarklet code" },
  { type: "toggle", label: "Wrap code", value: true },
  { type: "toggle", label: "Minify JS", value: true },
  { type: "text", label: "Title", value: "Bookmarklet", inline: true },
  {
    type: "script",
    value: "https://cdn.jsdelivr.net/npm/terser/dist/bundle.min.js",
  },
]

export const make = async ([code, wrap, minify, title]) => {
  if (!code) return

  if (wrap) code = `(function(){${code}})()`
  if (minify) code = (await Terser.minify(code)).code

  const value = `javascript:${encodeURIComponent(code)}`
  const label = "Drag this link into your bookmarks"

  return [
    { type: "code", value },
    { type: "link", label, value: { href: value, text: title } },
  ]
}