-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (41 loc) · 964 Bytes
/
index.js
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
const arvish = require('arvish');
const { load } = require('cheerio');
function getPointEmoji(point) {
return {
0: '😷',
1: '🙁',
2: '😕',
3: '😐',
4: '😉',
5: '😊',
}[point] || '';
}
(async () => {
const url = `https://www.abbreviations.com/abbreviation/${arvish.input}`;
const data = await arvish.fetch(url, {
json: false,
});
const $ = load(data);
const items = $('.table.tdata.no-margin tr')
.map((_, ele) => {
const $ele = $(ele);
const abbr = $ele.find('td:nth-child(1) a').text();
const point = $ele.find('td:last-child span.sf').length;;
return {
point,
title: `${getPointEmoji(point)} ${abbr}`,
subtitle: $(ele)
.find('td:nth-child(2) a')
.map((_, e) => $(e).text()).get().join(' / '),
arg: abbr,
quicklookurl: url,
text: {
copy: abbr,
largetype: abbr,
}
}
})
.get()
.sort((item1, item2) => item2.point - item1.point);
arvish.output(items);
})()