1. All Blogs 2. About Me 3. Contact Me 4. Visit My Website 5. Visit My Venture

Part 2: Course Edition: Angular TOC Trees, 16x Video Beacons & Modals

font_size 100%
font
contrast
listen
share

Part 2: Course Edition — Angular TOC Trees, 16× Video Beacons & Modals

On paper, automating a video course player sounds like a ten-line script: grab the <video> element, set video.currentTime = video.duration, and click "Next". If you try that on Infosys Springboard (infyspringboard.onwingspan.com/web/en/viewer/*), two things break right away:

1. Videos finish playing, but the green completion checkmark never shows up: Springboard's Wingspan player wraps HTML5 video inside Video.js and watches playback progress ticks before sending its completion beacon on the ended event. Jumping straight to 100% (video.duration) skips that final playback window and leaves the lesson marked incomplete.

2. The script stops at the end of the first module: Springboard renders its course syllabus using lazy-loaded Angular Material tree nodes (mat-tree-node.ws-player-tree-node). Until you physically click a collapsed module accordion (aria-expanded="false"), the lessons inside that module do not exist in the DOM at all.

In this second part of the Building SpringBored series, we will walk through how SpringBored (Course Edition) handles Angular's TOC tree, why seeking to duration − 3s at 16× speed triggers completion beacons reliably, and how it clicks through reading-duration confirmation modals while skipping every quiz.

Course Edition Automation Pipeline in SpringBored/content.js

1. Expanding Lazy-Loaded Angular Material Trees in 4 Passes

When you open a course in Springboard's /viewer/ player, both module folders and clickable lessons use the exact same HTML element and class: mat-tree-node.ws-player-tree-node. If your script blindly clicks every mat-tree-node in order, it will click an open module folder, collapse it, and hide all the lessons inside!

After inspecting the live DOM across several courses, I noticed a reliable pattern: folder nodes always contain a child mat-icon.toc-expand-icon, while actual clickable lessons never have that icon. Even better, because some courses nest sub-folders inside parent modules, expanding a top-level folder can mount a second layer of collapsed folders (aria-expanded="false") that weren't in the DOM a moment earlier.

To make sure every lesson in the course is mounted in the DOM before the runner starts, expandAllFolders() runs up to four expansion passes until no collapsed folder nodes remain, and collectLessons() filters strictly for leaf nodes:

// STEP 2: Expand all collapsed folder/module nodes across nested levels
async function expandAllFolders() {
  const toc = document.querySelector('.viewer-toc-container, .toc-container');
  if (!toc) return;

  for (let pass = 0; pass < 4; pass++) {
    if (!isRunning || isPaused) break;
    const collapsedFolders = [...toc.querySelectorAll(
      'mat-tree-node.ws-player-tree-node[aria-expanded="false"]'
    )].filter(node => !!node.querySelector('mat-icon.toc-expand-icon'));

    if (collapsedFolders.length === 0) break;

    for (const folder of collapsedFolders) {
      if (!isRunning || isPaused) break;
      const toggle = folder.querySelector('mat-icon.toc-expand-icon, button') || folder;
      toggle.click();
      emitTelemetry('module_completed', { modules: 1 });
      await sleep(350);
    }
    await sleep(500);
  }
}

// STEP 3: Collect only leaf lesson items (nodes WITHOUT toc-expand-icon)
function collectLessons() {
  const toc = document.querySelector('.viewer-toc-container, .toc-container');
  if (!toc) return [];

  const allNodes = [...toc.querySelectorAll('mat-tree-node.ws-player-tree-node')];
  if (allNodes.length > 0) {
    return allNodes.filter(node => !node.querySelector('mat-icon.toc-expand-icon'));
  }
  return [];
}

Skipping Quizzes and Graded Assessments

Before Course Edition clicks any leaf node, it runs two checks:

  • isCompleted(el): Checks whether the node already has a completion badge (mat-icon.tick, mat-icon.done, ws-viewer-icon[status="completed"]) and no pending Mark as Complete button. If it's already done, it skips right past it.
  • isAssignment(el): Checks both the lesson title and the ws-viewer-icon type attribute for assignment, quiz, or assessment. If it matches, Course Edition increments the skipped counter in the popup and leaves the assessment untouched.

2. Why Seeking to duration − 3s at 16× Speed Works Every Time

When moving from one video lecture to the next in an Angular single-page app, there is a subtle race condition: for the first 1–2 seconds after you click "Next", the previous lecture's <video> element often stays in the DOM with video.ended === true while Angular fetches the new video stream. If your script checks document.querySelector('video') immediately, it sees video.ended === true from the old video and thinks the new lecture is already finished!

Inside handleContent(), we guard against that stale video element during the first 3.5s (if (video.ended && video.currentTime >= video.duration - 0.5 && elapsed < 3500) continue;). Once the new video reports readyState >= 2 and a valid duration, we do three things:

1. Mute and accelerate to 16×: Set video.muted = true and video.playbackRate = 16, then call video.play().

2. Seek to Math.max(0, dur - 3) on both <video> and Video.js: Instead of jumping to dur, we seek to 3 seconds before the end on both the native HTML5 <video> element and window.videojs.getPlayers().

3. Let the final 3 seconds play out in ~187ms: At 16× speed, 3 seconds of video takes less than a fifth of a second to play through naturally. That short window fires normal timeupdate events followed by the genuine native ended event—which triggers Wingspan's completion beacon every single time:

const dur = video.duration;
lastVideoDurationSec = Math.round(dur);

video.muted = true;
try { video.playbackRate = 16; } catch (_) {}
if (video.paused) {
  try { await video.play(); } catch (_) {}
}

const seekTo = Math.max(0, dur - 3);
await sleep(150);

// Update both the native <video> element and Video.js if present
video.currentTime = seekTo;
try {
  if (window.videojs) {
    const players = window.videojs.getPlayers && window.videojs.getPlayers();
    const vjsPlayer = players && Object.values(players)[0];
    if (vjsPlayer) vjsPlayer.currentTime(seekTo);
  }
} catch (_) {}

return await waitForVideoEnd(video);

Once waitForVideoEnd() sees video.ended, it waits 1000ms so the network beacon finishes sending, adds lastVideoDurationSec to your Time Saved stat in the popup, and clicks the forward navigation arrow (button[aria-label="next content"] or button.navigation-btn-frwd).

3. Handling Reading Slides & "Learning Duration" Modals

Courses also include PDFs, web pages, and reading modules that don't have a <video> tag. Instead, they have a Mark as Complete button. If you click Mark as Complete right after opening a reading slide, Springboard pops up an Angular CDK modal dialog (mat-dialog-container inside .cdk-overlay-pane) asking you to confirm that you have completed the learning duration.

markContentAsComplete() and confirmDialogIfPresent() handle both clicks automatically:

1. Find and click Mark as Complete: Searches the lesson node, active TOC item, and document for enabled buttons whose mattooltip, aria-label, title, or text matches Mark as Complete (while ignoring Cancel buttons).

2. Auto-confirm the CDK dialog: Polls every 200ms (up to 8 times) for any visible mat-dialog-container or [role="dialog"] mentioning mark as complete, learning content, learning duration, or confirm, and clicks the primary confirmation button (Confirm, Yes, or Mark as complete).

Practical Tips

  • Keep the Springboard tab visible on screen: Chrome throttles setTimeout and HTML5 media events in minimized windows or background tabs. Leaving the Springboard tab in the foreground (even in a side window) keeps the 16× loop running at full speed.
  • Pause and Resume anytime: Clicking Pause in the popup pauses the active <video> element and holds the loop in waitWhilePaused() while keeping your progress bar (lastProgress) intact, so Resume continues right where you left off.

Series Navigation: ← Previous: Part 1: Splitting the Extensions, Manifest V3 & the Botanical Forest UI | Next: Part 3: Assessment Solver I — DOM Scraping, Gemini Fallback & Two-Pass Critic → | All Articles

ojas@blog:~$ share_post --id #blog_2026_25
post linkedin whatsapp

← Back to all articles