@@ -85,16 +85,17 @@ export class GmailElementReplacer extends WebmailElementReplacer {
8585 ] ;
8686 } ;
8787
88- public setReplyBoxEditable = async ( ) => {
88+ public setReplyBoxEditable = async ( messageContainer ?: JQuery < Element > ) => {
8989 const replyContainerIframe = $ ( '.reply_message_iframe_container > iframe' ) . last ( ) ;
90- if ( replyContainerIframe . length ) {
91- $ ( replyContainerIframe ) . replaceWith ( this . factory . embeddedReply ( this . getLastMsgReplyParams ( this . getConvoRootEl ( replyContainerIframe [ 0 ] ) ) , true ) ) ; // xss-safe-value
90+ if ( replyContainerIframe . length && messageContainer ) {
91+ $ ( replyContainerIframe ) . replaceWith ( this . factory . embeddedReply ( this . getLastMsgReplyParams ( messageContainer ) , true ) ) ; // xss-safe-value
9292 } else {
9393 await this . replaceStandardReplyBox ( undefined , true ) ;
9494 }
9595 } ;
9696
9797 public reinsertReplyBox = ( replyMsgId : string ) => {
98+ console . log ( 'wew' , replyMsgId ) ;
9899 const params : FactoryReplyParams = { replyMsgId } ;
99100 $ ( '.reply_message_iframe_container:visible' )
100101 . last ( )
@@ -351,10 +352,10 @@ export class GmailElementReplacer extends WebmailElementReplacer {
351352 return ;
352353 }
353354 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
354- const messageContainer = $ ( btn . closest ( '.h7' ) ! ) ;
355+ const messageContainer : JQuery < Element > = $ ( btn . closest ( '.h7' ) ! ) ;
355356 if ( messageContainer . is ( ':last-child' ) ) {
356357 if ( this . isEncrypted ( ) ) {
357- await this . setReplyBoxEditable ( ) ;
358+ await this . setReplyBoxEditable ( messageContainer ) ;
358359 } else {
359360 await this . replaceStandardReplyBox ( undefined , true ) ;
360361 }
@@ -589,8 +590,10 @@ export class GmailElementReplacer extends WebmailElementReplacer {
589590 return from ? Str . parseEmail ( from ) : undefined ;
590591 } ;
591592
592- private getLastMsgReplyParams = ( convoRootEl : JQuery ) : FactoryReplyParams => {
593- return { replyMsgId : this . determineMsgId ( $ ( convoRootEl ) . find ( this . sel . msgInner ) . last ( ) ) } ;
593+ private getLastMsgReplyParams = ( convoRootEl : JQuery < Element > ) : FactoryReplyParams => {
594+ const msgIdElement = $ ( convoRootEl ) . find ( '[data-legacy-message-id], [data-message-id]' ) ;
595+ const msgId = msgIdElement . attr ( 'data-legacy-message-id' ) || msgIdElement . attr ( 'data-message-id' ) ;
596+ return { replyMsgId : msgId } ;
594597 } ;
595598
596599 private getConvoRootEl = ( anyInnerElement : HTMLElement ) => {
@@ -618,6 +621,7 @@ export class GmailElementReplacer extends WebmailElementReplacer {
618621 const convoRootEl = this . getConvoRootEl ( newReplyBoxes [ 0 ] ) ;
619622 const replyParams = this . getLastMsgReplyParams ( convoRootEl ) ;
620623 if ( msgId ) {
624+ console . log ( msgId ) ;
621625 replyParams . replyMsgId = msgId ;
622626 }
623627 const hasDraft = newReplyBoxes . filter ( replyBox => {
@@ -665,6 +669,7 @@ export class GmailElementReplacer extends WebmailElementReplacer {
665669 const isReplyButtonView = replyBoxEl . className . includes ( 'nr' ) ;
666670 const replyBoxes = document . querySelectorAll ( 'iframe.reply_message' ) ;
667671 const alreadyHasSecureReplyBox = replyBoxes . length > 0 ;
672+ console . log ( 'wew' , replyParams ) ;
668673 const secureReplyBoxXssSafe = /* xss-safe-factory */ `
669674 <div class="remove_borders reply_message_iframe_container">
670675 ${ this . factory . embeddedReply ( replyParams , ! isReplyButtonView || alreadyHasSecureReplyBox || this . lastSwitchToEncryptedReply ) }
0 commit comments