@@ -135,11 +135,23 @@ chrome.runtime.onMessage.addListener(function (messageUnTyped, sender, sendRespo
135135 } )
136136 }
137137
138- if ( message . type === "enable_beta" ) {
138+ if ( ( message . type === "enable_beta" ) || ( message . type === "enable_beta_with_notification" ) ) {
139+ const showNotification = ( message . type === "enable_beta_with_notification" )
140+
139141 enableBeta ( ) . then ( ( message ) => {
140- /** @type {ExtensionResponse } */
141- const response = { success : true , message : message }
142- sendResponse ( response )
142+ registerContentScripts ( showNotification ) . then ( ( message ) => {
143+ /** @type {ExtensionResponse } */
144+ const response = { success : true , message : message }
145+ sendResponse ( response )
146+ } )
147+ . catch ( ( error ) => {
148+ // Fails with error codes: not defined
149+ const parsedError = /** @type {ErrorObject } */ ( error )
150+
151+ /** @type {ExtensionResponse } */
152+ const response = { success : false , message : parsedError }
153+ sendResponse ( response )
154+ } )
143155 } )
144156 . catch ( ( error ) => {
145157 // Fails with error codes: not defined
@@ -194,9 +206,12 @@ chrome.runtime.onUpdateAvailable.addListener(() => {
194206 } )
195207} )
196208
197- // Register content scripts whenever runtime permission is provided by the user
209+ // Register content scripts whenever runtime permission change—mostly serves as a backup for changes made outside the UI.
198210chrome . permissions . onAdded . addListener ( ( event ) => {
199- registerContentScripts ( )
211+ // Prevent competing with explicit content script registrations
212+ setTimeout ( ( ) => {
213+ registerContentScripts ( )
214+ } , 2000 )
200215} )
201216
202217
@@ -639,7 +654,7 @@ function enableBeta() {
639654/**
640655 * @param {boolean } [showNotification]
641656 */
642- function registerContentScripts ( showNotification = true ) {
657+ function registerContentScripts ( showNotification = false ) {
643658 return new Promise ( ( resolve , reject ) => {
644659 chrome . permissions . getAll ( ) . then ( ( permissions ) => {
645660 if ( permissions . origins ?. includes ( "https://*.zoom.us/*" ) && permissions . origins ?. includes ( "https://teams.live.com/*" ) && permissions . origins ?. includes ( "https://teams.microsoft.com/*" ) ) {
@@ -699,8 +714,8 @@ function registerContentScripts(showNotification = true) {
699714 chrome . notifications . create ( {
700715 type : "basic" ,
701716 iconUrl : "icon.png" ,
702- title : "Enabled! Join Zoom/Teams meetings on the browser " ,
703- message : "Refresh any existing Zoom/Teams pages"
717+ title : "Enabled!" ,
718+ message : "Join Teams/Zoom meetings on the browser. Refresh any existing Zoom/Teams pages"
704719 } )
705720 }
706721 } )
0 commit comments