chore: selector audit, feed-filter test suite, release v1.17.0 #50
Loading…
Reference in a new issue
No description provided.
Delete branch "refs/pull/50/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Follow-up to #49, closing the two gaps that review surfaced: nothing detects a dead selector, and the DOM-facing code had no test coverage. Also cuts v1.17.0 and refreshes the site's manual-install download.
Selector audit
Run on any YouTube page:
Prints a table of the selectors the extension depends on with a live match count, and warns on any that found nothing where they should. It cannot prove a selector is correct, only that it is still alive — but a renamed class currently produces no error whatsoever, which is precisely how the members-badge filter stayed broken through a release. Invalid selectors (e.g.
:has()unsupported) are reported separately from dead ones, and entries that legitimately match nothing on a clean feed (promo shelves, ad slots) are marked optional so they never cry wolf.The registry lives in
defaults.jsnext to the selectors it audits, so adding a selector and forgetting to audit it is visible in one place.Tests: 24 → 60
test/feed-text.test.jstest/feed-dom.test.jstest/shared-globals.test.jsglobalThis.FY_*a script depends on is actually exportedTwo of these earn their keep immediately:
the legacy-only badge selectors match nothing (why the filter died)pins the original regression against live markup, so it cannot silently return.shared-globalscatches renames in theFY_*contract. Those resolve at runtime with no import to typo-check them, so a mistake otherwise shows up as a TypeError in a user's browser. It caught a real mistake while I was writing it —FY_I18Ncomes fromi18n.js, notdefaults.js.The DOM fixture is built from the live "Get more from memberships" markup. Writing it also exposed that my first draft had no video titles, which the audit test flagged — an unrepresentative fixture is worse than none.
Shared DOM surface (the refactor)
My scratch harnesses sliced source text out of
content.js, and that broke once mid-session when I reformatted an array. Committing that brittleness would have made the tests a liability. So the selectors, badge tokens and relative-date parser moved into a documented "YouTube DOM surface" section indefaults.js— the repo's existing home for shared testable helpers (FY_MATCHES_COMMENT_FILTERS,FY_NORMALIZE_MEMBERS_FIRST_CHANNELS).The filters, the tests and the audit now read the same values rather than three copies that drift apart.
content.jskeeps hoisted delegating wrappers, so no call sites changed and there is no TDZ risk;defaults.jsalready loads beforecontent.jsin all three content-script contexts per the manifest.Notes for review
jsdomis the first devDependency, used only byfeed-dom.test.js. The higher-value assertions are pure and need no browser environment.node_modules/was not in.gitignore— added before it could be committed.package-lock.jsonis now tracked for reproducible dev installs; say the word if you'd rather it weren't.Test plan
npm test— 60/60node --checkon all touched scriptstest/,node_modules/,website/or.DS_Storeleakagedefaults.jsmove__CW_AUDIT_SELECTORS__()on a live home page and a watch page