@@ -465,14 +465,17 @@ window.Spicetify = {
465465 // Filter out non-webpack scripts
466466 . filter ( ( script ) => [ "extensions" , "spicetify" , "helper" , "theme" ] . every ( ( str ) => ! script . src ?. includes ( str ) ) ) ;
467467
468+ //console.time("sanitize");
468469 await Promise . all (
469470 scripts . map ( async ( script ) => {
470471 try {
471472 const res = await fetch ( script . src ) ;
472473 const text = await res . text ( ) ;
474+ // remove every string from the content
475+ const sanitizedText = text . replace ( / ( [ " ' ` ] ) (?: \\ .| [ ^ \\ \1] ) * ?\1/ g, "" ) ;
473476 const src = script . src . split ( "/" ) . pop ( ) ;
474477 console . log ( `[spicetifyWrapper] Waiting for ${ src } ` ) ;
475- for ( const pack of text . match ( / (?< ! [ " ' ` ] ) (?: , | { ) ( \d + ) : ? \( ., ., ./ g) . map ( ( str ) => str . slice ( 0 , - 7 ) . slice ( 1 ) ) ) {
478+ for ( const pack of sanitizedText . match ( / (?< ! [ " ' ` ] ) (?: , | { ) ( \d + ) : ? \( ., ., ./ g) . map ( ( str ) => str . slice ( 0 , - 7 ) . slice ( 1 ) ) ) {
476479 //console.debug(`[spicetifyWrapper] Waiting for ${pack} of ${src}`);
477480 while ( ! require . m || ! Object . keys ( require . m ) . includes ( pack ) ) {
478481 await new Promise ( ( r ) => setTimeout ( r , 100 ) ) ;
@@ -485,6 +488,7 @@ window.Spicetify = {
485488 } )
486489 ) . then ( ( ) => {
487490 console . log ( "[spicetifyWrapper] All required webpack modules loaded" ) ;
491+ //console.timeEnd("sanitize");
488492 chunks = Object . entries ( require . m ) ;
489493 cache = Object . keys ( require . m ) . map ( ( id ) => require ( id ) ) ;
490494
0 commit comments