Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jeduan
Created February 9, 2020 10:27
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 jeduan/1bfe9e9cad4763d3f735cd3f079cffd8 to your computer and use it in GitHub Desktop.
Save jeduan/1bfe9e9cad4763d3f735cd3f079cffd8 to your computer and use it in GitHub Desktop.
PokeAPI Launchbar Action
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconFile</key>
<string>com.spotify.client</string>
<key>LBTextInputTitle</key>
<string>Spotify</string>
<key>CFBundleIdentifier</key>
<string>com.kyleacarson.LaunchBar.action.SearchSpotify</string>
<key>CFBundleName</key>
<string>Search Spotify</string>
<key>CFBundleVersion</key>
<string>2.0</string>
<key>LBDescription</key>
<dict>
<key>LBAuthor</key>
<string>Kyle Carson</string>
<key>LBSummary</key>
<string>Search Spotify (with predictions!)</string>
<key>LBTwitter</key>
<string>@kyleacarson</string>
</dict>
<key>LBScripts</key>
<dict>
<key>LBSuggestionsScript</key>
<dict>
<key>LBLiveFeedbackEnabled</key>
<true/>
<key>LBScriptName</key>
<string>suggestion.js</string>
<key>LBBackgroundKillEnabled</key>
<true/>
</dict>
<key>LBDefaultScript</key>
<dict>
<key>LBScriptName</key>
<string>default.js</string>
</dict>
</dict>
<key>LBAssociatedApplication</key>
<string>com.spotify.client</string>
<key>LBArgument</key>
<string>songs, artists, albums</string>
<key>LBRequiresArgument</key>
<true/>
<key>LBResult</key>
<string>opens Spotify</string>
<key>LBAcceptedArgumentTypes</key>
<array>
<string>string</string>
</array>
</dict>
</plist>
function runWithString(string) {
const query = encodeURIComponent(string)
const url = `https://pokeapi.co/api/v2/pokemon/${query}`
const result = HTTP.getJSON(url);
if (!result.data) {
return [];
}
const data = [
`Name: ${result.data.name}`,
`Number: ${result.data.id}`,
];
const types = result.data.types;
if (types) {
const arr = [];
for (type of types) {
arr.push(type.type.name);
}
data.push(`Type: ${arr.join(' / ')}`);
}
return data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment