Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mf-6014 don't replace tweets that have embed images #11657

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ function resolveLangNode(node: HTMLElement) {
}

export function injectPostReplacerAtTwitter(signal: AbortSignal, current: PostInfo) {
const isPromotionPost = !!current.rootNode?.querySelector('svg path[d$="996V8h7v7z"]')
const isCollapsedPost = !!current.rootNode?.querySelector('[data-testid="tweet-text-show-more-link"]')
const rootNode = current.rootNode
if (!rootNode) return
const isPromotionPost = !!rootNode.querySelector('svg path[d$="996V8h7v7z"]')
const isCollapsedPost = !!rootNode.querySelector('[data-testid="tweet-text-show-more-link"]')
if (isPromotionPost || isCollapsedPost) return

const hasVideo = !!current.rootNode?.closest('[data-testid="tweet"]')?.querySelector('video')
const hasVideo = !!rootNode.closest('[data-testid="tweet"]')?.querySelector('video')
if (hasVideo) return
const hasEmbedImage = !!rootNode.querySelector('[data-testid="tweetText"] [data-testid="tweetPhoto"]')
if (hasEmbedImage) return

const tags = Array.from(
current.rootNode?.querySelectorAll<HTMLAnchorElement>(
rootNode.querySelectorAll<HTMLAnchorElement>(
['a[role="link"][href*="cashtag_click"]', 'a[role="link"][href*="hashtag_click"]'].join(','),
) ?? [],
)
Expand Down
Loading