-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
info.plist
232 lines (218 loc) · 7.26 KB
/
info.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?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>bundleid</key>
<string>zarifpour.yousuggest</string>
<key>category</key>
<string>Internet</string>
<key>connections</key>
<dict>
<key>B2496DEF-C902-4D76-BD7C-DC86D9DB4C04</key>
<array>
<dict>
<key>destinationuid</key>
<string>882A5947-06A0-49ED-8443-D55F88AEF74A</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>createdby</key>
<string>Daniel Zarifpour</string>
<key>description</key>
<string>Get in-line You.com search suggestions</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>You.com Suggest</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>browser</key>
<string></string>
<key>skipqueryencode</key>
<false/>
<key>skipvarencode</key>
<false/>
<key>spaces</key>
<string></string>
<key>url</key>
<string>https://you.com/search?q={query}</string>
</dict>
<key>type</key>
<string>alfred.workflow.action.openurl</string>
<key>uid</key>
<string>882A5947-06A0-49ED-8443-D55F88AEF74A</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<true/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>1</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>{var:search_keyword}</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<true/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string>Getting suggestions…</string>
<key>script</key>
<string>// Define a function to create Alfred items from an array of suggestion names
function makeItems(itemNames) {
return itemNames.map(name => {
// Each item has a unique ID, a title that matches the suggestion name, a subtitle that indicates the search term and the search engine, and an argument that contains the suggestion name
return {
"uid": name,
"title": name,
"subtitle": "Search “" + name + "” on you.com",
"arg": name
}
})
}
// Retrieve the previous search term and suggestions from Alfred's environment variables
const oldArg = $.NSProcessInfo.processInfo.environment.objectForKey("oldArg").js
const oldResults = $.NSProcessInfo.processInfo.environment.objectForKey("oldResults").js
// Define the main function that generates the list of suggestions for Alfred
function run(argv) {
// If the user did not type anything, return an empty list of suggestions
if (!argv[0]) {
return JSON.stringify({ "items": [] })
}
// If the user is currently typing, return the previous suggestions as well as the new ones from the current search
if (argv[0] !== oldArg) {
return JSON.stringify({
// Rerun the script in 0.1 seconds to guarantee that the top suggestion matches the current query
"rerun": 0.1,
// Skip the default knowledge results and show only the script's output
"skipknowledge": true,
// Store the previous suggestions and search term in the environment variables for later use
"variables": { "oldResults": oldResults, "oldArg": argv[0] },
// Combine the previous suggestions and new ones from the current search, remove duplicates, and generate Alfred items from them
"items": makeItems(argv.concat(oldResults?.split("\n").filter(line => line)))
})
}
// If the user is not currently typing, make a request to the you.com autocomplete API to retrieve new suggestions
const encodedQuery = encodeURIComponent(argv[0])
const queryURL = $.NSURL.URLWithString(`https://you.com/api/ac?q=${encodedQuery}`)
const requestData = $.NSData.dataWithContentsOfURL(queryURL);
const requestString = $.NSString.alloc.initWithDataEncoding(requestData, $.NSUTF8StringEncoding).js
const newResults = JSON.parse(requestString)[1].filter(result => result !== argv[0])
// Return the new suggestions as Alfred items, and store them along with the current search term in the environment variables for later use
return JSON.stringify({
// Skip the default knowledge results and show only the script's output
"skipknowledge": true,
// Store the new suggestions and search term in the environment variables for later use
"variables": { "oldResults": newResults.join("\n"), "oldArg": argv[0] },
// Generate Alfred items from the new suggestions
"items": makeItems(argv.concat(newResults))
})
}
</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string>Search You.com with suggestions</string>
<key>title</key>
<string>Search You.com</string>
<key>type</key>
<integer>7</integer>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>B2496DEF-C902-4D76-BD7C-DC86D9DB4C04</string>
<key>version</key>
<integer>3</integer>
</dict>
</array>
<key>readme</key>
<string># Usage
Get in-line suggestions from [You.com](https://you.com)'s search results via the Search Keyword (default: `y`). Press <kbd>↩</kbd> to open the search results page with the default web browser.
![you-workflow.png](/resources/you-workflow.png)
# Setup
1. Go to **Alfred Preferences**.
2. Open the **Workflows** tab.
3. Select **You.com Suggest**.
4. Click **Configure Workflow...** to set the Search Keyword.
# Credits
This workflow is inspired by the [Google Suggest](https://alfred.app/workflows/alfredapp/google-suggest/) workflow created by Vítor Galvão.
"This workflow was adapted with the help of ChatGPT, a large language model trained by OpenAI. ChatGPT provided guidance and support during the development process."
---
Adapted with ❤️ by [Daniel Zarifpour](https://links.dev/z).</string>
<key>uidata</key>
<dict>
<key>882A5947-06A0-49ED-8443-D55F88AEF74A</key>
<dict>
<key>xpos</key>
<real>315</real>
<key>ypos</key>
<real>230</real>
</dict>
<key>B2496DEF-C902-4D76-BD7C-DC86D9DB4C04</key>
<dict>
<key>xpos</key>
<real>125</real>
<key>ypos</key>
<real>230</real>
</dict>
</dict>
<key>userconfigurationconfig</key>
<array>
<dict>
<key>config</key>
<dict>
<key>default</key>
<string>y</string>
<key>placeholder</key>
<string></string>
<key>required</key>
<false/>
<key>trim</key>
<true/>
</dict>
<key>description</key>
<string>Key to start You.com suggestions</string>
<key>label</key>
<string>Search Keyword</string>
<key>type</key>
<string>textfield</string>
<key>variable</key>
<string>search_keyword</string>
</dict>
</array>
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>1.0.0</string>
<key>webaddress</key>
<string>https://links.dev/z</string>
</dict>
</plist>