@@ -89,8 +89,9 @@ const addSignatureToggle = async (messageActions) => {
89
89
icon . src = chrome . runtime . getURL ( `icons/${ darkModePreference . matches ? 'dark' : 'light' } /icon32.png` ) ;
90
90
icon . alt = 'Toggle Signature' ;
91
91
icon . style = 'width: 20px; height: 20px; margin: 0 0.5rem; transition: opacity 0.3s; position: relative; bottom: 0.2em;' ;
92
- const item = await chrome . storage . local . get ( [ 'linkedinsignature' ] ) ;
93
- icon . style . opacity = item . linkedinsignature . messageSignEnabled ? 1 : 0.4 ;
92
+ const { linkedinsignature } = await chrome . storage . local . get ( [ 'linkedinsignature' ] ) ;
93
+ if ( ! linkedinsignature ) return ;
94
+ icon . style . opacity = linkedinsignature . messageSignEnabled ? 1 : 0.4 ;
94
95
signatureToggle . appendChild ( icon ) ;
95
96
96
97
messageActions . appendChild ( signatureToggle ) ;
@@ -99,19 +100,21 @@ const addSignatureToggle = async (messageActions) => {
99
100
const findCompanyName = ( fullName ) => {
100
101
if ( window . location . href . includes ( 'linkedin.com/in/' ) ) {
101
102
const mainName = document . querySelector ( 'main h1' ) . textContent . trim ( ) ;
102
- if ( mainName === fullName ) {
103
- const experiences = document . querySelector ( 'section #experience' ) . parentElement ,
104
- latestCompany = experiences . querySelector ( 'li' ) ,
105
- latestCompanyName = latestCompany . querySelector ( 'img' ) . getAttribute ( 'alt' ) . split ( ' ' ) . slice ( 0 , - 1 ) . join ( ' ' ) ;
106
-
107
- let latestTimeline = latestCompany . querySelector ( '.pvs-entity__caption-wrapper' ) . textContent . trim ( ) ;
108
-
109
- const changedRoles = latestTimeline . indexOf ( ' - ' ) === - 1 ; // displays "Full-time"
110
- if ( changedRoles ) latestTimeline = latestCompany . querySelector ( '.pvs-entity__sub-components li .pvs-entity__caption-wrapper' ) . textContent . trim ( ) ;
111
-
112
- const isCurrentCompany = ! latestTimeline . split ( ' - ' ) [ 1 ] . split ( ' · ' ) [ 0 ] . includes ( ' ' ) ;
113
- if ( isCurrentCompany ) return latestCompanyName ;
114
- }
103
+ if ( mainName !== fullName ) return ;
104
+
105
+ const experienceTitleSelector = 'div.mr1 span[aria-hidden="true"]' ,
106
+ experienceSubtitleSelector = 'span.t-14:not(.t-black--light):first-of-type span[aria-hidden="true"]' ,
107
+ latestCompany = document . querySelector ( 'section #experience' ) . parentElement . querySelector ( 'li' ) ,
108
+ changedRoles = latestCompany . querySelector ( '.pvs-entity__caption-wrapper' ) . textContent . trim ( ) . indexOf ( ' · ' ) === - 1 ,
109
+ latestCompanyName = changedRoles ?
110
+ latestCompany . querySelector ( experienceTitleSelector ) . textContent . trim ( ) :
111
+ latestCompany . querySelector ( experienceSubtitleSelector ) . textContent . trim ( ) . split ( ' · ' ) [ 0 ] ,
112
+ latestTimeline = changedRoles ?
113
+ latestCompany . querySelector ( '.pvs-entity__sub-components li .pvs-entity__caption-wrapper' ) . textContent . trim ( ) :
114
+ latestCompany . querySelector ( '.pvs-entity__caption-wrapper' ) . textContent . trim ( ) ,
115
+ isCurrentCompany = ! latestTimeline . split ( ' - ' ) [ 1 ] . split ( ' · ' ) [ 0 ] . includes ( ' ' ) ;
116
+
117
+ if ( isCurrentCompany ) return latestCompanyName ;
115
118
} else if ( window . location . href . includes ( 'linkedin.com/search/results/' ) ) {
116
119
let returnValue = null ;
117
120
document . querySelectorAll ( 'div.mb1' ) . forEach ( result => {
0 commit comments