feat: add VidIQ badge reader with unset selector

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
IgorVolochay
2026-10-25 10:49:23 +03:00
co-authored by Claude Sonnet 5.5
parent b52c847068
commit 10f5c095b2
2 changed files with 46 additions and 0 deletions
+14
View File
@@ -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;
}