hunk.code_window: import { config } from '@/config';
   const allowSiteList = ['mastodon.social', 'pawoo.net'];
   const mediaParse = (media_attachments) =>
       media_attachments
           .map((item) => {
               const selectedUrl = item.remote_url ?? item.url;
               const description = item.description ?? '';
  
hunk.labels: keep keep keep add keep keep keep keep keep
hunk.after_edit: const apiHeaders = (site) => {
       const { accessToken, apiHost } = config.mastodon;
       // avoid sending API token to other sites
       return accessToken && site === apiHost ? { Authorization: `Bearer ${accessToken}` } : {};
   };
  
hunk.file_path: lib/routes/mastodon/utils.js
hunk.type: add
file: const got = require('@/utils/got');
  const cheerio = require('cheerio');
  const url = require('url');
  
  const host = 'http://sist.shanghaitech.edu.cn/';
  
  module.exports = async (ctx) => {
      const link = url.resolve(host, 'cn/News.asp?mid=102');
      const response = await got.get(link);
  
      const $ = cheerio.load(response.data);
  
      const list = $('.pagebv tr')
          .slice(0, 10)
          .map((i, e) => ({
              link: $(e).find('td:nth-of-type(2) a').attr('href'),
              date: $(e).find('td:last-of-type').text().replace('[', '').replace(']', ''),
          }))
          .get();
  
      const out = await Promise.all(
          list.map(async (item) => {
              const itemUrl = url.resolve(host, `cn/${item.link}`);
              const cache = await ctx.cache.get(itemUrl);
              if (cache) {
                  return JSON.parse(cache);
              }
  
              const response = await got.get(itemUrl);
              const $ = cheerio.load(response.data);
              const single = {
                  title: $('.pagebv tr:first-of-type').text().trim(),
                  link: itemUrl,
                  author: '上海科技大学信息科技与技术学院',
                  description: $('.pagebv tr:last-of-type')
                      .html()
                      .replaceAll('src="/', `src="${url.resolve(host, '.')}`)
                      .trim(),
                  pubDate: new Date(item.date),
              };
              ctx.cache.set(itemUrl, JSON.stringify(single));
              return single;
          })
      );
  
      ctx.state.data = {
          title: '上海科技大学信息科技与技术学院 -- 活动',
          link,
          item: out,
      };
  };
  