feat: add VidIQ badge reader with unset selector
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
b52c847068
commit
10f5c095b2
@@ -0,0 +1,14 @@
|
||||
// CSS selector of VidIQ's outlier badge on a video card. It stays null until the real
|
||||
// markup is captured (Task 15); until then readVidiqScore returns null for every card.
|
||||
export const VIDIQ_BADGE_SELECTOR = null;
|
||||
|
||||
export function parseVidiqScore(text) {
|
||||
const match = /(\d+(?:[.,]\d+)?)/.exec(text ?? '');
|
||||
return match ? Number(match[1].replace(',', '.')) : null;
|
||||
}
|
||||
|
||||
export function readVidiqScore(card, selector = VIDIQ_BADGE_SELECTOR) {
|
||||
if (!selector || !card) return null;
|
||||
const badge = card.querySelector(selector);
|
||||
return badge ? parseVidiqScore(badge.textContent) : null;
|
||||
}
|
||||
Reference in New Issue
Block a user