- Bug Location:
player.js:743 - Root Cause: Missing DOM element IDs
статистика-сжатиевидеоandстатистика-сервер - Impact: Crash during error reporting, prevents crash reports from being generated
- Severity: HIGH - Breaks error reporting system
Location: /home/vercel-sandbox/twitch_alternate_player/player.html
Change 1 - Line 67-68 (Video Compression):
<!-- BEFORE: -->
<!-- <span id=статистика-сжатиевидео title="Параметры сжатия видео: стандарт сжатия, профиль, уровень, максимальное количество опорных кадров, диапазон, частота кадров"></span> -->
<span id=statistics-videocompression title="Video compression parameters: compression standard, profile, level, maximum number of reference frames, range, frame rate"></span>
<!-- AFTER: -->
<span id=статистика-сжатиевидео title="Параметры сжатия видео: стандарт сжатия, профиль, уровень, максимальное количество опорных кадров, диапазон, частота кадров"></span>
<span id=statistics-videocompression title="Video compression parameters: compression standard, profile, level, maximum number of reference frames, range, frame rate"></span>Change 2 - Line 89-90 (Server):
<!-- BEFORE: -->
<!-- <span id=статистика-сервер data-очистить="" title="Сервер, с которого загружается видео"></span> -->
<span id=statistics-server data-clear="" title="The server from which the video is downloaded"></span>
<!-- AFTER: -->
<span id=статистика-сервер data-очистить="" title="Сервер, с которого загружается видео"></span>
<span id=statistics-server data-clear="" title="The server from which the video is downloaded"></span>- Reload extension in Chrome:
chrome://extensions→ click reload icon - Navigate to a Twitch channel
- Press 'S' key to open statistics overlay
- Verify no console errors
- Check that statistics display correctly
Pros:
- ✅ Immediate fix, no code changes
- ✅ Minimal risk
- ✅ Maintains backward compatibility
- ✅ Can be deployed immediately
Cons:
- ❌ Creates duplicate elements in DOM (small memory overhead)
- ❌ Doesn't advance translation effort
- ❌ Temporary solution, not final fix
Location: /home/vercel-sandbox/twitch_alternate_player/player.js
Change 1 - Line 1846 (ПолучитьДанныеДляОтчета):
// BEFORE:
ПараметрыВидео:
Узел("статистика-разрешениевидео").textContent +
" " +
Узел("статистика-сжатиевидео").textContent,
// AFTER:
ПараметрыВидео:
Узел("статистика-разрешениевидео").textContent +
" " +
Узел("statistics-videocompression").textContent,Change 2 - Line 1865 (РазобранСписокСегментов):
// BEFORE:
Узел("статистика-сервер").textContent = new URL(
оСписок.моСегменты[оСписок.моСегменты.length - 1].сАдрес
).host;
// AFTER:
Узел("statistics-server").textContent = new URL(
оСписок.моСегменты[оСписок.моСегменты.length - 1].сАдрес
).host;Change 3 - Line 1995 (ПолученСегмент):
// BEFORE:
Узел("статистика-сжатиевидео").textContent = сСжатиеВидео;
// AFTER:
Узел("statistics-videocompression").textContent = сСжатиеВидео;Change 4 - Line 2000 (ПолученСегмент):
// BEFORE:
Узел("статистика-сжатиевидео").textContent = "—";
// AFTER:
Узел("statistics-videocompression").textContent = "—";Line 67 - Remove:
<!-- <span id=статистика-сжатиевидео title="..."></span> -->Line 89 - Remove:
<!-- <span id=статистика-сервер data-очистить="" title="..."></span> -->- Reload extension
- Navigate to Twitch channel
- Press 'S' key for statistics overlay
- Verify all statistics display correctly
- Check video codec info appears when stream loads
- Check server name appears in statistics
- Test with both English and Russian browser locales
- Trigger error reporting (if possible) to verify crash reporting works
Pros:
- ✅ Completes the translation for these elements
- ✅ Aligns with CLAUDE.md translation goals
- ✅ No duplicate DOM elements
- ✅ Final solution, not temporary
Cons:
- ❌ More changes = higher risk
- ❌ Requires more comprehensive testing
- ❌ Should be part of larger translation effort
Location: /home/vercel-sandbox/twitch_alternate_player/common.js
Line: 216-224
// BEFORE:
function Узел(пЭлемент) {
// function Node(pElement) {
const элЭлемент = typeof пЭлемент == 'string' ? document.getElementById(пЭлемент) : пЭлемент;
// const elElement = typeof pElement == 'string' ? document.getElementById(pElement) : pElement;
Проверить(элЭлемент.nodeType === 1);
// Check(elElement.nodeType === 1);
return элЭлемент;
// return elElement;
}
// AFTER:
function Узел(пЭлемент) {
// function Node(pElement) {
const элЭлемент = typeof пЭлемент == 'string' ? document.getElementById(пЭлемент) : пЭлемент;
// const elElement = typeof pElement == 'string' ? document.getElementById(pElement) : pElement;
if (!элЭлемент) {
console.warn(`⚠️ Element not found: ${пЭлемент}`);
// Return stub element to prevent crashes
const stubElement = document.createElement('span');
stubElement.textContent = '';
stubElement.style.display = 'none';
return stubElement;
}
Проверить(элЭлемент.nodeType === 1);
// Check(elElement.nodeType === 1);
return элЭлемент;
// return elElement;
}This defensive coding should be applied in addition to either Option 1 or Option 2, not as a replacement.
Pros:
- ✅ Prevents crashes from any missing element
- ✅ Logs warnings for debugging
- ✅ Graceful degradation
- ✅ Catches future translation issues
Cons:
- ❌ Masks the real problem
- ❌ May hide bugs during development
- ❌ Adds runtime overhead (minimal)
- ❌ Console warnings on every access to missing element
Apply Fix Option 1 - Restore missing Russian IDs
- Time: 5 minutes
- Risk: Very Low
- Gets system working immediately
Apply Fix Option 3 - Add defensive coding
- Time: 10 minutes
- Risk: Low
- Prevents similar issues in future
Apply Fix Option 2 - Update JavaScript to English IDs
- Time: 30 minutes + testing
- Risk: Medium
- Part of comprehensive translation effort
- Should be done as atomic commit with related changes
fix(player): restore missing statistics element IDs
Restore commented-out Russian element IDs to fix crash in statistics
overlay initialization at player.js:743.
- Uncomment статистика-сжатиевидео in player.html:67
- Uncomment статистика-сервер in player.html:89
- Both elements now have duplicate IDs (Russian + English)
- Temporary fix until JavaScript translation is complete
Fixes: TypeError at player.js:743 in ПолучитьДанныеДляОтчета()
Related: Translation effort documented in CLAUDE.md
translate(player): update statistics IDs to English
Complete the translation of statistics element IDs from Russian to English.
Updates JavaScript references to match the English IDs already in player.html.
Changes:
- player.js:1846: статистика-сжатиевидео → statistics-videocompression
- player.js:1865: статистика-сервер → statistics-server
- player.js:1995: статистика-сжатиевидео → statistics-videocompression
- player.js:2000: статистика-сжатиевидео → statistics-videocompression
- Remove commented-out Russian IDs from player.html
Fixes: TypeError at player.js:743
Part of: Russian → English translation effort (CLAUDE.md)
fix(common): add defensive check in Узел() function
Add null-check to Узел() function to prevent crashes when
element IDs are missing from DOM.
- Returns stub element instead of crashing on null
- Logs warning to console for debugging
- Prevents secondary crashes during error reporting
Related: player.js:743 crash during statistics initialization
- Extension loads without errors
- Can navigate to Twitch channel
- Statistics overlay opens with 'S' key
- No console errors when opening statistics
- Video codec info displays correctly
- Server name displays correctly
- Audio codec info displays correctly
- Open statistics overlay before stream loads
- Open statistics overlay during stream playback
- Open statistics overlay after stream ends
- Switch between streams with overlay open
- Test with different video qualities
- Test with English browser locale
- Test with Russian browser locale
- Verify correct i18n strings display
- Verify crash reports can be generated
- Check that statistics data is included in reports
- Verify no secondary crashes during error reporting
grep -n "id=статистика-" player.htmlgrep -n 'Узел("статистика-' player.jsgrep -n "id=statistics-" player.html# Should find 4 occurrences in player.js:
grep -c "статистика-сжатиевидео" player.js
# Should find 1 occurrence in player.js:
grep -c "статистика-сервер" player.jsIf issues occur after applying any fix:
Simply re-comment out the restored elements in player.html
git revert <commit-hash>
# Then apply Option 1 as emergency fixgit revert <commit-hash>
# System returns to original behavior (will crash on missing elements)/home/vercel-sandbox/twitch_alternate_player/player.js- Main player logic/home/vercel-sandbox/twitch_alternate_player/player.html- Player UI with statistics overlay/home/vercel-sandbox/twitch_alternate_player/common.js- Shared utilities including Узел()/home/vercel-sandbox/twitch_alternate_player/CLAUDE.md- Translation plan and guidelines/home/vercel-sandbox/twitch_alternate_player/Documentation/legacy_code_translation_reference.md- Translation glossary
HTML allows multiple elements with the same content but different IDs. Having both Russian and English IDs pointing to separate <span> elements is valid and won't cause conflicts. The elements will display the same content since JavaScript will write to both (if both are accessed).
Each additional <span> element is approximately 100-200 bytes. Adding 2 duplicate elements adds ~400 bytes to DOM, which is negligible.
document.getElementById() is O(1) operation. Having duplicate IDs doesn't impact lookup performance.
Once all JavaScript is translated to use English IDs, the Russian ID elements can be safely removed in a cleanup commit.