@@ -583,9 +583,25 @@ if (window.checkExtensionLoaded) {
583583 */
584584 async function loadDeveloperConsoleLoggingSetting ( ) {
585585 try {
586+ // Request config from background to get merged enterprise + local config
586587 const config = await new Promise ( ( resolve ) => {
587- chrome . storage . local . get ( [ "config" ] , ( result ) => {
588- resolve ( result . config || { } ) ;
588+ chrome . runtime . sendMessage ( { type : "GET_CONFIG" } , ( response ) => {
589+ if ( chrome . runtime . lastError ) {
590+ logger . log (
591+ `[M365-Protection] Error getting config from background: ${ chrome . runtime . lastError . message } `
592+ ) ;
593+ // Fallback to local storage if background not available
594+ chrome . storage . local . get ( [ "config" ] , ( result ) => {
595+ resolve ( result . config || { } ) ;
596+ } ) ;
597+ } else if ( ! response || ! response . success ) {
598+ // Fallback to local storage if response invalid
599+ chrome . storage . local . get ( [ "config" ] , ( result ) => {
600+ resolve ( result . config || { } ) ;
601+ } ) ;
602+ } else {
603+ resolve ( response . config ) ;
604+ }
589605 } ) ;
590606 } ) ;
591607
@@ -5580,12 +5596,27 @@ if (window.checkExtensionLoaded) {
55805596 // Set flag to prevent DOM monitoring loops
55815597 showingBanner = true ;
55825598
5583- // Fetch branding configuration (uniform pattern: storage only, like applyBrandingColors)
5599+ // Fetch branding configuration from background to get merged config
55845600 const fetchBranding = ( ) =>
55855601 new Promise ( ( resolve ) => {
55865602 try {
5587- chrome . storage . local . get ( [ "brandingConfig" ] , ( result ) => {
5588- resolve ( result ?. brandingConfig || { } ) ;
5603+ chrome . runtime . sendMessage ( { type : "GET_BRANDING_CONFIG" } , ( response ) => {
5604+ if ( chrome . runtime . lastError ) {
5605+ logger . log (
5606+ `[M365-Protection] Error getting branding from background: ${ chrome . runtime . lastError . message } `
5607+ ) ;
5608+ // Fallback to local storage if background not available
5609+ chrome . storage . local . get ( [ "brandingConfig" ] , ( result ) => {
5610+ resolve ( result ?. brandingConfig || { } ) ;
5611+ } ) ;
5612+ } else if ( ! response || ! response . success ) {
5613+ // Fallback to local storage if response invalid
5614+ chrome . storage . local . get ( [ "brandingConfig" ] , ( result ) => {
5615+ resolve ( result ?. brandingConfig || { } ) ;
5616+ } ) ;
5617+ } else {
5618+ resolve ( response . branding || { } ) ;
5619+ }
55895620 } ) ;
55905621 } catch ( _ ) {
55915622 resolve ( { } ) ;
@@ -5902,10 +5933,25 @@ if (window.checkExtensionLoaded) {
59025933 validBadgeTimeoutId = null ;
59035934 }
59045935
5905- // Load timeout configuration
5936+ // Load timeout configuration from background to get merged config
59065937 const config = await new Promise ( ( resolve ) => {
5907- chrome . storage . local . get ( [ "config" ] , ( result ) => {
5908- resolve ( result . config || { } ) ;
5938+ chrome . runtime . sendMessage ( { type : "GET_CONFIG" } , ( response ) => {
5939+ if ( chrome . runtime . lastError ) {
5940+ logger . log (
5941+ `[M365-Protection] Error getting config from background: ${ chrome . runtime . lastError . message } `
5942+ ) ;
5943+ // Fallback to local storage if background not available
5944+ chrome . storage . local . get ( [ "config" ] , ( result ) => {
5945+ resolve ( result . config || { } ) ;
5946+ } ) ;
5947+ } else if ( ! response || ! response . success ) {
5948+ // Fallback to local storage if response invalid
5949+ chrome . storage . local . get ( [ "config" ] , ( result ) => {
5950+ resolve ( result . config || { } ) ;
5951+ } ) ;
5952+ } else {
5953+ resolve ( response . config ) ;
5954+ }
59095955 } ) ;
59105956 } ) ;
59115957
@@ -6281,15 +6327,28 @@ if (window.checkExtensionLoaded) {
62816327 return ;
62826328 }
62836329
6284- // Get CIPP configuration from storage
6285- const result = await new Promise ( ( resolve ) => {
6286- chrome . storage . local . get ( [ "config" ] , ( result ) => {
6287- resolve ( result . config || { } ) ;
6330+ // Get CIPP configuration from background to get merged config
6331+ const config = await new Promise ( ( resolve ) => {
6332+ chrome . runtime . sendMessage ( { type : "GET_CONFIG" } , ( response ) => {
6333+ if ( chrome . runtime . lastError ) {
6334+ logger . log (
6335+ `[M365-Protection] Error getting config from background: ${ chrome . runtime . lastError . message } `
6336+ ) ;
6337+ // Fallback to local storage if background not available
6338+ chrome . storage . local . get ( [ "config" ] , ( result ) => {
6339+ resolve ( result . config || { } ) ;
6340+ } ) ;
6341+ } else if ( ! response || ! response . success ) {
6342+ // Fallback to local storage if response invalid
6343+ chrome . storage . local . get ( [ "config" ] , ( result ) => {
6344+ resolve ( result . config || { } ) ;
6345+ } ) ;
6346+ } else {
6347+ resolve ( response . config ) ;
6348+ }
62886349 } ) ;
62896350 } ) ;
62906351
6291- const config = result ;
6292-
62936352 // Check if CIPP reporting is enabled and URL is configured
62946353 if ( ! config . enableCippReporting || ! config . cippServerUrl ) {
62956354 logger . debug ( "CIPP reporting disabled or no server URL configured" ) ;
@@ -6348,10 +6407,25 @@ if (window.checkExtensionLoaded) {
63486407 */
63496408 async function applyBrandingColors ( ) {
63506409 try {
6351- // Get branding configuration from storage
6410+ // Get branding configuration from background to get merged config
63526411 const result = await new Promise ( ( resolve ) => {
6353- chrome . storage . local . get ( [ "brandingConfig" ] , ( result ) => {
6354- resolve ( result . brandingConfig || { } ) ;
6412+ chrome . runtime . sendMessage ( { type : "GET_BRANDING_CONFIG" } , ( response ) => {
6413+ if ( chrome . runtime . lastError ) {
6414+ logger . log (
6415+ `[M365-Protection] Error getting branding from background: ${ chrome . runtime . lastError . message } `
6416+ ) ;
6417+ // Fallback to local storage if background not available
6418+ chrome . storage . local . get ( [ "brandingConfig" ] , ( result ) => {
6419+ resolve ( result ?. brandingConfig || { } ) ;
6420+ } ) ;
6421+ } else if ( ! response || ! response . success ) {
6422+ // Fallback to local storage if response invalid
6423+ chrome . storage . local . get ( [ "brandingConfig" ] , ( result ) => {
6424+ resolve ( result ?. brandingConfig || { } ) ;
6425+ } ) ;
6426+ } else {
6427+ resolve ( response . branding || { } ) ;
6428+ }
63556429 } ) ;
63566430 } ) ;
63576431
0 commit comments