From cfc0cabdd024f1542094d27a6f44c3a29b501665 Mon Sep 17 00:00:00 2001 From: phoeagon Date: Sun, 1 Mar 2026 23:00:39 -0800 Subject: [PATCH 01/10] add ebay user/search routes --- lib/routes/ebay/namespace.ts | 8 +++++ lib/routes/ebay/search.ts | 68 ++++++++++++++++++++++++++++++++++++ lib/routes/ebay/user.ts | 58 ++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 lib/routes/ebay/namespace.ts create mode 100644 lib/routes/ebay/search.ts create mode 100644 lib/routes/ebay/user.ts diff --git a/lib/routes/ebay/namespace.ts b/lib/routes/ebay/namespace.ts new file mode 100644 index 000000000000..e00a101c98c0 --- /dev/null +++ b/lib/routes/ebay/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'eBay', + url: 'ebay.com', + categories: ['shopping'], + description: 'eBay search results and user listings.', +}; diff --git a/lib/routes/ebay/search.ts b/lib/routes/ebay/search.ts new file mode 100644 index 000000000000..c6071452a910 --- /dev/null +++ b/lib/routes/ebay/search.ts @@ -0,0 +1,68 @@ +import { Route } from '@/types'; +import { load } from 'cheerio'; +import ofetch from '@/utils/ofetch'; +import { parseDate } from '@/utils/parse-date'; +import logger from '@/utils/logger'; + +export const route: Route = { + path: '/search/:keywords', + categories: ['shopping'], + example: '/ebay/search/sodimm+ddr4+16gb', + parameters: { keywords: 'Keywords for search' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + name: 'Search Results', + maintainers: ['phoeagon'], + handler, +}; + +async function handler(ctx) { + const { keywords } = ctx.req.param(); + const url = `https://www.ebay.com/sch/i.html?_nkw=${encodeURIComponent(keywords)}&_sop=10&_ipg=240`; + + logger.info(`Fetching eBay search results: ${url}`); + const response = await ofetch(url); + logger.info(`eBay response status: ${response instanceof Response ? response.status : 'unknown'}`); + const $ = load(response); + + const items = $('.s-item, .s-card, .s-item__wrapper.clearfix') + .toArray() + .map((item) => { + const $item = $(item); + const titleElement = $item.find('.s-item__title, .s-card__title, .s-item__title--has-tags'); + const title = titleElement.text().replace(/^New Listing/i, '').trim(); + const link = $item.find('.s-item__link, .s-card__link').attr('href'); + const price = $item.find('.s-item__price, .s-card__price').text().trim(); + const image = + $item.find('.s-item__image-img img, img.s-item__image-img').attr('src') || + $item.find('.s-item__image-wrapper img').attr('src') || + $item.find('.s-card__image-img img').attr('src') || + $item.find('.s-item__image img').attr('src'); + + if (!title || !link || title.toLowerCase().includes('shop on ebay') || price === '') { + return null; + } + + return { + title: `${title} - ${price}`, + link, + description: `
Price: ${price}`, + category: 'eBay Search', + }; + }) + .filter(Boolean); + + logger.info(`Found ${items.length} items on eBay`); + + return { + title: `eBay Search: ${keywords}`, + link: url, + item: items, + }; +} diff --git a/lib/routes/ebay/user.ts b/lib/routes/ebay/user.ts new file mode 100644 index 000000000000..477e217204af --- /dev/null +++ b/lib/routes/ebay/user.ts @@ -0,0 +1,58 @@ +import { Route } from '@/types'; +import { load } from 'cheerio'; +import ofetch from '@/utils/ofetch'; + +export const route: Route = { + path: ['/usr/:username', '/user/:username'], + categories: ['shopping'], + example: '/ebay/usr/m.trotters', + parameters: { username: 'Username of the seller' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + name: 'User Listings', + maintainers: ['phoeagon'], + handler, +}; + +async function handler(ctx) { + const { username } = ctx.req.param(); + const url = `https://www.ebay.com/usr/${username}`; + + const response = await ofetch(url); + const $ = load(response); + console.log(response); + + const items = $('article.str-item-card.StoreFrontItemCard') + .toArray() + .map((item) => { + const $item = $(item); + const title = $item.find('.str-card-title .str-text-span').first().text().trim(); + const link = $item.find('.str-item-card__link').attr('href'); + const price = $item.find('.str-item-card__property-displayPrice').text().trim(); + const image = $item.find('.str-image img').attr('src'); + + if (!title || !link) { + return null; + } + + return { + title: `${title} - ${price}`, + link, + description: `
Price: ${price}`, + author: username, + }; + }) + .filter(Boolean); + + return { + title: `eBay User: ${username}`, + link: url, + item: items, + }; +} From d3ff7723e0c19cff3b7d955e5e0cab2ac52e9620 Mon Sep 17 00:00:00 2001 From: phoeagon Date: Sat, 7 Mar 2026 10:03:17 -0800 Subject: [PATCH 02/10] updated ebay routes according to standard --- lib/routes/ebay/search.ts | 90 +++++++++++++++++++++------------------ lib/routes/ebay/user.ts | 71 +++++++++++++++--------------- lib/routes/ebay/utils.ts | 37 ++++++++++++++++ 3 files changed, 122 insertions(+), 76 deletions(-) create mode 100644 lib/routes/ebay/utils.ts diff --git a/lib/routes/ebay/search.ts b/lib/routes/ebay/search.ts index c6071452a910..5b4c9c57bb17 100644 --- a/lib/routes/ebay/search.ts +++ b/lib/routes/ebay/search.ts @@ -1,7 +1,6 @@ import { Route } from '@/types'; import { load } from 'cheerio'; import ofetch from '@/utils/ofetch'; -import { parseDate } from '@/utils/parse-date'; import logger from '@/utils/logger'; export const route: Route = { @@ -17,52 +16,59 @@ export const route: Route = { supportPodcast: false, supportScihub: false, }, + radar: [ + { + source: ['ebay.com/sch/i.html'], + target: (params, url) => { + const searchKeywords = new URL(url).searchParams.get('_nkw'); + return `/search/${searchKeywords}`; + }, + }, + ], name: 'Search Results', maintainers: ['phoeagon'], - handler, -}; - -async function handler(ctx) { - const { keywords } = ctx.req.param(); - const url = `https://www.ebay.com/sch/i.html?_nkw=${encodeURIComponent(keywords)}&_sop=10&_ipg=240`; + handler: async (ctx) => { + const { keywords } = ctx.req.param(); + const url = `https://www.ebay.com/sch/i.html?_nkw=${encodeURIComponent(keywords)}&_sop=10&_ipg=240`; - logger.info(`Fetching eBay search results: ${url}`); - const response = await ofetch(url); - logger.info(`eBay response status: ${response instanceof Response ? response.status : 'unknown'}`); - const $ = load(response); + logger.info(`Fetching eBay search results: ${url}`); + const response = await ofetch(url); + logger.info(`eBay response status: ${response instanceof Response ? response.status : 'unknown'}`); + const $ = load(response); - const items = $('.s-item, .s-card, .s-item__wrapper.clearfix') - .toArray() - .map((item) => { - const $item = $(item); - const titleElement = $item.find('.s-item__title, .s-card__title, .s-item__title--has-tags'); - const title = titleElement.text().replace(/^New Listing/i, '').trim(); - const link = $item.find('.s-item__link, .s-card__link').attr('href'); - const price = $item.find('.s-item__price, .s-card__price').text().trim(); - const image = - $item.find('.s-item__image-img img, img.s-item__image-img').attr('src') || - $item.find('.s-item__image-wrapper img').attr('src') || - $item.find('.s-card__image-img img').attr('src') || - $item.find('.s-item__image img').attr('src'); + const items = $('.s-item, .s-card, .s-item__wrapper.clearfix') + .toArray() + .map((item) => { + const $item = $(item); + const titleElement = $item.find('.s-item__title, .s-card__title, .s-item__title--has-tags'); + const title = titleElement.text().replace(/^New Listing/i, '').trim(); + const link = $item.find('.s-item__link, .s-card__link').attr('href'); + const price = $item.find('.s-item__price, .s-card__price').text().trim(); + const image = + $item.find('.s-item__image-img img, img.s-item__image-img').attr('src') || + $item.find('.s-item__image-wrapper img').attr('src') || + $item.find('.s-card__image-img img').attr('src') || + $item.find('.s-item__image img').attr('src'); - if (!title || !link || title.toLowerCase().includes('shop on ebay') || price === '') { - return null; - } + if (!title || !link || title.toLowerCase().includes('shop on ebay') || price === '') { + return null; + } - return { - title: `${title} - ${price}`, - link, - description: `
Price: ${price}`, - category: 'eBay Search', - }; - }) - .filter(Boolean); + return { + title: `${title} - ${price}`, + link, + description: `
Price: ${price}`, + category: 'eBay Search', + }; + }) + .filter(Boolean); - logger.info(`Found ${items.length} items on eBay`); + logger.info(`Found ${items.length} items on eBay`); - return { - title: `eBay Search: ${keywords}`, - link: url, - item: items, - }; -} + return { + title: `eBay Search: ${keywords}`, + link: url, + item: items, + }; + }, +}; diff --git a/lib/routes/ebay/user.ts b/lib/routes/ebay/user.ts index 477e217204af..a5f6f1803119 100644 --- a/lib/routes/ebay/user.ts +++ b/lib/routes/ebay/user.ts @@ -15,44 +15,47 @@ export const route: Route = { supportPodcast: false, supportScihub: false, }, + radar: [ + { + source: ['ebay.com/usr/:username'], + target: '/user/:username', + }, + ], name: 'User Listings', maintainers: ['phoeagon'], - handler, -}; - -async function handler(ctx) { - const { username } = ctx.req.param(); - const url = `https://www.ebay.com/usr/${username}`; + handler: async (ctx) => { + const { username } = ctx.req.param(); + const url = `https://www.ebay.com/usr/${username}`; - const response = await ofetch(url); - const $ = load(response); - console.log(response); + const response = await ofetch(url); + const $ = load(response); - const items = $('article.str-item-card.StoreFrontItemCard') - .toArray() - .map((item) => { - const $item = $(item); - const title = $item.find('.str-card-title .str-text-span').first().text().trim(); - const link = $item.find('.str-item-card__link').attr('href'); - const price = $item.find('.str-item-card__property-displayPrice').text().trim(); - const image = $item.find('.str-image img').attr('src'); + const items = $('article.str-item-card.StoreFrontItemCard') + .toArray() + .map((item) => { + const $item = $(item); + const title = $item.find('.str-card-title .str-text-span').first().text().trim(); + const link = $item.find('.str-item-card__link').attr('href'); + const price = $item.find('.str-item-card__property-displayPrice').text().trim(); + const image = $item.find('.str-image img').attr('src'); - if (!title || !link) { - return null; - } + if (!title || !link) { + return null; + } - return { - title: `${title} - ${price}`, - link, - description: `
Price: ${price}`, - author: username, - }; - }) - .filter(Boolean); + return { + title: `${title} - ${price}`, + link, + description: `
Price: ${price}`, + author: username, + }; + }) + .filter(Boolean); - return { - title: `eBay User: ${username}`, - link: url, - item: items, - }; -} + return { + title: `eBay User: ${username}`, + link: url, + item: items, + }; + }, +}; diff --git a/lib/routes/ebay/utils.ts b/lib/routes/ebay/utils.ts new file mode 100644 index 000000000000..91659038590e --- /dev/null +++ b/lib/routes/ebay/utils.ts @@ -0,0 +1,37 @@ +import { CheerioAPI, Element } from 'cheerio'; + +/** + * Transforms an eBay image URL to prefer WebP format if it's a JPG/JPEG. + * @param url The original image URL. + * @returns The transformed URL. + */ +export const transformImage = (url?: string): string | undefined => { + if (!url) { + return undefined; + } + // eBay images often look like https://i.ebayimg.com/images/g/.../s-l500.jpg + // Replacing .jpg with .webp usually works if s-lXXX is used. + return url.replace(/\.jpe?g$/i, '.webp'); +}; + +/** + * Common item structure for eBay routes. + */ +export interface eBayItem { + title: string; + link: string; + description: string; + category?: string; + author?: string; +} + +/** + * Helper to extract common data from an eBay item element. + * Note: Since selectors vary, this might be less useful than specific logic in each route, + * but let's provide a way to standardize the output. + */ +export const createItem = (title: string, price: string, link: string, image?: string): eBayItem => ({ + title: `${title} - ${price}`, + link, + description: `
Price: ${price}`, +}); From f5ad40328ffae1e7b8ee4e2a2342b714c4b6becc Mon Sep 17 00:00:00 2001 From: phoeagon Date: Sat, 7 Mar 2026 10:52:44 -0800 Subject: [PATCH 03/10] update ebay routes according to presubmit finding --- lib/routes/.DS_Store | Bin 0 -> 6148 bytes lib/routes/ebay/.DS_Store | Bin 0 -> 6148 bytes lib/routes/ebay/search.ts | 7 ++++--- lib/routes/ebay/user.ts | 3 ++- lib/routes/ebay/utils.ts | 1 - 5 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 lib/routes/.DS_Store create mode 100644 lib/routes/ebay/.DS_Store diff --git a/lib/routes/.DS_Store b/lib/routes/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..cfe02c24435f050a90ebee97aab7cd32ece43a3b GIT binary patch literal 6148 zcmeH~F$w}f3`G;&V!>uh%V|7-Hy9Q@ffrCwY(zm&u$!a%lL>;WwTS#c@+X-I%f4b~ zBO=;gcXN?WL|VA1%q$E{kvFoJt!(6eTU}1a^XY(^)kksG*6>aS`>{w?k8$%b}%eZ5NHfI2n{SX^GV$F4bUcYwI zJh$~l*R)$k9b=9=Mz**|hnl@BtoS?k-UG+v-QtNJV`0uYYuw`{N~*>h$Llj#L?j4hDjOAp`r?o$3BR z<6malPIp2L7_eP2w+F&$Wa-z@hqEh Xm1A$HS>!M2#P|>>goFwPeu05ECCn~C literal 0 HcmV?d00001 diff --git a/lib/routes/ebay/search.ts b/lib/routes/ebay/search.ts index 5b4c9c57bb17..78e2ce4eac2d 100644 --- a/lib/routes/ebay/search.ts +++ b/lib/routes/ebay/search.ts @@ -1,7 +1,8 @@ -import { Route } from '@/types'; import { load } from 'cheerio'; -import ofetch from '@/utils/ofetch'; + import logger from '@/utils/logger'; +import ofetch from '@/utils/ofetch'; +import type { Route } from '@/types'; export const route: Route = { path: '/search/:keywords', @@ -41,7 +42,7 @@ export const route: Route = { .map((item) => { const $item = $(item); const titleElement = $item.find('.s-item__title, .s-card__title, .s-item__title--has-tags'); - const title = titleElement.text().replace(/^New Listing/i, '').trim(); + const title = titleElement.text().replace(/^New Listing/i, ''); const link = $item.find('.s-item__link, .s-card__link').attr('href'); const price = $item.find('.s-item__price, .s-card__price').text().trim(); const image = diff --git a/lib/routes/ebay/user.ts b/lib/routes/ebay/user.ts index a5f6f1803119..555a18a1c1af 100644 --- a/lib/routes/ebay/user.ts +++ b/lib/routes/ebay/user.ts @@ -1,6 +1,7 @@ -import { Route } from '@/types'; import { load } from 'cheerio'; + import ofetch from '@/utils/ofetch'; +import type { Route } from '@/types'; export const route: Route = { path: ['/usr/:username', '/user/:username'], diff --git a/lib/routes/ebay/utils.ts b/lib/routes/ebay/utils.ts index 91659038590e..3dc0f420e7aa 100644 --- a/lib/routes/ebay/utils.ts +++ b/lib/routes/ebay/utils.ts @@ -1,4 +1,3 @@ -import { CheerioAPI, Element } from 'cheerio'; /** * Transforms an eBay image URL to prefer WebP format if it's a JPG/JPEG. From 449def264b887ce32d1bdd5f43a473ccd4193bde Mon Sep 17 00:00:00 2001 From: phoeagon Date: Sat, 7 Mar 2026 11:03:47 -0800 Subject: [PATCH 04/10] update import order --- lib/routes/ebay/search.ts | 2 +- lib/routes/ebay/user.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/routes/ebay/search.ts b/lib/routes/ebay/search.ts index 78e2ce4eac2d..ed89dc503a69 100644 --- a/lib/routes/ebay/search.ts +++ b/lib/routes/ebay/search.ts @@ -1,8 +1,8 @@ import { load } from 'cheerio'; +import type { Route } from '@/types'; import logger from '@/utils/logger'; import ofetch from '@/utils/ofetch'; -import type { Route } from '@/types'; export const route: Route = { path: '/search/:keywords', diff --git a/lib/routes/ebay/user.ts b/lib/routes/ebay/user.ts index 555a18a1c1af..a5f74652072e 100644 --- a/lib/routes/ebay/user.ts +++ b/lib/routes/ebay/user.ts @@ -1,7 +1,7 @@ import { load } from 'cheerio'; -import ofetch from '@/utils/ofetch'; import type { Route } from '@/types'; +import ofetch from '@/utils/ofetch'; export const route: Route = { path: ['/usr/:username', '/user/:username'], From ec93a5688595f4f4fffe59252b7fde4509d04a0c Mon Sep 17 00:00:00 2001 From: phoeagon Date: Sat, 7 Mar 2026 11:08:50 -0800 Subject: [PATCH 05/10] updates according to autofindings --- lib/routes/ebay/search.ts | 6 +++--- lib/routes/ebay/user.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/routes/ebay/search.ts b/lib/routes/ebay/search.ts index ed89dc503a69..699562a24bcc 100644 --- a/lib/routes/ebay/search.ts +++ b/lib/routes/ebay/search.ts @@ -7,7 +7,7 @@ import ofetch from '@/utils/ofetch'; export const route: Route = { path: '/search/:keywords', categories: ['shopping'], - example: '/ebay/search/sodimm+ddr4+16gb', + example: '/search/sodimm+ddr4+16gb', parameters: { keywords: 'Keywords for search' }, features: { requireConfig: false, @@ -22,7 +22,7 @@ export const route: Route = { source: ['ebay.com/sch/i.html'], target: (params, url) => { const searchKeywords = new URL(url).searchParams.get('_nkw'); - return `/search/${searchKeywords}`; + return `/ebay/search/${searchKeywords}`; }, }, ], @@ -59,7 +59,7 @@ export const route: Route = { title: `${title} - ${price}`, link, description: `
Price: ${price}`, - category: 'eBay Search', + category: 'shopping', }; }) .filter(Boolean); diff --git a/lib/routes/ebay/user.ts b/lib/routes/ebay/user.ts index a5f74652072e..d53d9c718a5f 100644 --- a/lib/routes/ebay/user.ts +++ b/lib/routes/ebay/user.ts @@ -6,7 +6,7 @@ import ofetch from '@/utils/ofetch'; export const route: Route = { path: ['/usr/:username', '/user/:username'], categories: ['shopping'], - example: '/ebay/usr/m.trotters', + example: '/usr/m.trotters', parameters: { username: 'Username of the seller' }, features: { requireConfig: false, @@ -19,7 +19,7 @@ export const route: Route = { radar: [ { source: ['ebay.com/usr/:username'], - target: '/user/:username', + target: '/ebay/user/:username', }, ], name: 'User Listings', From 878edcebb6e689d52cb91ca0d9067c11a10bf263 Mon Sep 17 00:00:00 2001 From: phoeagon Date: Sat, 7 Mar 2026 11:10:26 -0800 Subject: [PATCH 06/10] clean up .DS_Store --- lib/routes/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 lib/routes/.DS_Store diff --git a/lib/routes/.DS_Store b/lib/routes/.DS_Store deleted file mode 100644 index cfe02c24435f050a90ebee97aab7cd32ece43a3b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~F$w}f3`G;&V!>uh%V|7-Hy9Q@ffrCwY(zm&u$!a%lL>;WwTS#c@+X-I%f4b~ zBO=;gcXN?WL|VA1%q$E{kvFoJt!(6eTU}1a^XY(^)kksG*6>aS`>{w?k8$%b}%eZ5NH Date: Sat, 7 Mar 2026 11:11:41 -0800 Subject: [PATCH 07/10] fix category --- lib/routes/ebay/search.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/routes/ebay/search.ts b/lib/routes/ebay/search.ts index 699562a24bcc..45d975bf97ee 100644 --- a/lib/routes/ebay/search.ts +++ b/lib/routes/ebay/search.ts @@ -59,7 +59,6 @@ export const route: Route = { title: `${title} - ${price}`, link, description: `
Price: ${price}`, - category: 'shopping', }; }) .filter(Boolean); From 826359a3776be3e4ed9a62a41c226c9f07b8c62d Mon Sep 17 00:00:00 2001 From: phoeagon Date: Sun, 8 Mar 2026 16:59:24 -0700 Subject: [PATCH 08/10] update ebay routes according to review comments --- lib/routes/ebay/.DS_Store | Bin 6148 -> 0 bytes lib/routes/ebay/search.ts | 13 +++++++------ lib/routes/ebay/user.ts | 13 ++++++++----- lib/routes/ebay/utils.ts | 36 ------------------------------------ 4 files changed, 15 insertions(+), 47 deletions(-) delete mode 100644 lib/routes/ebay/.DS_Store delete mode 100644 lib/routes/ebay/utils.ts diff --git a/lib/routes/ebay/.DS_Store b/lib/routes/ebay/.DS_Store deleted file mode 100644 index 9e536daa448791fb70b80ea9a735d97d38fb2d8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!Ab)$5Pi`e3L^CA&3u8yKUhiy58}c8fG!m+h)Q=C^tPYwdzn#OT=XVZW=iHw zCNr7jL6Z%DwCL8Szzo2YO_*eih}@$?dmb!IWsVn|pv5g3>fI2n{SX^GV$F4bUcYwI zJh$~l*R)$k9b=9=Mz**|hnl@BtoS?k-UG+v-QtNJV`0uYYuw`{N~*>h$Llj#L?j4hDjOAp`r?o$3BR z<6malPIp2L7_eP2w+F&$Wa-z@hqEh Xm1A$HS>!M2#P|>>goFwPeu05ECCn~C diff --git a/lib/routes/ebay/search.ts b/lib/routes/ebay/search.ts index 45d975bf97ee..93b3f9e94c72 100644 --- a/lib/routes/ebay/search.ts +++ b/lib/routes/ebay/search.ts @@ -7,7 +7,7 @@ import ofetch from '@/utils/ofetch'; export const route: Route = { path: '/search/:keywords', categories: ['shopping'], - example: '/search/sodimm+ddr4+16gb', + example: '/ebay/search/sodimm+ddr4+16gb', parameters: { keywords: 'Keywords for search' }, features: { requireConfig: false, @@ -32,12 +32,10 @@ export const route: Route = { const { keywords } = ctx.req.param(); const url = `https://www.ebay.com/sch/i.html?_nkw=${encodeURIComponent(keywords)}&_sop=10&_ipg=240`; - logger.info(`Fetching eBay search results: ${url}`); const response = await ofetch(url); - logger.info(`eBay response status: ${response instanceof Response ? response.status : 'unknown'}`); const $ = load(response); - const items = $('.s-item, .s-card, .s-item__wrapper.clearfix') + const items = $('.srp-results') .toArray() .map((item) => { const $item = $(item); @@ -55,10 +53,13 @@ export const route: Route = { return null; } + const cleanedLink = new URL(link); + cleanedLink.search = ''; + return { title: `${title} - ${price}`, - link, - description: `
Price: ${price}`, + link: cleanedLink.toString(), + description: `
Price: ${price}`, }; }) .filter(Boolean); diff --git a/lib/routes/ebay/user.ts b/lib/routes/ebay/user.ts index d53d9c718a5f..0daec35b6cbb 100644 --- a/lib/routes/ebay/user.ts +++ b/lib/routes/ebay/user.ts @@ -4,9 +4,9 @@ import type { Route } from '@/types'; import ofetch from '@/utils/ofetch'; export const route: Route = { - path: ['/usr/:username', '/user/:username'], + path: ['/user/:username'], categories: ['shopping'], - example: '/usr/m.trotters', + example: '/ebay/user/m.trotters', parameters: { username: 'Username of the seller' }, features: { requireConfig: false, @@ -19,7 +19,7 @@ export const route: Route = { radar: [ { source: ['ebay.com/usr/:username'], - target: '/ebay/user/:username', + target: '/user/:username', }, ], name: 'User Listings', @@ -44,10 +44,13 @@ export const route: Route = { return null; } + const cleanedLink = new URL(link); + cleanedLink.search = ''; + return { title: `${title} - ${price}`, - link, - description: `
Price: ${price}`, + link: cleanedLink.toString(), + description: `
Price: ${price}`, author: username, }; }) diff --git a/lib/routes/ebay/utils.ts b/lib/routes/ebay/utils.ts deleted file mode 100644 index 3dc0f420e7aa..000000000000 --- a/lib/routes/ebay/utils.ts +++ /dev/null @@ -1,36 +0,0 @@ - -/** - * Transforms an eBay image URL to prefer WebP format if it's a JPG/JPEG. - * @param url The original image URL. - * @returns The transformed URL. - */ -export const transformImage = (url?: string): string | undefined => { - if (!url) { - return undefined; - } - // eBay images often look like https://i.ebayimg.com/images/g/.../s-l500.jpg - // Replacing .jpg with .webp usually works if s-lXXX is used. - return url.replace(/\.jpe?g$/i, '.webp'); -}; - -/** - * Common item structure for eBay routes. - */ -export interface eBayItem { - title: string; - link: string; - description: string; - category?: string; - author?: string; -} - -/** - * Helper to extract common data from an eBay item element. - * Note: Since selectors vary, this might be less useful than specific logic in each route, - * but let's provide a way to standardize the output. - */ -export const createItem = (title: string, price: string, link: string, image?: string): eBayItem => ({ - title: `${title} - ${price}`, - link, - description: `
Price: ${price}`, -}); From a99c86cbc0193b65554d1062042f96bdd2e1175c Mon Sep 17 00:00:00 2001 From: phoeagon Date: Sun, 8 Mar 2026 18:14:07 -0700 Subject: [PATCH 09/10] fix ebay/search parsing --- lib/routes/ebay/search.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/routes/ebay/search.ts b/lib/routes/ebay/search.ts index 93b3f9e94c72..705786cb9c16 100644 --- a/lib/routes/ebay/search.ts +++ b/lib/routes/ebay/search.ts @@ -35,19 +35,16 @@ export const route: Route = { const response = await ofetch(url); const $ = load(response); - const items = $('.srp-results') + const items = $('.srp-results .s-item, .srp-results .s-card, .s-item, .s-card') .toArray() .map((item) => { const $item = $(item); const titleElement = $item.find('.s-item__title, .s-card__title, .s-item__title--has-tags'); - const title = titleElement.text().replace(/^New Listing/i, ''); + const title = titleElement.text().replace(/^new listing/i, '').trim(); const link = $item.find('.s-item__link, .s-card__link').attr('href'); const price = $item.find('.s-item__price, .s-card__price').text().trim(); - const image = - $item.find('.s-item__image-img img, img.s-item__image-img').attr('src') || - $item.find('.s-item__image-wrapper img').attr('src') || - $item.find('.s-card__image-img img').attr('src') || - $item.find('.s-item__image img').attr('src'); + const imageElement = $item.find('.s-item__image-img img, img.s-item__image-img, .s-item__image-wrapper img, .s-card__image-img img, .s-item__image img, .s-card__link img'); + const image = imageElement.attr('data-src') || imageElement.attr('src'); if (!title || !link || title.toLowerCase().includes('shop on ebay') || price === '') { return null; From 1233ae71a879ae5e9e2ae1da4bf128b47b8b9b3d Mon Sep 17 00:00:00 2001 From: phoeagon Date: Sun, 8 Mar 2026 18:43:07 -0700 Subject: [PATCH 10/10] minor changes to radar config, ebay/search extraction, etc --- lib/routes/ebay/search.ts | 2 +- lib/routes/ebay/user.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/routes/ebay/search.ts b/lib/routes/ebay/search.ts index 705786cb9c16..254e29b23279 100644 --- a/lib/routes/ebay/search.ts +++ b/lib/routes/ebay/search.ts @@ -35,7 +35,7 @@ export const route: Route = { const response = await ofetch(url); const $ = load(response); - const items = $('.srp-results .s-item, .srp-results .s-card, .s-item, .s-card') + const items = $('.srp-results .s-item, .srp-results .s-card, .s-card') .toArray() .map((item) => { const $item = $(item); diff --git a/lib/routes/ebay/user.ts b/lib/routes/ebay/user.ts index 0daec35b6cbb..5f511fe4d4ed 100644 --- a/lib/routes/ebay/user.ts +++ b/lib/routes/ebay/user.ts @@ -18,7 +18,7 @@ export const route: Route = { }, radar: [ { - source: ['ebay.com/usr/:username'], + source: ['ebay.com/usr/'], target: '/user/:username', }, ],