mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-23 19:03:02 +01:00
support elemhide filter option
This commit is contained in:
parent
5bc2309357
commit
ba31014503
@ -402,7 +402,7 @@ var onMessage = function(details, sender, callback) {
|
||||
|
||||
switch ( details.what ) {
|
||||
case 'retrieveGenericCosmeticSelectors':
|
||||
if ( pageStore && pageStore.getNetFilteringSwitch() ) {
|
||||
if ( pageStore && pageStore.getCosmeticFilteringSwitch() ) {
|
||||
response = µb.cosmeticFilteringEngine.retrieveGenericSelectors(details);
|
||||
}
|
||||
break;
|
||||
|
@ -492,6 +492,12 @@ PageStore.prototype.init = function(tabId, pageURL) {
|
||||
this.skipLocalMirroring = false;
|
||||
this.netFilteringCache = NetFilteringResultCache.factory();
|
||||
|
||||
// Support `elemhide` filter option. Called at this point so the required
|
||||
// context is all setup at this point.
|
||||
this.skipCosmeticFiltering = µb.staticNetFilteringEngine
|
||||
.matchStringExactType(this, pageURL, 'cosmetic-filtering')
|
||||
.charAt(1) === 'b';
|
||||
|
||||
// Preserve old buffer if there is one already, it may be in use, and
|
||||
// overwritting it would required another read to restart it.
|
||||
if ( this.logBuffer instanceof LogBuffer === false ) {
|
||||
@ -596,6 +602,13 @@ PageStore.prototype.getNetFilteringSwitch = function() {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.getCosmeticFilteringSwitch = function() {
|
||||
return this.getNetFilteringSwitch() === false ||
|
||||
this.skipCosmeticFiltering == false;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.filterRequest = function(context) {
|
||||
if ( this.getNetFilteringSwitch() === false ) {
|
||||
this.cacheResult(context, '');
|
||||
|
@ -64,6 +64,7 @@ var typeNameToTypeValue = {
|
||||
'xmlhttprequest': 6 << 4,
|
||||
'sub_frame': 7 << 4,
|
||||
'other': 8 << 4,
|
||||
'cosmetic-filtering': 13 << 4,
|
||||
'inline-script': 14 << 4,
|
||||
'popup': 15 << 4
|
||||
};
|
||||
@ -1245,6 +1246,11 @@ FilterParser.prototype.parse = function(s) {
|
||||
this.parseOptParty(not);
|
||||
continue;
|
||||
}
|
||||
if ( opt === 'elemhide' && this.action === AllowAction ) {
|
||||
this.types.push(typeNameToTypeValue['cosmetic-filtering']);
|
||||
this.action = BlockAction;
|
||||
continue;
|
||||
}
|
||||
if ( this.toNormalizedType.hasOwnProperty(opt) ) {
|
||||
this.parseOptType(opt, not);
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user