@@ -573,13 +573,24 @@ function updateAllElements(isDark: boolean) {
573573
574574// Function to update the solutions tab content 
575575function  updateSolutionsTab ( title : string )  { 
576+  // Check if we're actually on the solutions tab before proceeding 
577+  const  isSolutionsPage  =  / ^ h t t p s : \/ \/ l e e t c o d e \. c o m \/ p r o b l e m s \/ .* \/ s o l u t i o n s \/ ? / . test ( window . location . href ) ; 
578+  if  ( ! isSolutionsPage )  return ; 
579+ 576580 chrome . storage . local . get ( [ 'leetcodeProblems' ] ,  ( result )  =>  { 
577581 // Try to find the search bar with retries 
578582 const  maxRetries  =  10 ; 
579583 const  baseDelay  =  300 ; 
580584 let  retryCount  =  0 ; 
581585
582586 const  tryInsertContent  =  ( )  =>  { 
587+  // First check if we already have a wrapper to prevent duplicates 
588+  const  existingWrapper  =  document . querySelector ( '.leetcode-explained-wrapper' ) ; 
589+  if  ( existingWrapper )  { 
590+  console . log ( 'Content already exists, skipping insertion' ) ; 
591+  return ; 
592+  } 
593+ 583594 const  searchBar  =  document . querySelectorAll ( 'input.block' ) [ 0 ] ?. parentElement ?. parentElement ?. parentElement ; 
584595
585596 if  ( ! searchBar  &&  retryCount  <  maxRetries )  { 
@@ -596,6 +607,12 @@ function updateSolutionsTab(title: string) {
596607
597608 // If still not found, set up a MutationObserver to watch for DOM changes 
598609 const  observer  =  new  MutationObserver ( ( mutations ,  obs )  =>  { 
610+  // Check again for existing wrapper before proceeding 
611+  if  ( document . querySelector ( '.leetcode-explained-wrapper' ) )  { 
612+  obs . disconnect ( ) ; 
613+  return ; 
614+  } 
615+ 599616 const  searchBar  =  document . querySelectorAll ( 'input.block' ) [ 0 ] ?. parentElement ?. parentElement ?. parentElement ; 
600617 if  ( searchBar )  { 
601618 obs . disconnect ( ) ;  // Stop observing once we find the element 
0 commit comments