mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-02 00:42:45 +01: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]'));
|
idsFromNodeList(document.querySelectorAll('[id]'));
|
||||||
classesFromNodeList(document.querySelectorAll('[class]'));
|
classesFromNodeList(document.querySelectorAll('[class]'));
|
||||||
retrieveGenericSelectors();
|
retrieveGenericSelectors();
|
||||||
};
|
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/452
|
// Flush dead code from memory (does this work?)
|
||||||
// This needs to be executed *after* the response from our query is
|
domLoaded = null;
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var retrieveGenericSelectors = function() {
|
var retrieveGenericSelectors = function() {
|
||||||
@ -103,20 +79,48 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
|
|||||||
},
|
},
|
||||||
retrieveHandler
|
retrieveHandler
|
||||||
);
|
);
|
||||||
|
// https://github.com/gorhill/uBlock/issues/452
|
||||||
|
// There is only one first..
|
||||||
|
retrieveHandler = otherRetrieveHandler;
|
||||||
} else {
|
} else {
|
||||||
retrieveHandler(null);
|
otherRetrieveHandler(null);
|
||||||
}
|
}
|
||||||
idSelectors = null;
|
idSelectors = null;
|
||||||
classSelectors = null;
|
classSelectors = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
var retrieveHandler = function(selectors) {
|
// https://github.com/gorhill/uBlock/issues/452
|
||||||
// https://github.com/gorhill/uBlock/issues/452
|
// This needs to be executed *after* the response from our query is
|
||||||
// See above.
|
// received, not at `DOMContentLoaded` time, or else there is a good
|
||||||
if ( typeof firstRunHandler === 'function' ) {
|
// likeliness to outrun contentscript-start.js, which may still be waiting
|
||||||
firstRunHandler();
|
// on a response from its own query.
|
||||||
firstRunHandler = undefined;
|
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);
|
//console.debug('µBlock> contextNodes = %o', contextNodes);
|
||||||
if ( selectors && selectors.highGenerics ) {
|
if ( selectors && selectors.highGenerics ) {
|
||||||
highGenerics = selectors.highGenerics;
|
highGenerics = selectors.highGenerics;
|
||||||
@ -157,6 +161,8 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
|
|||||||
contextNodes.length = 0;
|
contextNodes.length = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var retrieveHandler = firstRetrieveHandler;
|
||||||
|
|
||||||
// Ensure elements matching a set of selectors are visually removed
|
// Ensure elements matching a set of selectors are visually removed
|
||||||
// from the page, by:
|
// from the page, by:
|
||||||
// - Modifying the style property on the elements themselves
|
// - Modifying the style property on the elements themselves
|
||||||
|
Loading…
Reference in New Issue
Block a user