File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ var EXTENSION_ID = chrome.runtime.id,
3131 WEBSITES = { } ,
3232 URL_PARTS_REGEX = / \/ [ ^ / ? # ] + / g,
3333 PROTOCOL_REGEX = / [ ^ / ] + / g,
34+ PROTOCOL_WWW_REGEX = / [ ^ / ] + \/ \/ ( w w w \. ) ? / ,
3435 SEARCH_REGEX = new RegExp ( '[?&](' + SEARCH_PARAMS . join ( '|' ) + ')=([^&]+)' ) ;
3536
3637
@@ -185,7 +186,10 @@ function cacheHistory() {
185186 }
186187
187188 BY_DOMAIN . push ( [ key , item . d ] ) ;
188- SEARCH . push ( [ key , item . c || 0 , key . match ( / \/ \/ ( [ ^ / ] + ) / ) [ 1 ] ] ) ;
189+
190+ var start_with = key . match ( PROTOCOL_WWW_REGEX ) [ 0 ] ;
191+
192+ SEARCH . push ( [ key . replace ( start_with , '' ) , item . c || 0 , start_with ] ) ;
189193 }
190194
191195 for ( var category in CATEGORIES ) {
Original file line number Diff line number Diff line change @@ -132,13 +132,21 @@ function initSearchBar() {
132132 }
133133 }*/
134134
135- for ( var i = 0 , l = SEARCH . length ; i < l ; i ++ ) {
135+ /* for (var i = 0, l = SEARCH.length; i < l; i++) {
136136 var item = SEARCH[i],
137- m = item [ 2 ] . match ( r ) ;
137+ m = item[0 ].match(r);
138138
139139 if (m) {
140140 results.push(item);
141141 }
142+ }*/
143+
144+ for ( var i = 0 , l = SEARCH . length ; i < l ; i ++ ) {
145+ var item = SEARCH [ i ] ;
146+
147+ if ( item [ 0 ] . indexOf ( this . value ) === 0 ) {
148+ results . push ( item ) ;
149+ }
142150 }
143151
144152 results = sort ( results , 1 ) ;
@@ -148,9 +156,9 @@ function initSearchBar() {
148156 for ( var i = 0 , l = results . length ; i < l ; i ++ ) {
149157 var item = document . createElement ( 'div' ) ;
150158
151- item . innerText = results [ i ] [ 2 ] ;
152- item . dataset . url = results [ i ] [ 0 ] ;
153- item . style . backgroundImage = 'url(chrome://favicon/' + results [ i ] [ 0 ] + ')' ;
159+ item . innerText = results [ i ] [ 0 ] ;
160+ item . dataset . url = results [ i ] [ 2 ] + results [ i ] [ 0 ] ;
161+ item . style . backgroundImage = 'url(chrome://favicon/' + results [ i ] [ 2 ] + results [ i ] [ 0 ] + ')' ;
154162
155163 item . addEventListener ( 'click' , function ( ) {
156164 search_results_element . style . display = 'none' ;
@@ -161,7 +169,7 @@ function initSearchBar() {
161169 search_results_element . appendChild ( item ) ;
162170 }
163171
164- first = results [ 0 ] [ 2 ] ;
172+ first = results [ 0 ] [ 0 ] ;
165173
166174 if ( first ) {
167175 search_results_element . children [ 0 ] . className = 'selected' ;
You can’t perform that action at this time.
0 commit comments