1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00
This commit is contained in:
gorhill 2015-03-28 11:09:36 -04:00
parent 231e640a79
commit 1a0d36b7aa

View File

@ -135,7 +135,7 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
var selectors = vAPI.hideCosmeticFilters;
if ( typeof selectors === 'object' ) {
injectedSelectors = selectors;
//hideElements(Object.keys(selectors));
hideElements(Object.keys(selectors));
}
// Add exception filters into injected filters collection, in order
// to force them to be seen as "already injected".
@ -196,10 +196,11 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
// - Injecting a style tag
var addStyleTag = function(selectors) {
//hideElements(selectors);
var selectorStr = selectors.toString();
hideElements(selectorStr);
var style = document.createElement('style');
// The linefeed before the style block is very important: do no remove!
style.appendChild(document.createTextNode(selectors.toString() + '\n{display:none !important;}'));
style.appendChild(document.createTextNode(selectorStr + '\n{display:none !important;}'));
var parent = document.body || document.documentElement;
if ( parent ) {
parent.appendChild(style);
@ -213,7 +214,6 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
//console.debug('µBlock> generic cosmetic filters: injecting %d CSS rules:', selectors.length, text);
};
/*
var hideElements = function(selectors) {
// https://github.com/gorhill/uBlock/issues/207
// Do not call querySelectorAll() using invalid CSS selectors
@ -231,7 +231,6 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
elems[i].style.setProperty('display', 'none', 'important');
}
};
*/
// Extract and return the staged nodes which (may) match the selectors.