updated getRSSItemTitle and getJsonFeedItemTitle to remove markdownCharEscape usage

This commit is contained in:
dylan 2025-12-25 20:01:35 +00:00
parent a3ed5a4a82
commit 904637fb56

View file

@ -42,12 +42,10 @@ export async function getRSSItemTitle(feedUrl) {
const item = dom.window.document.querySelector('item')
const title = item.querySelector('title').textContent
const link = item.querySelector('link').textContent.trim()
const cleanTitle = markdownCharEscape(
sanitizeHtml(title, {
allowedTags: [],
allowedAttributes: {},
})?.trim(),
)
const cleanTitle = sanitizeHtml(title, {
allowedTags: [],
allowedAttributes: {},
})?.trim()
return { text: cleanTitle, url: link }
}
@ -56,12 +54,11 @@ export async function getJsonFeedItemTitle(feedUrl, showImage = true) {
const data = await res.json()
const post = data.items[0]
const { title, image, url } = post
const cleanTitle = markdownCharEscape(title)
const text = !showImage
? cleanTitle
? title
: image
? `${cleanTitle} ![${cleanTitle}](${image})`
: cleanTitle
? `${title} ![${title}](${image})`
: title
return { text, url }
}
@ -69,16 +66,17 @@ export async function getJsonFeedItemContent(feedUrl, showImage = true) {
const res = await fetch(feedUrl)
const data = await res.json()
const post = data.items[0]
const { content_html, image } = post
const { content_html, image, url } = post
const title = sanitizeHtml(content_html, {
allowedTags: [],
allowedAttributes: {},
})?.trim()
const cleanTitle = markdownCharEscape(title)
if (!showImage) {
return cleanTitle
}
return image ? `${cleanTitle} ![${cleanTitle}](${image})` : cleanTitle
const text = !showImage
? title
: image
? `${title} ![${title}](${image})`
: title
return { text, url }
}
export async function getMalojaScrobble(malojaUrl) {
@ -89,9 +87,7 @@ export async function getMalojaScrobble(malojaUrl) {
title,
album: { artists },
} = scrobble.track
const cleanTitle = markdownCharEscape(title)
const cleanArtists = markdownCharEscape(artists.join(', '))
return markdownCharEscape(`${cleanTitle}<br />by ${cleanArtists}`)
return `${title}<br />by ${artists.join(', ')}`
}
export async function getLetterboxdActivity(username, showImage = true) {
@ -101,15 +97,14 @@ export async function getLetterboxdActivity(username, showImage = true) {
const item = dom.window.document.querySelector('item')
const title = item.querySelector('title').textContent
const link = item.querySelector('link').textContent.trim()
const cleanTitle = markdownCharEscape(title)
let text = cleanTitle
let text = title
if (showImage) {
// 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}](${image})` : cleanTitle
text = image ? `${title} ![${title}](${image})` : title
}
return { text, url: link }
@ -124,10 +119,9 @@ export async function getTraktEpisode(username, id, showImage = true) {
const entry = dom.window.document.querySelector('entry')
const title = entry.querySelector('title').textContent
const link = entry.querySelector('link').getAttribute('href')
const cleanTitle = markdownCharEscape(title)
const text = !showImage
? cleanTitle
: `${cleanTitle} ![${cleanTitle}](https://widgets.trakt.tv/users/${id}/watched/thumb@2x.jpg?type=episode&image_only=1)`
? title
: `${title} ![${title}](https://widgets.trakt.tv/users/${id}/watched/thumb@2x.jpg?type=episode&image_only=1)`
return { text, url: link }
}
@ -140,7 +134,7 @@ export async function getTraktMovie(username, showImage = true) {
const entry = dom.window.document.querySelector('entry')
const title = entry.querySelector('title').textContent
const link = entry.querySelector('link').getAttribute('href')
return { text: markdownCharEscape(title), url: link }
return { text: title, url: link }
}
export async function getTraktEpisodeAndMovie(username, id, showImage = true) {