-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinfo.plist
executable file
·316 lines (306 loc) · 9.46 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<?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>de.bru6</string>
<key>category</key>
<string>Internet</string>
<key>connections</key>
<dict>
<key>4E81152C-9E00-45FC-9C42-D99B3D80D3E3</key>
<array>
<dict>
<key>destinationuid</key>
<string>ABF404AE-7171-4B13-9FF0-A3FAF5CB4DD4</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>ABF404AE-7171-4B13-9FF0-A3FAF5CB4DD4</key>
<array>
<dict>
<key>destinationuid</key>
<string>86A62DE8-DE53-4368-88F0-0052B79F40E5</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>createdby</key>
<string>Christian Kirsch</string>
<key>description</key>
<string>Find terms on caniuse.com, using the site's exported data</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>Search Caniuse.com</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>action</key>
<integer>0</integer>
<key>argument</key>
<integer>0</integer>
<key>focusedappvariable</key>
<false/>
<key>focusedappvariablename</key>
<string></string>
<key>hotkey</key>
<integer>8</integer>
<key>hotmod</key>
<integer>1966080</integer>
<key>hotstring</key>
<string>C</string>
<key>leftcursor</key>
<false/>
<key>modsmode</key>
<integer>0</integer>
<key>relatedAppsMode</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.trigger.hotkey</string>
<key>uid</key>
<string>4E81152C-9E00-45FC-9C42-D99B3D80D3E3</string>
<key>version</key>
<integer>2</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>0</integer>
<key>escaping</key>
<integer>68</integer>
<key>keyword</key>
<string>cu</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></string>
<key>script</key>
<string>ObjC.import("Foundation");
const dataURL='https://raw.githubusercontent.com/Fyrd/caniuse/main/fulldata-json/data-2.0.json';
function findMatches(query, data) {
const lcQuery = query.toLowerCase();
return data.filter(d => {
console.log('${lcQuery}: ${d.title}/${d.name)/[${d.keywords}]')
return d.title.toLowerCase().includes(lcQuery) ||
d.name.toLowerCase().includes(lcQuery) ||
d.keywords.toLowerCase().includes(lcQuery) ;
});
} /* findMatches() */
function getBrowserVersion(stats, title, browser) {
let version = 0;
let retval = '';
for (const v of Object.keys(stats).sort((a,b) => Number(a) - Number(b))) {
const numVersion = Number(v);
const support = stats[v];
// if (title.indexOf('WOFF 2')> -1) console.log(`${browser}: ${numVersion} ${support}`);
if (numVersion > version) {
if (support === 'y') {
retval = `${v}+`;
break;
}
if (support.indexOf('y x') > -1) {
version = numVersion;
retval = `${v}-px-`;
} else if (support.indexOf('a') > -1) {
version = numVersion;
retval = `${v}!pa.`;
} else if (support.indexOf('p') > -1) {
version = numVersion;
retval = `${v}w/pl`;
}
}
}
// if (title.indexOf('WOFF 2')> -1) console.log(`Version ${browser} found: ${retval}`);
return retval;
} /* getBrowserVersion */
function run(argv) {
const browserMap = {'ie': 'IE',
'edge' : 'E',
'firefox': 'FF',
'chrome' : 'GC',
'safari' : 'S'};
const query = argv[0];
if (!query) return;
const localCache = 'data.json';
const filemanager = $.NSFileManager.defaultManager;
const modificationDate = (() => {
if (filemanager.fileExistsAtPath($(localCache))) {
const error = Ref();
const dict = filemanager.attributesOfItemAtPathError($(localCache), error);
return dict.objectForKey($.NSFileModificationDate).js;
} else {
return null;
}
})()
// console.log(modificationDate);
const milliSecsPerDay = 8.64e7;
const cachedValues = (() => {
const app = Application.currentApplication();
app.includeStandardAdditions = true;
if (!modificationDate || (Date.now() - modificationDate) >= (milliSecsPerDay * 7)) {
// const dataURL = 'https://raw.githubusercontent.com/Fyrd/caniuse/master/data.json';
const dataJSON = app.doShellScript(`curl ${dataURL}`);
// console.log(dataJSON.length);
const data = JSON.parse(dataJSON).data;
const cacheArray = Object.keys(data).map(k => {
const caniuseData = data[k];
// console.log(Object.keys(caniuseData.stats).filter(b => browserMap[b]));
// console.log(Object.keys(caniuseData.stats));
const stats = {};
Object.keys(caniuseData.stats).filter(browser => browserMap[browser]).forEach(browser => {
const support = getBrowserVersion(caniuseData.stats[browser], caniuseData.title, browser);
if (support.trim().length) stats[browserMap[browser]] = support;
})
return {
name: k,
title: caniuseData.title,
url: `https://caniuse.com/#feat=${k}`,
description: caniuseData.description,
keywords: caniuseData.keywords,
stats: Object.keys(stats).map(key => `${key}: ${stats[key]}`).join(', '),
}
});
if (cacheArray.length) {
/* write cache data */
// console.log(`updating cache data @ ${Path(localCache)}`);
const file = app.openForAccess(Path(localCache), {writePermission: true});
app.write(JSON.stringify(cacheArray), {to: file});
app.closeAccess(file);
}
return cacheArray;
} /* if local file is older than one week */ else {
const file = app.openForAccess(Path(localCache));
const cacheArray = JSON.parse(app.read(file));
app.closeAccess(file);
return cacheArray;
}
})()
/* Now 'cachedValues' contains the relevant JSON data */
const result = findMatches(query, cachedValues);
const items = result.map(r => {
return {
uid: r.title,
arg: r.url,
title: `${r.title} [${r.stats}]`,
subtitle: r.description,
icon: { path: 'icon.png'},
/* add icon */
}
}); /* items */
return JSON.stringify({items: (items.length ?
items :
[{ title: `No matches found for ${query}`}]) });
}</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string>Search Caniuse for {{query}}</string>
<key>title</key>
<string>Search Caniuse</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>ABF404AE-7171-4B13-9FF0-A3FAF5CB4DD4</string>
<key>version</key>
<integer>3</integer>
</dict>
<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>{query}</string>
</dict>
<key>type</key>
<string>alfred.workflow.action.openurl</string>
<key>uid</key>
<string>86A62DE8-DE53-4368-88F0-0052B79F40E5</string>
<key>version</key>
<integer>1</integer>
</dict>
</array>
<key>readme</key>
<string>Simple search for terms in the data of caniuse.com. Does not require third party software like PHP or Python.
It uses the official exported JSON file on Github
https://raw.githubusercontent.com/Fyrd/caniuse/main/fulldata-json/data-2.0.json
for this.
Terms are looked for in the title, keywords and the JSON data's key.
**Note 1**: The file is updated whenever the local copy is older than a week.
**Note 2**: The data is _not_ complete, i.e. it is not the same as on caniuse.com. It's not clear yet why the exported data does not contain all the information from the website.
Hotkey is Ctrl-Opt-Cmd-Shift C („Hyper-C“), keyword is 'cu'. Both can be modified, of course, as can be the JavaScript code of the script action.
The code is modelled after an earlier version by Will Farrell (https://github.com/willfarrell/alfred-caniuse-workflow). This workflow relied on PHP.</string>
<key>uidata</key>
<dict>
<key>4E81152C-9E00-45FC-9C42-D99B3D80D3E3</key>
<dict>
<key>xpos</key>
<real>60</real>
<key>ypos</key>
<real>40</real>
</dict>
<key>86A62DE8-DE53-4368-88F0-0052B79F40E5</key>
<dict>
<key>xpos</key>
<real>640</real>
<key>ypos</key>
<real>40</real>
</dict>
<key>ABF404AE-7171-4B13-9FF0-A3FAF5CB4DD4</key>
<dict>
<key>xpos</key>
<real>330</real>
<key>ypos</key>
<real>40</real>
</dict>
</dict>
<key>userconfigurationconfig</key>
<array/>
<key>version</key>
<string>1.0</string>
<key>webaddress</key>
<string></string>
</dict>
</plist>