@@ -41,7 +41,7 @@ if (!window.__OCP_messageListenerRegistered_v2) {
4141
4242 // Lightweight UI refresh that preserves the floating panel state
4343 // Accepts an optional `origin` parameter to limit refreshing to the initiator (e.g. 'panel' or 'inline').
44- window . __OCP_partialRefreshUI = function ( optionalNewConfig , origin = null ) {
44+ window . __OCP_partialRefreshUI = function ( optionalNewConfig , origin = null ) {
4545 try {
4646 if ( optionalNewConfig ) {
4747 window . globalMaxExtensionConfig = optionalNewConfig ;
@@ -60,12 +60,12 @@ if (!window.__OCP_messageListenerRegistered_v2) {
6060
6161 // Expose a single entry to perform partial or full refresh depending on panel presence
6262 // Accepts optional `origin` so partial refresh can be targeted when appropriate.
63- window . __OCP_nukeAndRefresh = function ( optionalNewConfig , origin = null ) {
63+ window . __OCP_nukeAndRefresh = function ( optionalNewConfig , origin = null ) {
6464 if ( window . __OCP_nukeInProgress ) return ;
6565 window . __OCP_nukeInProgress = true ;
6666 try {
6767 const hasPanel = ! ! ( window . MaxExtensionFloatingPanel && window . MaxExtensionFloatingPanel . panelElement ) ;
68-
68+
6969 if ( hasPanel ) {
7070 // Preserve panel DOM/state; only refresh buttons/inline
7171 window . __OCP_partialRefreshUI ( optionalNewConfig , origin ) ;
@@ -74,7 +74,7 @@ if (!window.__OCP_messageListenerRegistered_v2) {
7474 if ( optionalNewConfig ) {
7575 window . globalMaxExtensionConfig = optionalNewConfig ;
7676 }
77-
77+
7878 // 1) Stop resiliency monitors and timers from previous run
7979 try {
8080 if ( window . OneClickPropmts_currentResiliencyTimeout ) {
@@ -85,21 +85,21 @@ if (!window.__OCP_messageListenerRegistered_v2) {
8585 window . OneClickPropmts_extendedMonitoringObserver . disconnect ( ) ;
8686 window . OneClickPropmts_extendedMonitoringObserver = null ;
8787 }
88- } catch ( e ) { }
89-
88+ } catch ( e ) { }
89+
9090 // 2) Remove inline buttons container(s)
9191 try {
9292 const containerId = window ?. InjectionTargetsOnWebsite ?. selectors ?. buttonsContainerId ;
9393 if ( containerId ) {
9494 document . querySelectorAll ( '#' + CSS . escape ( containerId ) ) . forEach ( node => node . remove ( ) ) ;
9595 }
96- } catch ( e ) { }
97-
96+ } catch ( e ) { }
97+
9898 // 3) Do NOT remove the panel here (it is already absent in this branch)
99-
99+
100100 // 4) Detach keyboard listener to avoid duplicates
101- try { window . removeEventListener ( 'keydown' , manageKeyboardShortcutEvents ) ; } catch ( e ) { }
102-
101+ try { window . removeEventListener ( 'keydown' , manageKeyboardShortcutEvents ) ; } catch ( e ) { }
102+
103103 // 5) Re-run full initialization
104104 publicStaticVoidMain ( ) ;
105105 }
@@ -238,7 +238,7 @@ async function commenceExtensionInitialization(configurationObject) {
238238 let modsExist = ( ( ) => {
239239 const containerId = window ?. InjectionTargetsOnWebsite ?. selectors ?. buttonsContainerId ;
240240 if ( ! containerId ) return false ;
241- const el = document . getElementById ( containerId ) ;
241+ const el = document . getElementById ( containerId ) ;
242242 return ! ! ( el && el . children && el . children . length > 0 ) ;
243243 } ) ( ) ;
244244 // Only trigger fallback if no mods exist and the panel isn’t already visible.
@@ -367,13 +367,14 @@ function resilientStartAndRetryOnSPANavigation(callback) {
367367 window . __OCP_urlChangeObserver . disconnect ( ) ;
368368 window . __OCP_urlChangeObserver = null ;
369369 }
370- } catch ( e ) { }
370+ } catch ( e ) { }
371371
372372 let previousUrl = location . href ;
373373 const urlChangeObserver = new MutationObserver ( ( ) => {
374374 const currentUrl = location . href ;
375375 if ( currentUrl !== previousUrl ) {
376376 previousUrl = currentUrl ;
377+ document . dispatchEvent ( new CustomEvent ( 'ocp-page-navigated' ) ) ;
377378 callback ( ) ;
378379 }
379380 } ) ;
@@ -393,6 +394,7 @@ function patchHistoryMethods() {
393394 history [ method ] = function ( ...args ) {
394395 const result = original . apply ( this , args ) ;
395396 logConCgp ( `[init] ${ method } called. URL:` , args [ 2 ] ) ;
397+ document . dispatchEvent ( new CustomEvent ( 'ocp-page-navigated' ) ) ;
396398 publicStaticVoidMain ( ) ; // Re-run the full initialization logic
397399 return result ;
398400 } ;
0 commit comments