diff --git a/lib/routes-deprecated/chrome/extensions.js b/lib/routes-deprecated/chrome/extensions.js deleted file mode 100644 index 6448c136b..000000000 --- a/lib/routes-deprecated/chrome/extensions.js +++ /dev/null @@ -1,30 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const id = ctx.params.id; - - const response = await got({ - method: 'get', - url: `https://chrome.google.com/webstore/detail/${id}?hl=en`, - }); - const data = cheerio.load(response.data)('noscript').text(); - const $ = cheerio.load(data); - - const version = 'v' + $('.h-C-b-p-D-md').text(); - - ctx.state.data = { - title: $('.e-f-w').text() + ' 扩展程序更新 - Chrome', - link: `https://chrome.google.com/webstore/detail/${id}`, - item: [ - { - title: version, - description: $('.C-b-p-D-J').html(), - link: `https://chrome.google.com/webstore/detail/${id}`, - pubDate: new Date($('.h-C-b-p-D-xh-hh').text()).toUTCString(), - guid: version, - author: $('.C-b-p-rc-D-R').text(), - }, - ], - }; -}; diff --git a/lib/routes/google/extension.ts b/lib/routes/google/extension.ts new file mode 100644 index 000000000..1daccf8c6 --- /dev/null +++ b/lib/routes/google/extension.ts @@ -0,0 +1,29 @@ +import got from '@/utils/got'; +import { load } from 'cheerio'; + +export default async (ctx) => { + const id = ctx.req.param('id'); + + const response = await got({ + method: 'get', + url: `https://chrome.google.com/webstore/detail/${id}?hl=en`, + }); + const $ = load(response.data); + + const version = 'v' + $('.pDlpAd').text(); + + ctx.set('data', { + title: $('.Pa2dE').text() + ' - Google Chrome Extension', + link: `https://chrome.google.com/webstore/detail/${id}`, + item: [ + { + title: version, + description: $('.uORbKe').html(), + link: `https://chrome.google.com/webstore/detail/${id}`, + pubDate: new Date($('.kBFnc').text().replace('Updated', '')).toUTCString(), + guid: version, + author: $('.yNyGQd').text(), + }, + ], + }); +}; diff --git a/lib/routes/google/maintainer.ts b/lib/routes/google/maintainer.ts index a3894a3c8..b1cf02118 100644 --- a/lib/routes/google/maintainer.ts +++ b/lib/routes/google/maintainer.ts @@ -9,4 +9,5 @@ export default { '/search/:keyword/:language?': ['CaoMeiYouRen'], '/sites/:id': ['hoilc'], '/sites/recentChanges/:id': ['nczitzk'], + '/chrome/extension/:id': ['DIYgod'], }; diff --git a/lib/routes/google/radar.ts b/lib/routes/google/radar.ts index 36047f313..354b749c7 100644 --- a/lib/routes/google/radar.ts +++ b/lib/routes/google/radar.ts @@ -13,12 +13,12 @@ export default { }, }, ], - chrome: [ + chromewebstore: [ { - title: '插件更新', - source: '/webstore/detail/:name/:id', - docs: 'https://docs.rsshub.app/routes/program-update#chrome-wang-shang-ying-yong-dian', - target: '/chrome/webstore/extensions/:id', + title: 'Extension Update', + source: '/detail/:name/:id', + docs: 'https://docs.rsshub.app/routes/program-update#chrome-web-store', + target: '/google/chrome/extension/:id', }, ], photos: [ diff --git a/lib/routes/google/router.ts b/lib/routes/google/router.ts index 13ccbab29..f688be1ad 100644 --- a/lib/routes/google/router.ts +++ b/lib/routes/google/router.ts @@ -7,4 +7,5 @@ export default (router) => { router.get('/news/:category/:locale', './news'); router.get('/scholar/:query', './scholar'); router.get('/search/:keyword/:language?', './search'); + router.get('/chrome/extension/:id', './extension'); }; diff --git a/lib/utils/got.ts b/lib/utils/got.ts index d707308d6..dc2b9b933 100644 --- a/lib/utils/got.ts +++ b/lib/utils/got.ts @@ -2,7 +2,7 @@ import logger from '@/utils/logger'; import { config } from '@/config'; import got, { CancelableRequest, Response as GotResponse, NormalizedOptions, Options } from 'got'; -type Response = GotResponse & { +type Response = GotResponse & { data: T; status: number; }; diff --git a/website/docs/routes/program-update.mdx b/website/docs/routes/program-update.mdx index 91dcbe7c0..609c1b861 100644 --- a/website/docs/routes/program-update.mdx +++ b/website/docs/routes/program-update.mdx @@ -156,12 +156,6 @@ -## Chrome Web Store {#chrome-web-store} - -### Extensions Update {#chrome-web-store-extensions-update} - - - ## Civitai {#civitai} ### Latest models {#civitai-latest-models} @@ -272,6 +266,12 @@ Need to configure `CIVITAI_COOKIE` to obtain image information of NSFW models. +## Google Chrome Web Store {#google-chrome-web-store} + +### Extension Update {#google-chrome-web-store-extension-update} + + + ## Greasy Fork {#greasy-fork} ### Script Update {#greasy-fork-script-update}