1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-02 00:42:45 +01:00
This commit is contained in:
gorhill 2014-12-17 10:32:50 -05:00
parent ceb36732cc
commit b9c1f2e397
2 changed files with 31 additions and 3 deletions

View File

@ -363,6 +363,17 @@ SelectorCacheEntry.prototype.add = function(selectors, type) {
}
};
// https://github.com/gorhill/uBlock/issues/420
SelectorCacheEntry.prototype.remove = function(type) {
this.lastAccessTime = Date.now();
if ( type === 'cosmetic' ) {
this.cosmetic = {};
} else {
this.net = {};
this.netCount = 0;
}
};
SelectorCacheEntry.prototype.retrieve = function(type, out) {
this.lastAccessTime = Date.now();
var dict = type === 'cosmetic' ? this.cosmetic : this.net;
@ -918,6 +929,16 @@ FilterContainer.prototype.addToSelectorCache = function(details) {
/******************************************************************************/
FilterContainer.prototype.removeFromSelectorCache = function(hostname, type) {
var entry = this.selectorCache[hostname];
if ( entry === undefined ) {
return;
}
entry.remove(type);
};
/******************************************************************************/
FilterContainer.prototype.retrieveFromSelectorCache = function(hostname, type, out) {
var entry = this.selectorCache[hostname];
if ( entry === undefined ) {

View File

@ -314,9 +314,16 @@ var matchWhitelistDirective = function(url, hostname, directive) {
} else {
changed = this.netFilteringEngine.dynamicFilterUnblock(details.hostname, details.requestType, details.firstParty);
}
if ( changed ) {
if ( !changed ) {
return;
}
this.userSettings.dynamicFilteringSelfie = this.netFilteringEngine.selfieFromDynamicFilters();
this.XAL.keyvalSetOne('dynamicFilteringSelfie', this.userSettings.dynamicFilteringSelfie);
// https://github.com/gorhill/uBlock/issues/420
if ( details.requestType === 'sub_frame' && !details.block ) {
this.cosmeticFilteringEngine.removeFromSelectorCache(details.pageHostname, 'net');
}
};