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
|
const axios = require('axios');
const apiVersion = "v1"
function sleep(ms) {
return new Promise((res) => {
setTimeout(res, ms);
});
}
(async () => {
let user = process.argv[2];
try {
let data = (await axios.get(`https://mastodon.social/api/${apiVersion}/accounts/lookup?acct=${user}`)).data;
let obj = {
error: null,
avatar: "https://img.icons8.com/external-tal-revivo-regular-tal-revivo/64/ffffff/external-mastodon-is-an-online-self-hosted-social-media-and-social-networking-service-logo-regular-tal-revivo.png",
name: data['display_name'] ?? data['username'],
description: `@${data['acct']}`,
link: data['url'],
copy: [
{
title: "Copy link to profile",
text: data['url']
},
{
title: "Copy local username",
text: data['username']
},
{
title: "Copy full username",
text: data['acct']
},
data['avatar_static'] ? {
title: "Copy avatar URL",
text: data['avatar_static']
} : null
]
}
if (data['avatar_static']) {
obj.avatar = data['avatar_static'];
}
console.log(JSON.stringify(obj, null, 2));
} catch (e) {
console.log(JSON.stringify({
error: e,
avatar: "https://img.icons8.com/external-tal-revivo-regular-tal-revivo/64/ffffff/external-mastodon-is-an-online-self-hosted-social-media-and-social-networking-service-logo-regular-tal-revivo.png",
name: user,
description: "Mastodon",
link: null,
copy: []
}, null, 2));
}
})();
|