Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
this fixes #325
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jun 2, 2014
1 parent 4fbb511 commit 82a3f78
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion js/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ CosmeticFiltering.prototype.retrieveHandler = function(generic, selectors) {
var hideStyleText = '{{hideSelectors}} {display:none !important;}'
.replace('{{hideSelectors}}', selectors.hide.join(','));
styleText.push(hideStyleText);
this.applyCSS(selectors.hide, 'display', 'none');
//console.log('HTTPSB> ABP cosmetic filters: injecting %d CSS rules:', selectors.hide.length, hideStyleText);
}
if ( generic ) {
Expand All @@ -166,12 +167,26 @@ CosmeticFiltering.prototype.retrieveHandler = function(generic, selectors) {
var dontHideStyleText = '{{donthideSelectors}} {display:initial !important;}'
.replace('{{donthideSelectors}}', selectors.donthide.join(','));
styleText.push(dontHideStyleText);
this.applyCSS(selectors.hide, 'display', 'initial');
//console.log('HTTPSB> ABP cosmetic filters: injecting %d CSS rules:', selectors.donthide.length, dontHideStyleText);
}
if ( styleText.length > 0 ) {
var style = document.createElement('style');
style.appendChild(document.createTextNode(styleText.join('')));
document.documentElement.appendChild(style);
var parent = document.body || document.documentElement;
if ( parent ) {
parent.appendChild(style);
}
}
};

CosmeticFiltering.prototype.applyCSS = function(selectors, prop, value) {
var elems = document.querySelectorAll(selectors);
if ( elems !== null ) {
var i = elems.length, elem;
while ( i-- ) {
elems[i].style[prop] = value;
}
}
};

Expand Down

0 comments on commit 82a3f78

Please sign in to comment.