Repository navigation
docs(skill): userscript 反应式改动优先 Observer,定时器仅作有界兜底 - #135
Merged
Merged
Conversation
The userscript reactivity section only said to prefer a MutationObserver over polling "to wait for an element". It was silent on the geometry/animation-tracking case, which is exactly where a self-scheduling requestAnimationFrame loop creeps in and burns a core on an idle page (a shipped bilibili card-blocker did this). Expand it into "Reacting to change: observers first": a signal -> observer table (MutationObserver, ResizeObserver, IntersectionObserver, PerformanceObserver, ReportingObserver, plus the event-based matchMedia/visualViewport/navigation equivalents), the fallback ladder (observer -> discrete event -> one-shot setTimeout -> bounded rAF), the anti-patterns, and the cases that have no observer at all. Point --print-skill's Userscripts section at the new section. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
MutationObserver而不是轮询」,扩成完整的 observers first 章节:按信号选 observer 的对照表(MutationObserver/ResizeObserver/IntersectionObserver/PerformanceObserver/ReportingObserver,以及matchMedia、visualViewport、navigation这类事件型等价物)。setTimeout→ 有界requestAnimationFrame;并明确禁止setInterval轮询与无界自续 rAF。--print-skill的 Userscripts 段改为指向新章节,并列出五个 observer 与「neversetIntervalor an unbounded rAF loop」。背景:旧章节只覆盖「等 SPA 元素」,对「按帧跟踪元素几何/动画」是空白,正是无界 rAF 容易混进来的地方;本次先把规则写进文档。
无关联 issue。
测试证明
mise run test(daemon + skill + evals + pi 全绿):mise run test
界面证据
N/A:无界面改动
检查项
🤖 Generated with Claude Code