Files
Sukka d82847f541 style/chore(eslint): enforce new rules (#8040)
* style: prefer object shorthand syntax
* refactor: prefer Array#map over Array#forEach
* style: prefer arrow callback
* chore(eslint): update rules
* style: auto fix by eslint
2021-08-17 22:23:23 +08:00

37 lines
1.1 KiB
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const link = `https://repo.xposed.info/module/${ctx.params.mod}`;
const response = await got({
method: 'get',
url: link,
});
const data = response.data;
const $ = cheerio.load(data);
const title = $('#page-title').text();
const list = $('div.field-collection-view');
ctx.state.data = {
title: `${title}(${ctx.params.mod}) 更新`,
link,
item:
list &&
list
.map((_, item) => {
item = $(item);
const version = item.find('div.field-name-field-version-number div.even').text();
return {
title: `Version ${version}`,
description: item.find('div.field-name-field-changes').html(),
link,
pubDate: item.find('span.date-display-single').html().replace('- ', ''),
guid: ctx.params.mod + version,
};
})
.get(),
};
};