Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
this fixes #333
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jun 9, 2014
1 parent 0391b3d commit e921f9e
Show file tree
Hide file tree
Showing 5 changed files with 712 additions and 39 deletions.
102 changes: 71 additions & 31 deletions js/abp-hide-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ FilterContainer.prototype.addFilterEntry = function(hash, f) {

/******************************************************************************/

FilterContainer.prototype.retrieve = function(request) {
FilterContainer.prototype.retrieveGenericSelectors = function(request) {
if ( httpsb.userSettings.parseAllABPHideFilters !== true ) {
return;
}
Expand All @@ -563,6 +563,10 @@ FilterContainer.prototype.retrieve = function(request) {
return;
}

if ( !request.selectors ) {
return;
}

//quickProfiler.start('FilterContainer.retrieve()');

//filterTestCount = 0;
Expand All @@ -576,44 +580,80 @@ FilterContainer.prototype.retrieve = function(request) {
};

var hash, bucket;

if ( request.locationURL ) {
var hostname = pageHostname = httpsb.URI.hostnameFromURI(request.locationURL);
var domain = httpsb.URI.domainFromHostname(hostname);
hash = makePrefixHash('#', domain);
if ( bucket = this.filters[hash] ) {
//bucketTestCount += 1;
//filterTestCount += 1;
bucket.retrieve(null, r.hide);
var hideSelectors = r.hide;
var selectors = request.selectors;
var i = selectors.length;
var selector;
while ( i-- ) {
selector = selectors[i];
if ( !selector ) {
continue;
}
hash = makePrefixHash('@', domain);
hash = makeSuffixHash('#', selector);
if ( bucket = this.filters[hash] ) {
//bucketTestCount += 1;
//filterTestCount += 1;
bucket.retrieve(null, r.donthide);
bucket.retrieve(selector, hideSelectors);
}
}

if ( request.selectors ) {
var hideSelectors = r.hide;
var selectors = request.selectors;
var i = selectors.length;
var selector;
while ( i-- ) {
selector = selectors[i];
if ( !selector ) {
continue;
}
hash = makeSuffixHash('#', selector);
if ( bucket = this.filters[hash] ) {
//bucketTestCount += 1;
//filterTestCount += 1;
bucket.retrieve(selector, hideSelectors);
}
}
r.hideUnfiltered = this.hideUnfiltered;
r.donthideUnfiltered = this.donthideUnfiltered;

//quickProfiler.stop();

/*
console.log(
'HTTPSB> abp-hide-filters.js: "%s"\n\t%d selectors in => %d/%d filters/buckets tested => %d selectors out',
url,
inSelectors.length,
//filterTestCount,
//bucketTestCount,
hideSelectors.length + donthideSelectors.length
);
*/

return r;
};

/******************************************************************************/

FilterContainer.prototype.retrieveDomainSelectors = function(request) {
if ( httpsb.userSettings.parseAllABPHideFilters !== true ) {
return;
}

if ( httpsb.getTemporaryABPFilteringFromPageURL(request.pageURL) !== true ) {
return;
}

r.hideUnfiltered = this.hideUnfiltered;
r.donthideUnfiltered = this.donthideUnfiltered;
if ( !request.locationURL ) {
return;
}

//quickProfiler.start('FilterContainer.retrieve()');

//filterTestCount = 0;
//bucketTestCount = 0;

var hostname = pageHostname = httpsb.URI.hostnameFromURI(request.locationURL);
var r = {
domain: httpsb.URI.domainFromHostname(hostname),
hide: [],
donthide: []
};
var bucket;
var hash = makePrefixHash('#', r.domain);
if ( bucket = this.filters[hash] ) {
//bucketTestCount += 1;
//filterTestCount += 1;
bucket.retrieve(null, r.hide);
}
hash = makePrefixHash('@', r.domain);
if ( bucket = this.filters[hash] ) {
//bucketTestCount += 1;
//filterTestCount += 1;
bucket.retrieve(null, r.donthide);
}

//quickProfiler.stop();
Expand Down
Loading

0 comments on commit e921f9e

Please sign in to comment.