@@ -223,7 +223,8 @@ async function commenceExtensionInitialization(configurationObject) {
223223 } else {
224224 logConCgp ( '[init] Decide-first: Panel is hidden. Using standard inline injection.' ) ;
225225 buttonBoxCheckingAndInjection ( true ) ;
226-
226+ // Initialize per-tab flags if absent
227+ if ( typeof window . __OCP_inlineHealthy === 'undefined' ) window . __OCP_inlineHealthy = false ;
227228 /**
228229 * When inline injection fails (e.g., because the target container cannot be found),
229230 * there is no user click event to supply a mouse position for the floating panel.
@@ -234,18 +235,16 @@ async function commenceExtensionInitialization(configurationObject) {
234235 setTimeout ( ( ) => {
235236 try {
236237 // Check if inline buttons were injected by looking for the container and its children.
237- let modsExist = false ;
238- try {
238+ let modsExist = ( ( ) => {
239239 const containerId = window ?. InjectionTargetsOnWebsite ?. selectors ?. buttonsContainerId ;
240- if ( containerId ) {
240+ if ( ! containerId ) return false ;
241241 const el = document . getElementById ( containerId ) ;
242- modsExist = ! ! ( el && el . children && el . children . length > 0 ) ;
243- }
244- } catch ( _ ) {
245- modsExist = false ;
246- }
242+ return ! ! ( el && el . children && el . children . length > 0 ) ;
243+ } ) ( ) ;
247244 // Only trigger fallback if no mods exist and the panel isn’t already visible.
248- if ( ! modsExist && window . MaxExtensionFloatingPanel && ! window . MaxExtensionFloatingPanel . isPanelVisible ) {
245+ const userDisabled = ! ! window . __OCP_userDisabledFallback ;
246+ if ( ! modsExist && ! window . __OCP_inlineHealthy && ! userDisabled &&
247+ window . MaxExtensionFloatingPanel && ! window . MaxExtensionFloatingPanel . isPanelVisible ) {
249248 logConCgp ( "[init] We haven't found the place to inject buttons, so we will fall back to a floating panel instead." ) ;
250249 window . MaxExtensionFloatingPanel . createFloatingPanel ( ) . then ( ( ) => {
251250 const panelElement = window . MaxExtensionFloatingPanel . panelElement ;
@@ -267,6 +266,7 @@ async function commenceExtensionInitialization(configurationObject) {
267266 panelElement . style . display = 'flex' ;
268267 window . MaxExtensionFloatingPanel . isPanelVisible = true ;
269268 if ( window . MaxExtensionFloatingPanel . currentPanelSettings ) {
269+ // note: do not set inlineHealthy here — we are in fallback mode
270270 window . MaxExtensionFloatingPanel . currentPanelSettings . isVisible = true ;
271271 window . MaxExtensionFloatingPanel . debouncedSavePanelSettings ?. ( ) ;
272272 }
0 commit comments