Skip to content

Commit 2aa68e9

Browse files
h4ciantheusaf
andauthored
feat(eBay): add livestream support (#10717)
Signed-off-by: cian <96041079+h4cian@users.noreply.github.com> Co-authored-by: Daniel Lau <32113157+theusaf@users.noreply.github.com>
1 parent a62dc6e commit 2aa68e9

2 files changed

Lines changed: 87 additions & 3 deletions

File tree

websites/E/eBay/metadata.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,44 @@
99
{
1010
"name": "The Gamerzs",
1111
"id": "730142125181894657"
12+
},
13+
{
14+
"name": "cian",
15+
"id": "834863623595229247"
1216
}
1317
],
1418
"service": "eBay",
1519
"description": {
1620
"en": "Buy and sell electronics, cars, fashion apparel, collectibles, sporting goods, digital cameras, baby items, coupons, and everything else on eBay, the world's online marketplace.",
1721
"nl": "Koop en verkoop elektronica, auto's, mode, verzamelobjecten, sportartikelen, digitale camera's, babyartikelen, kortingsbonnen en al het andere op eBay, 's werelds online marktplaats."
1822
},
19-
"url": "www.ebay.com",
23+
"url": [
24+
"www.ebay.com",
25+
"www.ebay.co.uk"
26+
],
2027
"regExp": "^https?[:][/][/]([a-z0-9-]+[.])*ebay([.][a-z]+)+[/]",
21-
"version": "1.4.0",
28+
"version": "1.5.0",
2229
"logo": "https://cdn.rcd.gg/PreMiD/websites/E/eBay/assets/logo.png",
2330
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/E/eBay/assets/thumbnail.png",
2431
"color": "#e53238",
2532
"category": "other",
2633
"tags": [
2734
"store",
28-
"shopping"
35+
"shopping",
36+
"livestream"
2937
],
3038
"settings": [
3139
{
3240
"id": "buttons",
3341
"title": "Show Buttons",
3442
"icon": "fas fa-compress-arrows-alt",
3543
"value": true
44+
},
45+
{
46+
"id": "showLiveDetails",
47+
"title": "Show Live Details",
48+
"icon": "fas fa-broadcast-tower",
49+
"value": true
3650
}
3751
]
3852
}

websites/E/eBay/presence.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,76 @@ presence.on('UpdateData', async () => {
8484

8585
break
8686
}
87+
case 'ebaylive': {
88+
// eBay Live (livestreams) — e.g. /ebaylive/events/<id>/stream
89+
const parts = location.pathname.split('/').filter(Boolean)
90+
// parts[0] === 'ebaylive', parts[1] === 'events' | 'schedule' | etc., parts[2] === id, parts[3] === 'stream'
91+
const subPage = parts[1]
92+
93+
if (subPage === 'events' && parts[2]) {
94+
// Individual livestream page
95+
const title
96+
= document.querySelector('meta[property="og:title"]')?.getAttribute('content')?.trim()
97+
?? document.querySelector('h1')?.textContent?.trim()
98+
?? document.title?.replace(/\s*\|\s*eBay.*$/i, '').trim()
99+
?? 'Livestream'
100+
101+
// Try to grab the seller / host name from the "About" panel
102+
const host
103+
= document.querySelector<HTMLAnchorElement>('a[href*="/usr/"]')?.textContent?.trim()
104+
?? document.querySelector<HTMLAnchorElement>('a[href*="/str/"]')?.textContent?.trim()
105+
?? document.querySelector('[data-testid="host-name"]')?.textContent?.trim()
106+
?? ''
107+
108+
// Try to grab the stream thumbnail / poster image
109+
const thumbnail
110+
= document.querySelector<HTMLMetaElement>('meta[property="og:image"]')?.content
111+
?? document.querySelector<HTMLMetaElement>('meta[name="twitter:image"]')?.content
112+
?? document.querySelector<HTMLVideoElement>('video')?.poster
113+
?? ''
114+
115+
const showLiveDetails = await presence.getSetting<boolean>('showLiveDetails')
116+
117+
if (showLiveDetails) {
118+
presenceData.details = 'Watching a livestream:'
119+
presenceData.state = host ? `${title} — by ${host}` : title
120+
if (thumbnail)
121+
presenceData.largeImageKey = thumbnail
122+
presenceData.smallImageKey = Assets.Live
123+
124+
const sellerUrl = document.querySelector<HTMLAnchorElement>(
125+
'a[href*="/usr/"], a[href*="/str/"]',
126+
)?.href
127+
128+
presenceData.buttons = host && sellerUrl
129+
? [
130+
{ label: 'Watch Stream', url: location.href },
131+
{ label: 'View Seller', url: sellerUrl },
132+
]
133+
: [
134+
{ label: 'Watch Stream', url: location.href },
135+
]
136+
}
137+
else {
138+
// Privacy / minimal mode — just say they're watching eBay Live
139+
presenceData.details = 'Watching an eBay livestream'
140+
}
141+
}
142+
else if (subPage === 'schedule') {
143+
presenceData.details = 'eBay Live'
144+
presenceData.state = 'Browsing the schedule'
145+
}
146+
else if (!subPage) {
147+
// /ebaylive homepage
148+
presenceData.details = 'Browsing eBay Live'
149+
presenceData.state = 'Livestreams'
150+
}
151+
else {
152+
presenceData.details = 'eBay Live'
153+
presenceData.state = subPage
154+
}
155+
break
156+
}
87157
default:
88158
if (location.pathname.includes('/myb/')) {
89159
presenceData.details = 'Viewing their:'

0 commit comments

Comments
 (0)