@@ -19,14 +19,12 @@ const wikis = prepareWikisInfo( getWikis( false, true ), {
19
19
20
20
21
21
class DdgSearchModule extends GenericSearchModule {
22
- ENGINE_LAYOUT_SELECTOR = '#b_results' ;
23
- RESULT_CONTAINER_SELECTOR = 'li.b_algo, div.slide' ;
24
- ORDINARY_RESULT_CLASS_NAME = 'b_algo' ;
25
- URL_ELEMENT_SELECTOR = 'h2#b_topTitle' ;
26
- SPAN_TITLE_ELEMENT_SELECTOR = 'h2 > a' ;
27
- ANCHOR_ELEMENT_SELECTOR = 'div > cite' ;
28
- NETWORK_NAME_ELEMENT_SELECTOR = '.tptt' ;
29
- BLACKLIST = 'slide' ; // TODO: This should be a list
22
+ ENGINE_LAYOUT_SELECTOR = '.w-gl--desktop' ;
23
+ RESULT_CONTAINER_SELECTOR = '.w-gl__result' ;
24
+ URL_ELEMENT_SELECTOR = '.w-gl__result-url' ;
25
+ SPAN_TITLE_ELEMENT_SELECTOR = '.w-gl__result-title > h3' ;
26
+ BADGE_ELEMENT_SELECTOR = '.w-gl__result-title' ;
27
+ ANCHOR_ELEMENT_SELECTOR = '.w-gl__result-url' ; // URL breadcumb
30
28
/**
31
29
* @protected
32
30
* @return {string }
@@ -56,7 +54,7 @@ class DdgSearchModule extends GenericSearchModule {
56
54
57
55
findNearestGgResult ( wikiInfo , boundaryElement ) {
58
56
for ( const node of document . querySelectorAll ( wikiInfo . search . goodSelector ) ) {
59
- if ( this . isBlacklisted ( node ) && ( node . compareDocumentPosition ( boundaryElement ) & 0x02 ) ) {
57
+ if ( node . compareDocumentPosition ( boundaryElement ) & 0x02 ) {
60
58
return crawlUntilParentFound ( node , this . RESULT_CONTAINER_SELECTOR ) ;
61
59
}
62
60
}
@@ -70,24 +68,7 @@ class DdgSearchModule extends GenericSearchModule {
70
68
* @param {HTMLElement } _foundLinkElement
71
69
*/
72
70
async hideResult ( wikiInfo , containerElement , _foundLinkElement ) {
73
- // This is just a placeholder, what if we had different elements?
74
- if ( containerElement . classList . contains ( this . ORDINARY_RESULT_CLASS_NAME ) ) {
75
-
76
- // Try to find the first wiki.gg result after this one
77
- const ggResult = this . findNearestGgResult ( wikiInfo , containerElement ) ;
78
-
79
- let replacement ;
80
- if ( ggResult ) {
81
- replacement = ggResult ;
82
- } else {
83
- replacement = constructReplacementMarker ( wikiInfo ) ;
84
- }
85
- containerElement . textContent = '' ;
86
- containerElement . append ( replacement ) ;
87
- } else {
88
- containerElement . style . display = 'none' ;
89
- }
90
-
71
+ super . hideResult ( wikiInfo , containerElement , _foundLinkElement ) ;
91
72
}
92
73
93
74
@@ -114,20 +95,25 @@ class DdgSearchModule extends GenericSearchModule {
114
95
const badgeElement = constructRedirectBadge ( {
115
96
allMoved : true ,
116
97
theme : {
117
- fontSize : '60%' ,
118
- color : '#222'
98
+ fontSize : '80%' ,
99
+ color : document . documentElement . classList . contains ( "startpage-html--dark" || "startpage-html--night" ) ? '#a7b1fc' : '#000000' ,
100
+ marginBottom : '1%' ,
101
+ display : 'inline-block'
119
102
}
120
103
} ) ;
121
- titleSpan . appendChild ( badgeElement ) ;
104
+ containerElement . querySelector ( this . BADGE_ELEMENT_SELECTOR ) . appendChild ( badgeElement ) ;
122
105
123
- // Rewrite URL breadcrumb
106
+ //Rewrite URL breadcrumb
124
107
for ( const url of containerElement . querySelectorAll ( this . ANCHOR_ELEMENT_SELECTOR ) ) {
125
108
RewriteUtil . doUrlSpan ( wikiInfo , url ) ;
126
109
}
127
-
128
- // Rewrite network name
129
- containerElement . querySelector ( this . NETWORK_NAME_ELEMENT_SELECTOR ) . textContent = 'wiki.gg' ;
130
110
}
131
111
}
132
112
133
- DdgSearchModule . invoke ( wikis ) ;
113
+ debugger ;
114
+ document . onreadystatechange = ( ) => {
115
+ if ( document . readyState === "complete" ) {
116
+ DdgSearchModule . invoke ( wikis ) ;
117
+
118
+ }
119
+ } ;
0 commit comments