Description
The mainScript can be executed multiple times due to:
- webNavigation triggers
- GitHub SPA navigation
- manual reinjection
Issues caused
- Duplicate polling loops (setInterval)
- Multiple requestAnimationFrame loops
- Re-attached event listeners
- Unpredictable behavior and performance degradation
Expected Behavior
Script should initialize only once per page lifecycle.
Proposed Fix
Add a global guard at the top of the script:
if (window.__ghSingleFileInitialized) return;
window.__ghSingleFileInitialized = true;
Why this matters
- Prevents memory leaks
- Ensures deterministic behavior
- Required for Chrome Web Store quality standards
Description
The mainScript can be executed multiple times due to:
Issues caused
Expected Behavior
Script should initialize only once per page lifecycle.
Proposed Fix
Add a global guard at the top of the script:
Why this matters