@@ -7,42 +7,38 @@ import {sanitize} from 'dompurify'
77class BookmarkSearch {
88 private readonly host : string
99 private readonly innerClass : string
10- private keyword : string
10+ private getKeyword : ( ) => string
1111 constructor ( ) {
1212 this . host = getHost ( window . location . href )
13- if ( this . host === 'www.baidu.com' ) {
14- this . keyword = $ ( '#kw' ) . val ( ) as string
13+
14+ if ( this . host . endsWith ( '.baidu.com' ) ) {
15+ this . getKeyword = ( ) => ( $ ( '#kw' ) [ 0 ] [ 'value' ] as string )
1516 this . innerClass = '#content_left'
1617 $ ( '#kw' ) . bind ( 'input propertychange' , ( ) => {
17- this . keyword = $ ( '#kw' ) . val ( ) as string
18- this . sendSearch ( this . keyword )
18+ this . sendSearch ( this . getKeyword ( ) )
1919 } )
20- this . sendSearch ( this . keyword )
2120 } else if ( this . host . startsWith ( 'www.google.' ) ) {
22- this . keyword = $ ( '#lst-ib' ) . val ( ) as string
21+ this . getKeyword = ( ) => ( $ ( 'input.gsfi' ) [ 0 ] [ 'value' ] as string )
2322 this . innerClass = '#res'
24- $ ( '#lst-ib' ) . bind ( 'input propertychange' , ( ) => {
25- this . keyword = $ ( '#lst-ib' ) . val ( ) as string
26- this . sendSearch ( this . keyword )
23+ $ ( 'input.gsfi' ) . bind ( 'input propertychange' , ( ) => {
24+ this . sendSearch ( this . getKeyword ( ) )
2725 } )
28- this . sendSearch ( this . keyword )
29- } else if ( this . host . endsWith ( '.bind.com' ) ) {
30- this . keyword = $ ( '#sb_form_q' ) . val ( ) as string
31- this . innerClass = '#b_results '
26+ } else if ( this . host . endsWith ( '.bing.com' ) ) {
27+ $ ( 'li.b_algo:last' ) . after ( '<div id="bookmarkCard"></div>' )
28+ this . getKeyword = ( ) => ( $ ( '#sb_form_q' ) [ 0 ] [ 'value' ] as string )
29+ this . innerClass = '#bookmarkCard '
3230 $ ( '#sb_form_q' ) . bind ( 'input propertychange' , ( ) => {
33- this . keyword = $ ( '#sb_form_q' ) . val ( ) as string
34- this . sendSearch ( this . keyword )
31+ this . sendSearch ( this . getKeyword ( ) )
3532 } )
36- this . sendSearch ( this . keyword )
3733 } else if ( this . host . endsWith ( 'search.naver.com' ) ) {
38- this . keyword = $ ( '#nx_query' ) . val ( ) as string
34+ this . getKeyword = ( ) => ( $ ( '#nx_query' ) . val ( ) as string )
3935 this . innerClass = '#sub_pack'
4036 $ ( '#nx_query' ) . bind ( 'input propertychange' , ( ) => {
41- this . keyword = $ ( '#nx_query' ) . val ( ) as string
42- this . sendSearch ( this . keyword )
37+ this . sendSearch ( this . getKeyword ( ) )
4338 } )
44- this . sendSearch ( this . keyword )
4539 }
40+
41+ this . sendSearch ( this . getKeyword ( ) )
4642 }
4743
4844 public sendSearch ( keyword : string ) {
0 commit comments