Automation for Developersbeta

Making scripts easy to run, write, and share

What is Script Kit?

How often do you avoid scripting something because it takes too much effort?

Script Kit makes it easy to create and run scripts that solve your daily problems. Create a new script from the prompt then your script opens in the editor of your choice. Write a few lines of JavaScript. Then run the script from the prompt.

Simply put, Script Kit helps you script away the friction of your day.

Key Features

  • ▪︎Launch the prompt from anywhere as part of your flow
  • ▪︎Add keyboard shortcuts with comments://Shortcut: opt a
  • ▪︎Prompt for input with:await arg("First name")
  • ▪︎Prompt for environment vars:await env("GITHUB_TOKEN")
  • ▪︎Load npm libraries:await npm("sharp")
  • ▪︎Share scripts directly from the prompt
  • ▪︎Launch scripts from a Stream Deck button
  • ▪︎Scripts behave the same in your terminal

Learn more

Script Kit includes a built-in tutorial and myriad examples are available on our discussions pages:

Featured Scripts

giphy-search

by John Lindquist

Search giphy. Paste link.

// Menu: Giphy
// Description: Search giphy. Paste link.
// Author: John Lindquist
// Twitter: @johnlindquist
let download = await npm("image-downloader")
let queryString = await npm("query-string")
let GIPHY_API_KEY = await env("GIPHY_API_KEY", {
hint: md(
`Get a [Giphy API Key](https://developers.giphy.com/dashboard/)`
),
ignoreBlur: true,
secret: true,
})
let search = q =>
`https://api.giphy.com/v1/gifs/search?api_key=${GIPHY_API_KEY}&q=${q}&limit=10&offset=0&rating=g&lang=en`
let { input, url } = await arg(
"Search giphy:",
async input => {
if (!input) return []
let query = search(input)
let { data } = await get(query)
return data.data.map(gif => {
return {
name: gif.title.trim() || gif.slug,
value: {
input,
url: gif.images.original.url,
},
preview: `<img src="${gif.images.downsized.url}" alt="">`,
}
})
}
)
let formattedLink = await arg("Format to paste", [
{
name: "URL Only",
value: url,
},
{
name: "Markdown Image Link",
value: `![${input}](${url})`,
},
{
name: "HTML <img>",
value: `<img src="${url}" alt="${input}">`,
},
])
setSelectedText(formattedLink)

image-resize

by John Lindquist

Select an image in Finder. Type option + i to resize it.

// Menu: Resize an Image
// Description: Select an image in Finder. Type option + i to resize it.
// Author: John Lindquist
// Twitter: @johnlindquist
// Shortcut: opt i
let sharp = await npm("sharp")
let imagePath = await getSelectedFile()
let width = Number(await arg("Enter width:"))
let metadata = await sharp(imagePath).metadata()
let newHeight = Math.floor(
metadata.height * (width / metadata.width)
)
let lastDot = /.(?!.*\.)/
let resizedImageName = imagePath.replace(
lastDot,
`-${width}.`
)
await sharp(imagePath)
.resize(width, newHeight)
.toFile(resizedImageName)

reddit

by John Lindquist

Browse Reddit from Script Kit

// Menu: Reddit
// Description: Browse Reddit from Script Kit
// Author: John Lindquist
// Twitter: @johnlindquist
let Reddit = await npm("reddit")
let envOptions = {
ignoreBlur: true,
hint: md(
`[Create a reddit app](https://www.reddit.com/prefs/apps)`
),
secret: true,
}
let reddit = new Reddit({
username: await env("REDDIT_USERNAME"),
password: await env("REDDIT_PASSWORD"),
appId: await env("REDDIT_APP_ID", envOptions),
appSecret: await env("REDDIT_APP_SECRET", envOptions),
userAgent: `ScriptKit/1.0.0 (https://scriptkit.com)`,
})
let subreddits = [
"funny",
"aww",
"dataisbeautiful",
"mildlyinteresting",
"RocketLeague",
]
subreddits.forEach(sub => {
onTab(sub, async () => {
let url = await arg(
"Select post to open:",
async () => {
let best = await reddit.get(`/r/${sub}/hot`)
return best.data.children.map(({ data }) => {
let {
title,
thumbnail,
url,
subreddit_name_prefixed,
preview,
} = data
let resolutions =
preview?.images?.[0]?.resolutions
let previewImage =
resolutions?.[resolutions?.length - 1]?.url
return {
name: title,
description: subreddit_name_prefixed,
value: url,
img: thumbnail,
...(previewImage && {
preview: md(`
![${title}](${previewImage})
### ${title}
`),
}),
}
})
}
)
exec(`open "${url}"`)
})
})