Created
February 9, 2020 10:27
-
-
Save jeduan/1bfe9e9cad4763d3f735cd3f079cffd8 to your computer and use it in GitHub Desktop.
PokeAPI Launchbar Action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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