@@ -241,6 +241,7 @@ var FilterContainer = function() {
241241 this . acceptedCount = 0 ;
242242 this . processedCount = 0 ;
243243 this . filters = { } ;
244+ this . rejected = [ ] ;
244245} ;
245246
246247/******************************************************************************/
@@ -252,6 +253,9 @@ FilterContainer.prototype.reset = function() {
252253 this . acceptedCount = 0 ;
253254 this . processedCount = 0 ;
254255 this . filters = { } ;
256+ this . hideUnfiltered = [ ] ;
257+ this . donthideUnfiltered = [ ] ;
258+ this . rejected = [ ] ;
255259} ;
256260
257261/******************************************************************************/
@@ -289,21 +293,44 @@ FilterContainer.prototype.add = function(s) {
289293 // Content script side, the unsorted container of selectors could be used
290294 // in a querySelectorAll() to figure which rules apply (if any), or they
291295 // could just all be injected undiscriminately (not good).
292- if ( parsed . isElement ( ) ) {
293- return this . addElementFilter ( parsed ) ;
296+ if ( parsed . filterType === '#' ) {
297+ this . hideUnfiltered . push ( parsed . suffix ) ;
298+ } else {
299+ this . donthideUnfiltered . push ( parsed . suffix ) ;
294300 }
301+ this . acceptedCount += 1 ;
295302
296- return false ;
303+ return true ;
304+ } ;
305+
306+ /******************************************************************************/
307+
308+ FilterContainer . prototype . chunkify = function ( selectors ) {
309+ var chunkified = [ ] , chunk ;
310+ for ( ; ; ) {
311+ chunk = selectors . splice ( 0 , 10 ) ;
312+ if ( chunk . length === 0 ) {
313+ break ;
314+ }
315+ chunkified . push ( chunk . join ( ',' ) ) ;
316+ }
317+ return chunkified ;
297318} ;
298319
299320/******************************************************************************/
300321
301322FilterContainer . prototype . freeze = function ( ) {
323+ this . hideUnfiltered = this . chunkify ( this . hideUnfiltered ) ;
324+ this . donthideUnfiltered = this . chunkify ( this . donthideUnfiltered ) ;
325+
302326 this . filterParser . reset ( ) ;
303327
304328 console . log ( 'HTTPSB> adp-hide-filters.js: %d filters accepted' , this . acceptedCount ) ;
305329 console . log ( 'HTTPSB> adp-hide-filters.js: %d filters processed' , this . processedCount ) ;
306330 console . log ( 'HTTPSB> adp-hide-filters.js: coverage is %s%' , ( this . acceptedCount * 100 / this . processedCount ) . toFixed ( 1 ) ) ;
331+ console . log ( 'HTTPSB> adp-hide-filters.js: unfiltered hide selectors:' , this . hideUnfiltered ) ;
332+ console . log ( 'HTTPSB> adp-hide-filters.js: unfiltered dont hide selectors:' , this . donthideUnfiltered ) ;
333+ console . log ( 'HTTPSB> adp-hide-filters.js: rejected selectors:' , this . rejected ) ;
307334
308335 //histogram('allFilters', this.filters);
309336} ;
@@ -436,12 +463,12 @@ FilterContainer.prototype.addPlainFilter = function(parsed) {
436463/******************************************************************************/
437464
438465FilterContainer . prototype . addPlainMoreFilter = function ( parsed ) {
439- var plainSelector = parsed . extractPlain ( ) ;
440- if ( plainSelector === '' ) {
466+ var selectorSuffix = parsed . extractPlain ( ) ;
467+ if ( selectorSuffix === '' ) {
441468 return ;
442469 }
443470 var f = new FilterPlainMore ( parsed . suffix ) ;
444- var hash = makeSuffixHash ( parsed . filterType , plainSelector ) ;
471+ var hash = makeSuffixHash ( parsed . filterType , selectorSuffix ) ;
445472 this . addFilterEntry ( hash , f ) ;
446473 this . acceptedCount += 1 ;
447474} ;
@@ -469,11 +496,6 @@ FilterContainer.prototype.addHostnameFilter = function(parsed) {
469496
470497/******************************************************************************/
471498
472- FilterContainer . prototype . addElementFilter = function ( parsed ) {
473- } ;
474-
475- /******************************************************************************/
476-
477499FilterContainer . prototype . addFilterEntry = function ( hash , f ) {
478500 var bucket = this . filters [ hash ] ;
479501 if ( bucket === undefined ) {
@@ -543,7 +565,9 @@ FilterContainer.prototype.retrieve = function(url, inSelectors) {
543565
544566 return {
545567 hide : hideSelectors ,
546- donthide : donthideSelectors
568+ donthide : donthideSelectors ,
569+ hideUnfiltered : this . hideUnfiltered ,
570+ donthideUnfiltered : this . donthideUnfiltered
547571 } ;
548572} ;
549573
0 commit comments