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

Commit 8aff806

Browse files
committed
fixed bugs causing too many injected rules, and wrongly parsing exceptions
1 parent efa268f commit 8aff806

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

js/abp-hide-filters.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ var FilterPlain = function(s) {
7979
};
8080

8181
FilterPlain.prototype.retrieve = function(s, out) {
82-
if ( s === this.s.slice(0, s.length) ) {
82+
if ( s === this.s ) {
8383
out.push(this.s);
8484
}
85+
// if ( s === this.s.slice(0, s.length) ) {
86+
// out.push(this.s);
87+
// }
8588
};
8689

8790
/******************************************************************************/
@@ -92,7 +95,7 @@ var FilterPlainHostname = function(s, hostname) {
9295
};
9396

9497
FilterPlainHostname.prototype.retrieve = function(s, out) {
95-
if ( s === this.s.slice(0, s.length) && pageHostname === this.hostname ) {
98+
if ( s === this.s && pageHostname === this.hostname ) {
9699
out.push(this.s);
97100
}
98101
};
@@ -147,7 +150,7 @@ FilterParser.prototype.parse = function(s) {
147150

148151
this.anchor = s.indexOf('##');
149152
if ( this.anchor < 0 ) {
150-
this.anchor = s.indexOf('#@');
153+
this.anchor = s.indexOf('#@#');
151154
if ( this.anchor < 0 ) {
152155
this.invalid = true;
153156
return this;
@@ -157,7 +160,11 @@ FilterParser.prototype.parse = function(s) {
157160
if ( this.anchor > 0 ) {
158161
this.hostnames = s.slice(0, this.anchor).split(/\s*,\s*/);
159162
}
160-
this.f = s.slice(this.anchor + 2);
163+
if ( this.filterType === '@' ) {
164+
this.f = s.slice(this.anchor + 3);
165+
} else {
166+
this.f = s.slice(this.anchor + 2);
167+
}
161168

162169
// selector
163170
var selectorType = this.f.charAt(0);

js/contentscript-elemhide.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ var retrieveHandler = function(selectors) {
2727
}
2828
var styleText = [];
2929
if ( selectors.hide.length > 0 ) {
30-
var hideStyleText = '{{hideSelectors}} {visibility:hidden;display:none;}';
31-
styleText.push(hideStyleText.replace('{{hideSelectors}}', selectors.hide.join(',')));
30+
var hideStyleText = '{{hideSelectors}} {display:none;}'
31+
.replace('{{hideSelectors}}', selectors.hide.join(','));
32+
styleText.push(hideStyleText);
33+
console.log('ABP cosmetic filters: injecting CSS rule:', hideStyleText);
3234
}
3335
if ( selectors.donthide.length > 0 ) {
34-
var dontHideStyleText = '{{donthideSelectors}} {visibility:inherit;display:inherit;}';
35-
styleText.push(donthideStyleText.replace('{{donthideSelectors}}', selectors.donthide.join(',')));
36+
var dontHideStyleText = '{{donthideSelectors}} {display:initial;}'
37+
.replace('{{donthideSelectors}}', selectors.donthide.join(','));
38+
styleText.push(donthideStyleText);
39+
console.log('ABP cosmetic filters: injecting CSS rule:', donthideStyleText);
3640
}
3741
if ( styleText.length > 0 ) {
3842
var style = document.createElement('style');

0 commit comments

Comments
 (0)