/
addon.ts
56 lines (51 loc) 路 1.57 KB
/
addon.ts
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
import { Route } from '@/types';
import got from '@/utils/got';
export const route: Route = {
path: '/edge/addon/:crxid',
categories: ['program-update'],
example: '/microsoft/edge/addon/gangkeiaobmjcjokiofpkfpcobpbmnln',
parameters: { crxid: 'Addon id, can be found in addon url' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['microsoftedge.microsoft.com/addons/detail/:name/:crxid'],
},
],
name: 'Addons Update',
maintainers: ['hoilc', 'DIYgod'],
handler,
};
async function handler(ctx) {
const crxid = ctx.req.param('crxid');
const page_url = `https://microsoftedge.microsoft.com/addons/detail/${crxid}`;
const { data } = await got({
method: 'get',
url: `https://microsoftedge.microsoft.com/addons/getproductdetailsbycrxid/${crxid}?hl=en`,
headers: {
Referer: page_url,
},
});
return {
title: `${data.name} - Microsoft Edge Addons`,
description: data.shortDescription,
image: `https:${data.thumbnail}`,
link: page_url,
item: [
{
title: 'v' + data.version,
author: data.developer,
description: data.description,
pubDate: new Date(data.lastUpdateDate * 1000),
guid: `edge::${crxid}::${data.version}`,
link: page_url,
},
],
};
}