Automate online law course video watching on 律师云学院 (lawschool.lawyerpass.com). Use when a user needs to automatically play through a list of training videos,...
Automates video playback across multiple courses on lawschool.lawyerpass.com using the browser tool (Chrome profile via Browser Relay) and a persistent state file + cron job for long-running monitoring.
video_state.json): tracks progress, current video, queuevideo-check-loop): fires every 8 minutes, checks video status, switches when doneprofile=chrome, targetId from state filereferences/workflow.md for the full step-by-step procedurereferences/known-issues.md for critical gotchas before startinghttps://lawschool.lawyerpass.com/course/list/course/detail?courseId=<id>app-lesson-card.square-itemdocument.querySelector('video')Course cards use Angular Router — no href on <a> tags. Intercept history.pushState:
let captured = '';
const orig = window.history.pushState.bind(window.history);
window.history.pushState = function(s, t, url) { captured = url; orig(s, t, url); };
[...document.querySelectorAll('app-lesson-card.square-item')]
.find(c => c.textContent.includes('课程标题关键词'))
?.querySelector('a')?.click();
return captured; // returns "/course/detail?courseId=d5b19f94..."
Then navigate to https://lawschool.lawyerpass.com + captured path.
Some courses from 课程广场 require enrollment before video appears:
// Step 1: Check and click enrollment button
const btn = [...document.querySelectorAll('button, a, [class*=btn]')]
.find(el => el.textContent.includes('选修并学习'));
if (btn) { btn.click(); return 'clicked_enroll'; }
return 'no_enroll_btn';
If clicked → wait 3s → confirm dialog:
const confirm = [...document.querySelectorAll('button, [class*=btn], [class*=confirm]')]
.find(el => el.textContent.match(/确定|确认|OK/));
confirm?.click();
Wait 3s more, then video.play().
const v = document.querySelector('video');
if (!v) return JSON.stringify({ found: false, url: location.href });
return JSON.stringify({
found: true,
ct: Math.round(v.currentTime),
dur: Math.round(v.duration),
paused: v.paused,
ended: v.ended,
url: location.href
});
Completion condition: ended === true OR ct >= dur - 3
Note: Some videos stop with
ended=falsebutct === dur— always check both.
{
"schedule": { "kind": "every", "everyMs": 480000 },
"sessionTarget": "isolated",
"payload": { "kind": "agentTurn", "timeoutSeconds": 120 }
}
⚠️ Do NOT use everyMs < 300000 (5 min) — causes API rate limit errors.
See references/state-schema.md for the full video_state.json schema.
Use scripts/lawschool_init_state.py to generate an initial state file.
Use message tool on every video complete and every video start:
✅ 播完:{title}({done}/{total})▶ 开始:{title},{duration},第{done+1}/{total}门🎉 全部{total}门完成!| File | When to read |
|---|---|
references/workflow.md | Full step-by-step setup and monitoring loop |
references/state-schema.md | State file fields and update rules |
references/known-issues.md | Before starting — critical gotchas |
ZIP package — ready to use