77
88 console . log ( '🎵 MUSIC PLAYER SCRIPT STARTING - Loading enhanced music player...' ) ;
99
10+ // Immediate visibility test - create a simple test element
11+ const testElement = document . createElement ( 'div' ) ;
12+ testElement . id = 'mera-music-test' ;
13+ testElement . style . cssText = `
14+ position: fixed;
15+ top: 10px;
16+ right: 10px;
17+ background: red;
18+ color: white;
19+ padding: 5px;
20+ z-index: 999999;
21+ font-size: 12px;
22+ ` ;
23+ testElement . textContent = '🎵 MUSIC SCRIPT LOADED' ;
24+ document . body . appendChild ( testElement ) ;
25+
26+ // Remove test element after 3 seconds
27+ setTimeout ( ( ) => {
28+ if ( testElement . parentNode ) {
29+ testElement . parentNode . removeChild ( testElement ) ;
30+ }
31+ } , 3000 ) ;
32+
1033 // Track script execution count to detect reloads
1134 if ( typeof window . meraScriptCounter === 'undefined' ) {
1235 window . meraScriptCounter = 0 ;
9841007
9851008 // Create the enhanced persistent top bar
9861009 function createTopBar ( ) {
987- if ( document . getElementById ( 'mera - top - bar ') ) {
988- return ;
989- }
1010+ try {
1011+ console . log ( '🎵 createTopBar ( ) called ') ;
1012+ if ( document . getElementById ( 'mera - top - bar ') ) {
1013+ console . log ( '🎵 Top bar already exists , skipping creation ') ;
1014+ return ;
1015+ }
1016+ console . log ( '🎵 Creating new top bar ...') ;
9901017
9911018 const topBar = document . createElement ( 'div ') ;
9921019 topBar . id = 'mera - top - bar ';
10661093 setupEventListeners ( ) ;
10671094 updateUI ( ) ;
10681095
1069- console . log ( '🎵 Enhanced persistent music player top bar created ') ;
1096+ console . log ( '🎵 Enhanced persistent music player top bar created successfully ') ;
1097+ } catch ( error ) {
1098+ console . error ( '🎵 Failed to create top bar :', error ) ;
1099+ // Try creating a minimal fallback bar
1100+ try {
1101+ console . log ( '🎵 Attempting minimal fallback top bar ...') ;
1102+ const fallbackBar = document . createElement ( 'div ') ;
1103+ fallbackBar . id = 'mera - top - bar ';
1104+ fallbackBar . style . cssText = 'position : fixed ; top : 0 ; left : 0 ; right : 0 ; height : 40 px ; background : #666 ; color : white ; display : flex ; align - items : center ; padding : 0 20 px ; z - index : 999999 ; ';
1105+ fallbackBar . innerHTML = '< span > 🎵 MERA Music ( Minimal ) </span > ';
1106+ document . body . insertBefore ( fallbackBar , document . body . firstChild ) ;
1107+ document . body . style . paddingTop = '45 px ';
1108+ console . log ( '🎵 Minimal fallback top bar created ') ;
1109+ } catch ( fallbackError ) {
1110+ console . error ( '🎵 Even minimal fallback failed :', fallbackError ) ;
1111+ }
1112+ }
10701113 }
10711114
10721115 // Enhanced event listeners with popup support
12291272 // Make path calculation globally available
12301273 window . meraGetMusicPath = getMusicPath ;
12311274
1232- // Initialize
1275+ // Initialize - try multiple approaches
1276+ console . log ( '🎵 Setting up initialization ...') ;
1277+ console . log ( '🎵 Document ready state :', document . readyState ) ;
1278+
1279+ function initializeNow ( ) {
1280+ console . log ( '🎵 initializeNow ( ) called ') ;
1281+ initialize ( ) ;
1282+ }
1283+
12331284 if ( document . readyState === 'loading ') {
1234- document . addEventListener ( 'DOMContentLoaded ', initialize ) ;
1285+ console . log ( '🎵 Document still loading , waiting for DOMContentLoaded ') ;
1286+ document . addEventListener ( 'DOMContentLoaded ', initializeNow ) ;
12351287 } else {
1236- initialize ( ) ;
1288+ console . log ( '🎵 Document ready , initializing immediately ') ;
1289+ initializeNow ( ) ;
12371290 }
12381291
1292+ // Fallback initialization after a delay
1293+ setTimeout ( ( ) => {
1294+ console . log ( '🎵 Fallback check - looking for top bar ') ;
1295+ if ( ! document . getElementById ( 'mera - top - bar ') ) {
1296+ console . log ( '🎵 No top bar found , running fallback initialization ') ;
1297+ try {
1298+ initializeNow ( ) ;
1299+ } catch ( e ) {
1300+ console . error ( '🎵 Fallback initialization failed :', e ) ;
1301+ }
1302+ } else {
1303+ console . log ( '🎵 Top bar already exists ') ;
1304+ }
1305+ } , 2000 ) ;
1306+
12391307} ) ( ) ;
0 commit comments