@@ -136,9 +136,7 @@ export const search: SearchFunction<GoogleDictResult> = async (
136136
137137 extractImg ( bodyText ) . forEach ( ( { id, src } ) => {
138138 try {
139- const el = $obcontainer . querySelector (
140- `#${ id } , img[data-iid="${ id } "]`
141- )
139+ const el = $obcontainer . querySelector ( `#${ id } , img[data-iid="${ id } "]` )
142140 if ( el ) {
143141 el . setAttribute ( 'src' , src )
144142 el . setAttribute ( 'data-deferred' , '2' )
@@ -205,8 +203,7 @@ function extractImg(text: string): Array<{ id: string; src: string }> {
205203 }
206204 }
207205
208- const setImageMatcher =
209- / \( f u n c t i o n \( \) \{ v a r s = ' ( (?: \\ .| [ ^ ' \\ ] ) * ) ' ; v a r i i = \[ ( [ ^ \] ] * ) \] ; _ s e t I m a g e s S r c \( i i , s \) ; \} \) \( \) ; / g
206+ const setImageMatcher = / \( f u n c t i o n \( \) \{ v a r s = ' ( (?: \\ .| [ ^ ' \\ ] ) * ) ' ; v a r i i = \[ ( [ ^ \] ] * ) \] ; _ s e t I m a g e s S r c \( i i , s \) ; \} \) \( \) ; / g
210207 let setImageMatch : RegExpExecArray | null | undefined
211208 while ( ( setImageMatch = setImageMatcher . exec ( text ) ) ) {
212209 const src = normalizeImgSrc ( decodeJSString ( setImageMatch [ 1 ] ) )
@@ -226,15 +223,17 @@ function decodeHex(m: string, code: string): string {
226223}
227224
228225function decodeJSString ( text : string ) : string {
229- return text
230- // escape \x
231- . replace ( / \\ x ( [ \d a - f ] { 2 } ) / gi, decodeHex )
232- // escape \u
233- . replace ( / \\ u ( [ \d a - f ] { 4 } ) / gi, decodeHex )
234- . replace ( / \\ ( [ \\ / " ' ] ) / g, '$1' )
235- . replace ( / \\ n / g, '\n' )
236- . replace ( / \\ r / g, '\r' )
237- . replace ( / \\ t / g, '\t' )
226+ return (
227+ text
228+ // escape \x
229+ . replace ( / \\ x ( [ \d a - f ] { 2 } ) / gi, decodeHex )
230+ // escape \u
231+ . replace ( / \\ u ( [ \d a - f ] { 4 } ) / gi, decodeHex )
232+ . replace ( / \\ ( [ \\ / " ' ] ) / g, '$1' )
233+ . replace ( / \\ n / g, '\n' )
234+ . replace ( / \\ r / g, '\r' )
235+ . replace ( / \\ t / g, '\t' )
236+ )
238237}
239238
240239function normalizeImgSrc ( src : string ) : string {
0 commit comments