mirror of https://github.com/gorhill/uBlock.git
fixed overzealous cosmetic filter bug introduced in #365
This commit is contained in:
parent
7e55dc898e
commit
f141d6f769
|
@ -43,7 +43,7 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
|
|||
|
||||
(function() {
|
||||
var queriedSelectors = {};
|
||||
var injectedSelectors = vAPI.injectedCosmeticFilters || {};
|
||||
var injectedSelectors = vAPI.hideCosmeticFilters || {};
|
||||
var classSelectors = null;
|
||||
var idSelectors = null;
|
||||
var highGenerics = null;
|
||||
|
@ -55,9 +55,19 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
|
|||
// 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..
|
||||
if ( vAPI.injectedCosmeticFilters ) {
|
||||
hideElements(Object.keys(vAPI.injectedCosmeticFilters).join(','));
|
||||
if ( vAPI.hideCosmeticFilters ) {
|
||||
hideElements(Object.keys(vAPI.hideCosmeticFilters).join(','));
|
||||
}
|
||||
// Add exception filters into injected filters collection, in order
|
||||
// to force them to be seen as "already injected".
|
||||
var donthideCosmeticFilters = vAPI.donthideCosmeticFilters;
|
||||
for ( var selector in donthideCosmeticFilters ) {
|
||||
if ( donthideCosmeticFilters.hasOwnProperty(selector) === false ) {
|
||||
continue;
|
||||
}
|
||||
injectedSelectors[selector] = true;
|
||||
}
|
||||
// Now scan content of page
|
||||
idsFromNodeList(document.querySelectorAll('[id]'));
|
||||
classesFromNodeList(document.querySelectorAll('[class]'));
|
||||
retrieveGenericSelectors();
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
/* jshint multistr: true */
|
||||
/* global vAPI */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Injected into content pages
|
||||
|
@ -32,6 +30,8 @@
|
|||
|
||||
(function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// because Safari
|
||||
|
@ -55,7 +55,8 @@ var cosmeticFilters = function(details) {
|
|||
if ( style !== null ) {
|
||||
return;
|
||||
}
|
||||
var injectedCosmeticFilters = {};
|
||||
var donthideCosmeticFilters = {};
|
||||
var hideCosmeticFilters = {};
|
||||
style = document.createElement('style');
|
||||
style.setAttribute('id', 'ublock-preload-1ae7a5f130fc79b4fdb8a4272d9426b5');
|
||||
var donthide = details.cosmeticDonthide;
|
||||
|
@ -65,7 +66,7 @@ var cosmeticFilters = function(details) {
|
|||
donthide = donthide.split(',\n');
|
||||
var i = donthide.length;
|
||||
while ( i-- ) {
|
||||
injectedCosmeticFilters[donthide[i]] = true;
|
||||
donthideCosmeticFilters[donthide[i]] = true;
|
||||
}
|
||||
// https://github.com/gorhill/uBlock/issues/143
|
||||
if ( hide.length !== 0 ) {
|
||||
|
@ -75,10 +76,10 @@ var cosmeticFilters = function(details) {
|
|||
var selector;
|
||||
while ( i-- ) {
|
||||
selector = hide[i];
|
||||
if ( injectedCosmeticFilters[selector] ) {
|
||||
if ( donthideCosmeticFilters[selector] ) {
|
||||
hide.splice(i, 1);
|
||||
} else {
|
||||
injectedCosmeticFilters[selector] = true;
|
||||
hideCosmeticFilters[selector] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +95,8 @@ var cosmeticFilters = function(details) {
|
|||
if ( parent ) {
|
||||
parent.appendChild(style);
|
||||
}
|
||||
vAPI.injectedCosmeticFilters = injectedCosmeticFilters;
|
||||
vAPI.donthideCosmeticFilters = donthideCosmeticFilters;
|
||||
vAPI.hideCosmeticFilters = hideCosmeticFilters;
|
||||
};
|
||||
|
||||
var netFilters = function(details) {
|
||||
|
|
Loading…
Reference in New Issue