updated getLetterboxdActivity to conditionally include image in returned text
This commit is contained in:
parent
c7717e6d29
commit
360465395a
1 changed files with 10 additions and 4 deletions
14
utils.js
14
utils.js
|
|
@ -102,10 +102,16 @@ export async function getLetterboxdActivity(username, showImage = true) {
|
||||||
const title = item.querySelector('title').textContent
|
const title = item.querySelector('title').textContent
|
||||||
const link = item.querySelector('link').textContent.trim()
|
const link = item.querySelector('link').textContent.trim()
|
||||||
const cleanTitle = markdownCharEscape(title)
|
const cleanTitle = markdownCharEscape(title)
|
||||||
const image = item.querySelector('description > img').src
|
|
||||||
const text = !showImage
|
let text = cleanTitle
|
||||||
? cleanTitle
|
if (showImage) {
|
||||||
: `${cleanTitle} `
|
// Parse CDATA content as HTML to extract image
|
||||||
|
const description = item.querySelector('description').textContent
|
||||||
|
const imgMatch = description.match(/<img[^>]+src="([^"]+)"/)
|
||||||
|
const image = imgMatch ? imgMatch[1] : null
|
||||||
|
text = image ? `${cleanTitle} ` : cleanTitle
|
||||||
|
}
|
||||||
|
|
||||||
return { text, url: link }
|
return { text, url: link }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue