1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-04 18:19:38 +02:00

Merge branch 'master' of github.com:gorhill/uBlock into fix-433

This commit is contained in:
gorhill 2014-12-31 23:24:07 -05:00
commit 3b0dac6402

View File

@ -48,7 +48,7 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
}
var queriedSelectors = {};
var injectedSelectors = vAPI.hideCosmeticFilters || {};
var injectedSelectors = {};
var classSelectors = null;
var idSelectors = null;
var highGenerics = null;
@ -56,28 +56,36 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
var nullArray = { push: function(){} };
var domLoaded = function() {
idsFromNodeList(document.querySelectorAll('[id]'));
classesFromNodeList(document.querySelectorAll('[class]'));
retrieveGenericSelectors();
};
// https://github.com/gorhill/uBlock/issues/452
// This needs to be executed *after* the response from our query is
// received, not at `DOMContentLoaded` time, or else there is a good
// likeliness to outrun contentscript-start.js, which may still be waiting
// on a response from its own query.
var firstRunHandler = function() {
// https://github.com/gorhill/uBlock/issues/158
// Ensure injected styles are enforced
// rhill 2014-11-16: not sure this is needed anymore. Test case in
// above issue was fine without the line below..
var selectors = vAPI.hideCosmeticFilters;
if ( typeof selectors === 'object' ) {
injectedSelectors = selectors;
hideElements(Object.keys(selectors).join(','));
}
// Add exception filters into injected filters collection, in order
// to force them to be seen as "already injected".
selectors = vAPI.donthideCosmeticFilters;
if ( typeof selectors === 'object' ) {
for ( var selector in selectors ) {
for ( selector in selectors ) {
if ( selectors.hasOwnProperty(selector) ) {
injectedSelectors[selector] = true;
}
}
}
// Now scan content of page
idsFromNodeList(document.querySelectorAll('[id]'));
classesFromNodeList(document.querySelectorAll('[class]'));
retrieveGenericSelectors();
};
var retrieveGenericSelectors = function() {
@ -103,6 +111,12 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
};
var retrieveHandler = function(selectors) {
// https://github.com/gorhill/uBlock/issues/452
// See above.
if ( typeof firstRunHandler === 'function' ) {
firstRunHandler();
firstRunHandler = undefined;
}
//console.debug('µBlock> contextNodes = %o', contextNodes);
if ( selectors && selectors.highGenerics ) {
highGenerics = selectors.highGenerics;