1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-01 16:33:06 +01:00

this fixes under-reporting of active cosmetic filters in logger

This commit is contained in:
gorhill 2015-04-25 08:27:27 -04:00
parent 057611ba25
commit 0ce32af7af
4 changed files with 12 additions and 7 deletions

View File

@ -370,7 +370,7 @@ var uBlockCollapser = (function() {
processHighHighGenericsAsync();
}
}
if ( hideSelectors.length ) {
if ( hideSelectors.length !== 0 ) {
addStyleTag(hideSelectors);
}
contextNodes.length = 0;
@ -687,6 +687,12 @@ var uBlockCollapser = (function() {
idsFromNodeList(selectNodes('[id]'));
classesFromNodeList(selectNodes('[class]'));
retrieveGenericSelectors();
// This is required: a new element could be matching an already
// injected but otherwise inactive cosmetic filter. This means
// the already injected cosmetic filter become active (has an
// effect on the document), and thus must be logged if needed.
messager.send({ what: 'cosmeticFiltersActivated' });
}
};

View File

@ -140,7 +140,7 @@ var filteringHandler = function(details) {
// This is just to inform the background process that cosmetic filters were
// actually injected.
if ( vAPI.styles.length !== styleTagCount ) {
localMessager.send({ what: 'cosmeticFiltersInjected' });
localMessager.send({ what: 'cosmeticFiltersActivated' });
}
// https://github.com/chrisaljoudi/uBlock/issues/587

View File

@ -68,10 +68,10 @@ while ( i-- ) {
if ( loggedSelectors.hasOwnProperty(selector) ) {
continue;
}
loggedSelectors[selector] = true;
if ( document.querySelector(selector) === null ) {
continue;
}
loggedSelectors[selector] = true;
matchedSelectors.push(selector);
}

View File

@ -62,10 +62,9 @@ var onMessage = function(request, sender, callback) {
break;
case 'cosmeticFiltersInjected':
// Is this a request to cache selectors?
if ( Array.isArray(request.selectors) ) {
µb.cosmeticFilteringEngine.addToSelectorCache(request);
}
/* falls through */
case 'cosmeticFiltersActivated':
// Net-based cosmetic filters are of no interest for logging purpose.
if ( µb.logger.isObserved(tabId) && request.type !== 'net' ) {
µb.logCosmeticFilters(tabId);