@@ -688,42 +688,53 @@ class DkimFavicon {
688
688
*/
689
689
class DkimFromAddress {
690
690
/**
691
- * Get the element containing the from address (without the following star).
691
+ * Get the elements containing the from address (without the following star).
692
+ * Can return multiple elements, as newer Thunderbird version have
693
+ * both a single line and a multi line from address.
692
694
*
693
695
* @private
694
696
* @param {Document } document
695
- * @returns {HTMLElement? }
697
+ * @returns {HTMLElement[] }
696
698
*/
697
699
static _getFromAddress ( document ) {
698
700
// TB >=102
699
701
const fromRecipient0Display = document . getElementById ( "fromRecipient0Display" ) ;
700
702
if ( fromRecipient0Display ) {
701
- return fromRecipient0Display ;
703
+ // eslint-disable-next-line no-extra-parens
704
+ const fromRecipient0 = /** @type {HeaderRecipient? } */ ( document . getElementById ( "fromRecipient0" ) ) ;
705
+ if ( ! fromRecipient0 ) {
706
+ console . warn ( "DKIM: multi line from address not found (no fromRecipient0)" ) ;
707
+ } else if ( ! fromRecipient0 . multiLine ) {
708
+ console . warn ( "DKIM: multi line from address not found (fromRecipient0 has no multiLine)" ) ;
709
+ } else {
710
+ return [ fromRecipient0Display , fromRecipient0 . multiLine ] ;
711
+ }
712
+ return [ fromRecipient0Display ] ;
702
713
}
703
714
704
715
// TB <102
705
716
// eslint-disable-next-line no-extra-parens
706
717
const expandedFromBox = /** @type {expandedfromBox? } */ ( document . getElementById ( "expandedfromBox" ) ) ;
707
718
if ( ! expandedFromBox ) {
708
719
console . debug ( "DKIM: from address not found (no expandedfromBox)" ) ;
709
- return null ;
720
+ return [ ] ;
710
721
}
711
722
if ( ! ( "emailAddresses" in expandedFromBox ) ) {
712
723
console . debug ( "DKIM: from address not found (no expandedFromBox.emailAddresses)" ) ;
713
- return null ;
724
+ return [ ] ;
714
725
}
715
726
const mailEmailadress = expandedFromBox . emailAddresses . firstElementChild ;
716
727
if ( ! mailEmailadress ) {
717
728
console . debug ( "DKIM: from address not found (no firstElementChild)" ) ;
718
- return null ;
729
+ return [ ] ;
719
730
}
720
731
const emailValue = mailEmailadress . getElementsByClassName ( "emaillabel" ) [ 0 ] ;
721
732
if ( ! emailValue ) {
722
733
console . debug ( "DKIM: from address not found (no emaillabel)" ) ;
723
- return null ;
734
+ return [ ] ;
724
735
}
725
736
// eslint-disable-next-line no-extra-parens
726
- return /** @type {HTMLElement } */ ( emailValue ) ;
737
+ return [ /** @type {HTMLElement } */ ( emailValue ) ] ;
727
738
}
728
739
729
740
/**
@@ -735,13 +746,15 @@ class DkimFromAddress {
735
746
* @returns {void }
736
747
*/
737
748
static setHighlightColor ( document , color , backgroundColor ) {
738
- const emailValue = this . _getFromAddress ( document ) ;
739
- if ( ! emailValue ) {
749
+ const emailValues = this . _getFromAddress ( document ) ;
750
+ if ( ! emailValues ) {
740
751
return ;
741
752
}
742
- emailValue . style . borderRadius = "3px" ;
743
- emailValue . style . color = color ;
744
- emailValue . style . backgroundColor = backgroundColor ;
753
+ for ( const emailValue of emailValues ) {
754
+ emailValue . style . borderRadius = "3px" ;
755
+ emailValue . style . color = color ;
756
+ emailValue . style . backgroundColor = backgroundColor ;
757
+ }
745
758
}
746
759
747
760
/**
@@ -752,28 +765,30 @@ class DkimFromAddress {
752
765
* @returns {void }
753
766
*/
754
767
static showTooltip ( document , show ) {
755
- const emailValue = this . _getFromAddress ( document ) ;
756
- if ( ! emailValue ) {
768
+ const emailValues = this . _getFromAddress ( document ) ;
769
+ if ( ! emailValues ) {
757
770
return ;
758
771
}
759
- if ( show ) {
760
- // save current tooltip if set
761
- const tooltiptext = emailValue . getAttribute ( "tooltiptext" ) ;
762
- if ( tooltiptext ) {
763
- emailValue . setAttribute ( "tooltiptextSaved" , tooltiptext ) ;
764
- }
765
- emailValue . removeAttribute ( "tooltiptext" ) ;
766
- // set DKIM tooltip
767
- emailValue . setAttribute ( "tooltip" , DkimFavicon . idTooltip ) ;
768
- } else {
769
- if ( emailValue . getAttribute ( "tooltip" ) === DkimFavicon . idTooltip ) {
770
- // remove DKIM tooltip
771
- emailValue . removeAttribute ( "tooltip" ) ;
772
- // restore saved tooltip
773
- const tooltiptextSaved = emailValue . getAttribute ( "tooltiptextSaved" ) ;
774
- if ( tooltiptextSaved ) {
775
- emailValue . setAttribute ( "tooltiptext" , tooltiptextSaved ) ;
776
- emailValue . removeAttribute ( "tooltiptextSaved" ) ;
772
+ for ( const emailValue of emailValues ) {
773
+ if ( show ) {
774
+ // save current tooltip if set
775
+ const tooltiptext = emailValue . getAttribute ( "tooltiptext" ) ;
776
+ if ( tooltiptext ) {
777
+ emailValue . setAttribute ( "tooltiptextSaved" , tooltiptext ) ;
778
+ }
779
+ emailValue . removeAttribute ( "tooltiptext" ) ;
780
+ // set DKIM tooltip
781
+ emailValue . setAttribute ( "tooltip" , DkimFavicon . idTooltip ) ;
782
+ } else {
783
+ if ( emailValue . getAttribute ( "tooltip" ) === DkimFavicon . idTooltip ) {
784
+ // remove DKIM tooltip
785
+ emailValue . removeAttribute ( "tooltip" ) ;
786
+ // restore saved tooltip
787
+ const tooltiptextSaved = emailValue . getAttribute ( "tooltiptextSaved" ) ;
788
+ if ( tooltiptextSaved ) {
789
+ emailValue . setAttribute ( "tooltiptext" , tooltiptextSaved ) ;
790
+ emailValue . removeAttribute ( "tooltiptextSaved" ) ;
791
+ }
777
792
}
778
793
}
779
794
}
0 commit comments