Inside Ski's 8-Signal Heuristic Engine: Building a Self-Healing Extension
One of the biggest hazards in browser extension development is DOM fragility. YouTube frequently redesigns its player, rotates class names, and tests experimental Polymer layouts across different A/B user buckets.
If an extension relies solely on hardcoded CSS selectors like '.ytp-ad-skip-button-modern', it will inevitably break as soon as YouTube rolls out an update.
To solve this, Ski Extension implements an 8-signal heuristic detector. When an ad is playing, every candidate interactive element inside the player is scored based on weighted criteria:
1. Skip Text Match (0.30 weight): Multilingual match across 30+ languages (Skip, Passer, Saltar, Überspringen, etc.). 2. Player Geometry (0.15 weight): Skip buttons reside in the bottom-right quadrant. 3. Class Name Hints (0.12 weight): Subtle semantic traces like 'skip' or 'ad'. 4. Hierarchy Proximity (0.13 weight): Enclosed inside ad overlay containers. 5. Element Type (0.10 weight): <button> or role='button' elements. 6. Text Length (0.10 weight): Short, imperative action text (under 20 characters). 7. ARIA Label Match (0.05 weight): Screen-reader accessible attributes. 8. Physical Dimensions (0.05 weight): Valid clickable button area.
When the cumulative score exceeds the 0.55 threshold, Ski identifies the element and automatically persists the newly discovered selector to storage for instant execution next time. This self-healing architecture ensures Ski continues working even after major YouTube redesigns.