mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-04 18:19:38 +02:00
bringing branch up to date with master
This commit is contained in:
commit
df2db73fb1
@ -59,33 +59,9 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
|
||||
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 ( selector in selectors ) {
|
||||
if ( selectors.hasOwnProperty(selector) ) {
|
||||
injectedSelectors[selector] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Flush dead code from memory (does this work?)
|
||||
domLoaded = null;
|
||||
};
|
||||
|
||||
var retrieveGenericSelectors = function() {
|
||||
@ -103,20 +79,48 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
|
||||
},
|
||||
retrieveHandler
|
||||
);
|
||||
// https://github.com/gorhill/uBlock/issues/452
|
||||
// There is only one first..
|
||||
retrieveHandler = otherRetrieveHandler;
|
||||
} else {
|
||||
retrieveHandler(null);
|
||||
otherRetrieveHandler(null);
|
||||
}
|
||||
idSelectors = null;
|
||||
classSelectors = null;
|
||||
};
|
||||
|
||||
var retrieveHandler = function(selectors) {
|
||||
// https://github.com/gorhill/uBlock/issues/452
|
||||
// See above.
|
||||
if ( typeof firstRunHandler === 'function' ) {
|
||||
firstRunHandler();
|
||||
firstRunHandler = undefined;
|
||||
// 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 firstRetrieveHandler = function(response) {
|
||||
// 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 ) {
|
||||
if ( selectors.hasOwnProperty(selector) ) {
|
||||
injectedSelectors[selector] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Flush dead code from memory (does this work?)
|
||||
firstRetrieveHandler = null;
|
||||
|
||||
otherRetrieveHandler(response);
|
||||
};
|
||||
|
||||
var otherRetrieveHandler = function(selectors) {
|
||||
//console.debug('µBlock> contextNodes = %o', contextNodes);
|
||||
if ( selectors && selectors.highGenerics ) {
|
||||
highGenerics = selectors.highGenerics;
|
||||
@ -157,6 +161,8 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
|
||||
contextNodes.length = 0;
|
||||
};
|
||||
|
||||
var retrieveHandler = firstRetrieveHandler;
|
||||
|
||||
// Ensure elements matching a set of selectors are visually removed
|
||||
// from the page, by:
|
||||
// - Modifying the style property on the elements themselves
|
||||
|
Loading…
Reference in New Issue
Block a user