|
| 1 | +// breadcrumb.js — Auto-inject navigation breadcrumb on mission pages |
| 2 | +const PAGE_NAMES = { |
| 3 | + 'phishing': 'Phishing Detective', |
| 4 | + 'social': 'Social Engineering', |
| 5 | + 'smishing': 'Smishing Simulator', |
| 6 | + 'ai': 'AI Crime Lab', |
| 7 | + 'malware': 'Malware Escape', |
| 8 | + 'password': 'Password Lab', |
| 9 | + 'darkweb': 'Dark Web Market', |
| 10 | + 'daily': 'Daily Challenge', |
| 11 | + 'incident': 'Incident Response', |
| 12 | + 'creator': 'Mission Creator', |
| 13 | + 'wiki': 'Cyber-Wiki', |
| 14 | + 'login': 'Login', |
| 15 | + 'index': 'Hub', |
| 16 | + 'hub': 'Hub' |
| 17 | +}; |
| 18 | + |
| 19 | +function injectBreadcrumb() { |
| 20 | + if (document.getElementById('breadcrumb')) return; |
| 21 | + |
| 22 | + const path = window.location.pathname.split('/').pop().replace('.html', '') || 'index'; |
| 23 | + if (['hub', 'index', 'login', ''].includes(path)) return; |
| 24 | + |
| 25 | + const crumb = document.createElement('div'); |
| 26 | + crumb.id = 'breadcrumb'; |
| 27 | + crumb.style.cssText = 'font-size:11px;color:#666;margin-bottom:10px;text-align:left;'; |
| 28 | + crumb.innerHTML = `<a href="hub.html" style="color:#666;text-decoration:none;" onmouseover="this.style.color='var(--neon-cyan)'" onmouseout="this.style.color='#666'">Hub</a> <span style="color:#444;">›</span> <span style="color:var(--neon-cyan);">${PAGE_NAMES[path] || path}</span>`; |
| 29 | + |
| 30 | + const container = document.querySelector('.container'); |
| 31 | + if (!container) return; |
| 32 | + const backBtn = container.querySelector('.back-btn'); |
| 33 | + if (backBtn) backBtn.insertAdjacentElement('afterend', crumb); |
| 34 | + else container.prepend(crumb); |
| 35 | +} |
| 36 | + |
| 37 | +document.addEventListener('DOMContentLoaded', injectBreadcrumb); |
0 commit comments