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() {
|
(function() {
|
||||||
var queriedSelectors = {};
|
var queriedSelectors = {};
|
||||||
var injectedSelectors = vAPI.injectedCosmeticFilters || {};
|
var injectedSelectors = vAPI.hideCosmeticFilters || {};
|
||||||
var classSelectors = null;
|
var classSelectors = null;
|
||||||
var idSelectors = null;
|
var idSelectors = null;
|
||||||
var highGenerics = null;
|
var highGenerics = null;
|
||||||
|
@ -55,9 +55,19 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
|
||||||
// Ensure injected styles are enforced
|
// Ensure injected styles are enforced
|
||||||
// rhill 2014-11-16: not sure this is needed anymore. Test case in
|
// rhill 2014-11-16: not sure this is needed anymore. Test case in
|
||||||
// above issue was fine without the line below..
|
// above issue was fine without the line below..
|
||||||
if ( vAPI.injectedCosmeticFilters ) {
|
if ( vAPI.hideCosmeticFilters ) {
|
||||||
hideElements(Object.keys(vAPI.injectedCosmeticFilters).join(','));
|
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]'));
|
idsFromNodeList(document.querySelectorAll('[id]'));
|
||||||
classesFromNodeList(document.querySelectorAll('[class]'));
|
classesFromNodeList(document.querySelectorAll('[class]'));
|
||||||
retrieveGenericSelectors();
|
retrieveGenericSelectors();
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
/* jshint multistr: true */
|
/* jshint multistr: true */
|
||||||
/* global vAPI */
|
/* global vAPI */
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// Injected into content pages
|
// Injected into content pages
|
||||||
|
@ -32,6 +30,8 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// because Safari
|
// because Safari
|
||||||
|
@ -55,7 +55,8 @@ var cosmeticFilters = function(details) {
|
||||||
if ( style !== null ) {
|
if ( style !== null ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var injectedCosmeticFilters = {};
|
var donthideCosmeticFilters = {};
|
||||||
|
var hideCosmeticFilters = {};
|
||||||
style = document.createElement('style');
|
style = document.createElement('style');
|
||||||
style.setAttribute('id', 'ublock-preload-1ae7a5f130fc79b4fdb8a4272d9426b5');
|
style.setAttribute('id', 'ublock-preload-1ae7a5f130fc79b4fdb8a4272d9426b5');
|
||||||
var donthide = details.cosmeticDonthide;
|
var donthide = details.cosmeticDonthide;
|
||||||
|
@ -65,7 +66,7 @@ var cosmeticFilters = function(details) {
|
||||||
donthide = donthide.split(',\n');
|
donthide = donthide.split(',\n');
|
||||||
var i = donthide.length;
|
var i = donthide.length;
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
injectedCosmeticFilters[donthide[i]] = true;
|
donthideCosmeticFilters[donthide[i]] = true;
|
||||||
}
|
}
|
||||||
// https://github.com/gorhill/uBlock/issues/143
|
// https://github.com/gorhill/uBlock/issues/143
|
||||||
if ( hide.length !== 0 ) {
|
if ( hide.length !== 0 ) {
|
||||||
|
@ -75,10 +76,10 @@ var cosmeticFilters = function(details) {
|
||||||
var selector;
|
var selector;
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
selector = hide[i];
|
selector = hide[i];
|
||||||
if ( injectedCosmeticFilters[selector] ) {
|
if ( donthideCosmeticFilters[selector] ) {
|
||||||
hide.splice(i, 1);
|
hide.splice(i, 1);
|
||||||
} else {
|
} else {
|
||||||
injectedCosmeticFilters[selector] = true;
|
hideCosmeticFilters[selector] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +95,8 @@ var cosmeticFilters = function(details) {
|
||||||
if ( parent ) {
|
if ( parent ) {
|
||||||
parent.appendChild(style);
|
parent.appendChild(style);
|
||||||
}
|
}
|
||||||
vAPI.injectedCosmeticFilters = injectedCosmeticFilters;
|
vAPI.donthideCosmeticFilters = donthideCosmeticFilters;
|
||||||
|
vAPI.hideCosmeticFilters = hideCosmeticFilters;
|
||||||
};
|
};
|
||||||
|
|
||||||
var netFilters = function(details) {
|
var netFilters = function(details) {
|
||||||
|
|
Loading…
Reference in New Issue