├── .gitignore ├── LICENSE.md ├── README.md ├── build └── scryfall.alfredworkflow ├── docs ├── hotkey.png ├── screenshot-w.png └── screenshot-wo.png ├── icon.png ├── img └── o.O.jpg ├── index.js ├── info.plist └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Chuck Harmston and the Scryfall team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # scion 2 | 3 | An Alfred worklow to quickly search for Magic cards on [Scryfall](https://www.scryfall.com). 4 | 5 | [![Download 1.0.0](https://img.shields.io/badge/download-v1.1.1-green.svg)](https://raw.githubusercontent.com/scryfall/scion/master/build/scryfall.alfredworkflow) 6 | 7 | ## Features 8 | 9 | After installing the workflow, type `mtg ` (with the space), followed by your search: 10 | 11 | ![Example search for "bolt"](docs/screenshot-wo.png) 12 | 13 | Optionally, go to the Alfred preferences and add a hotkey: 14 | 15 | ![Adding a hotkey](docs/hotkey.png) 16 | 17 | When invoked, the hotkey will then let you skip the prefix and start searching immediately: 18 | 19 | ![Example search for "Niv-Mizzet", invoked from the hotkey](docs/screenshot-w.png) 20 | -------------------------------------------------------------------------------- /build/scryfall.alfredworkflow: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scryfall/scion/3cac33b1f0cfe8be7e5280da2fe43e5c59f3b89a/build/scryfall.alfredworkflow -------------------------------------------------------------------------------- /docs/hotkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scryfall/scion/3cac33b1f0cfe8be7e5280da2fe43e5c59f3b89a/docs/hotkey.png -------------------------------------------------------------------------------- /docs/screenshot-w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scryfall/scion/3cac33b1f0cfe8be7e5280da2fe43e5c59f3b89a/docs/screenshot-w.png -------------------------------------------------------------------------------- /docs/screenshot-wo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scryfall/scion/3cac33b1f0cfe8be7e5280da2fe43e5c59f3b89a/docs/screenshot-wo.png -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scryfall/scion/3cac33b1f0cfe8be7e5280da2fe43e5c59f3b89a/icon.png -------------------------------------------------------------------------------- /img/o.O.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scryfall/scion/3cac33b1f0cfe8be7e5280da2fe43e5c59f3b89a/img/o.O.jpg -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const alfy = require('alfy'); 3 | const URI = require('urijs'); 4 | 5 | const ONE_HOUR = 1000 * 60 * 60; 6 | 7 | const formatURI = uri => { 8 | return new URI(uri).setSearch({ 9 | 'utm_source': 'alfred' 10 | }).toString(); 11 | } 12 | 13 | const Q = alfy.input.replace(/\++/g, '').trim(); 14 | const API_URL = new URI('https://api.scryfall.com/cards/search').setSearch('q', Q).toString(); 15 | const AUTOCOMPLETE_URL = new URI('https://api.scryfall.com/cards/autocomplete').setSearch('q', Q).toString(); 16 | const SEARCH_URL = formatURI(new URI('https://www.scryfall.com/search').setSearch('q', Q).toString()); 17 | 18 | const EMPTY = [{ 19 | title: '¯\\_(ツ)_/¯', 20 | subtitle: `Hellbent: no cards matching "${Q}".`, 21 | arg: SEARCH_URL, 22 | quicklookurl: SEARCH_URL 23 | }]; 24 | 25 | const SEARCH = [{ 26 | uid: `on-site-${Q}`, 27 | title: 'Search on Scryfall', 28 | arg: SEARCH_URL, 29 | quicklookurl: SEARCH_URL 30 | }]; 31 | 32 | const formatFullCard = card => { 33 | const output = { 34 | uid: card.id, 35 | title: card.name, 36 | arg: formatURI(card.scryfall_uri), 37 | quicklookurl: formatURI(card.scryfall_uri), 38 | autocomplete: card.name 39 | }; 40 | if (card.name === 'Amoeboid Changeling') { 41 | output.icon = { path: 'img/o.O.jpg' }; 42 | } 43 | return output; 44 | } 45 | 46 | const formatAbbreviatedCard = card => { 47 | const QUERY = encodeURI(`!"${card}"`); 48 | const URL = formatURI(`https://scryfall.com/search?q=${QUERY}`); 49 | const output = { 50 | uid: URL, 51 | title: card, 52 | arg: URL, 53 | quicklookurl: URL, 54 | autocomplete: card 55 | }; 56 | if (card === 'Amoeboid Changeling') { 57 | output.icon = { path: 'img/o.O.jpg' }; 58 | } 59 | return output; 60 | } 61 | 62 | if ( 63 | /\S[:=<>]+\S/g.test(Q) || 64 | /[\(\)|!]+/g.test(Q) 65 | ) { 66 | alfy.fetch(API_URL, { maxAge: ONE_HOUR }) 67 | .then(results => { 68 | if (results.object === "error") { 69 | alfy.output(EMPTY); 70 | } else { 71 | alfy.output(SEARCH.concat(results.data.slice(0, 10).map(formatFullCard))); 72 | } 73 | }) 74 | .catch(err => { 75 | alfy.output(EMPTY); 76 | }); 77 | } else { 78 | alfy.fetch(AUTOCOMPLETE_URL, { maxAge: ONE_HOUR }) 79 | .then(results => { 80 | if (results.object === "error") { 81 | alfy.output(EMPTY); 82 | } else { 83 | alfy.output(SEARCH.concat(results.data.slice(0, 10).map(formatAbbreviatedCard))); 84 | } 85 | }) 86 | .catch(err => { 87 | alfy.output(EMPTY); 88 | }); 89 | } 90 | -------------------------------------------------------------------------------- /info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleid 6 | com.scryfall.scion 7 | category 8 | Internet 9 | connections 10 | 11 | 2F85EFC9-6FF0-4B4F-A429-A25A72047F47 12 | 13 | 14 | destinationuid 15 | 81AAE853-6128-49A5-9C89-9D796BA3996A 16 | modifiers 17 | 0 18 | modifiersubtext 19 | 20 | vitoclose 21 | 22 | 23 | 24 | 81AAE853-6128-49A5-9C89-9D796BA3996A 25 | 26 | 27 | destinationuid 28 | 121520B1-E7AF-4C37-B5D0-A94E9A9A0676 29 | modifiers 30 | 0 31 | modifiersubtext 32 | 33 | vitoclose 34 | 35 | 36 | 37 | 38 | createdby 39 | Scryfall 40 | description 41 | Search for MTG cards 42 | disabled 43 | 44 | name 45 | Scryfall 46 | objects 47 | 48 | 49 | config 50 | 51 | action 52 | 0 53 | argument 54 | 0 55 | hotkey 56 | 46 57 | hotmod 58 | 1441792 59 | hotstring 60 | M 61 | leftcursor 62 | 63 | modsmode 64 | 0 65 | relatedAppsMode 66 | 0 67 | 68 | type 69 | alfred.workflow.trigger.hotkey 70 | uid 71 | 2F85EFC9-6FF0-4B4F-A429-A25A72047F47 72 | version 73 | 2 74 | 75 | 76 | config 77 | 78 | browser 79 | 80 | spaces 81 | 82 | url 83 | {query} 84 | utf8 85 | 86 | 87 | type 88 | alfred.workflow.action.openurl 89 | uid 90 | 121520B1-E7AF-4C37-B5D0-A94E9A9A0676 91 | version 92 | 1 93 | 94 | 95 | config 96 | 97 | alfredfiltersresults 98 | 99 | argumenttype 100 | 0 101 | escaping 102 | 102 103 | keyword 104 | mtg 105 | queuedelaycustom 106 | 3 107 | queuedelayimmediatelyinitially 108 | 109 | queuedelaymode 110 | 0 111 | queuemode 112 | 2 113 | runningsubtext 114 | Searching the city... 115 | script 116 | ./node_modules/.bin/run-node index.js "$1" 117 | scriptargtype 118 | 1 119 | scriptfile 120 | index.js 121 | subtext 122 | Search MTG cards 123 | title 124 | Scryfall 125 | type 126 | 0 127 | withspace 128 | 129 | 130 | type 131 | alfred.workflow.input.scriptfilter 132 | uid 133 | 81AAE853-6128-49A5-9C89-9D796BA3996A 134 | version 135 | 2 136 | 137 | 138 | readme 139 | 140 | uidata 141 | 142 | 121520B1-E7AF-4C37-B5D0-A94E9A9A0676 143 | 144 | xpos 145 | 510 146 | ypos 147 | 230 148 | 149 | 2F85EFC9-6FF0-4B4F-A429-A25A72047F47 150 | 151 | xpos 152 | 250 153 | ypos 154 | 230 155 | 156 | 81AAE853-6128-49A5-9C89-9D796BA3996A 157 | 158 | xpos 159 | 380 160 | ypos 161 | 230 162 | 163 | 164 | webaddress 165 | https://www.scryfall.com 166 | 167 | 168 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "alfred-scion", 3 | "version": "1.1.1", 4 | "description": "Workflow to search MTG cards on Scryfall.", 5 | "license": "MIT", 6 | "repository": "scryfall/scion", 7 | "author": { 8 | "name": "Scryfall", 9 | "url": "https://scryfall.com" 10 | }, 11 | "engines": { 12 | "node": ">=4" 13 | }, 14 | "scripts": { 15 | "postinstall": "alfy-init", 16 | "preuninstall": "alfy-cleanup" 17 | }, 18 | "keywords": [ 19 | "alfred", 20 | "workflow", 21 | "mtg", 22 | "scryfall", 23 | "magic" 24 | ], 25 | "dependencies": { 26 | "alfy": "^0.5.0" 27 | } 28 | } 29 | --------------------------------------------------------------------------------