1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 15:32:28 +02: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(); processHighHighGenericsAsync();
} }
} }
if ( hideSelectors.length ) { if ( hideSelectors.length !== 0 ) {
addStyleTag(hideSelectors); addStyleTag(hideSelectors);
} }
contextNodes.length = 0; contextNodes.length = 0;
@ -687,6 +687,12 @@ var uBlockCollapser = (function() {
idsFromNodeList(selectNodes('[id]')); idsFromNodeList(selectNodes('[id]'));
classesFromNodeList(selectNodes('[class]')); classesFromNodeList(selectNodes('[class]'));
retrieveGenericSelectors(); 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 // This is just to inform the background process that cosmetic filters were
// actually injected. // actually injected.
if ( vAPI.styles.length !== styleTagCount ) { if ( vAPI.styles.length !== styleTagCount ) {
localMessager.send({ what: 'cosmeticFiltersInjected' }); localMessager.send({ what: 'cosmeticFiltersActivated' });
} }
// https://github.com/chrisaljoudi/uBlock/issues/587 // https://github.com/chrisaljoudi/uBlock/issues/587

View File

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

View File

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