mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Fix generichide
not being evaluated for local context
Related issue: - https://github.com/uBlockOrigin/uAssets/issues/5704
This commit is contained in:
parent
27911e918c
commit
2eb9b726a5
2 changed files with 25 additions and 38 deletions
|
@ -547,12 +547,29 @@ var onMessage = function(request, sender, callback) {
|
|||
) {
|
||||
break;
|
||||
}
|
||||
const noCosmeticFiltering = pageStore.noCosmeticFiltering === true;
|
||||
response = {
|
||||
collapseBlocked: µb.userSettings.collapseBlocked,
|
||||
noCosmeticFiltering: pageStore.noCosmeticFiltering === true,
|
||||
noGenericCosmeticFiltering:
|
||||
pageStore.noGenericCosmeticFiltering === true
|
||||
noCosmeticFiltering,
|
||||
noGenericCosmeticFiltering: noCosmeticFiltering,
|
||||
};
|
||||
// https://github.com/uBlockOrigin/uAssets/issues/5704
|
||||
// `generichide` must be evaluated in the frame context.
|
||||
if ( noCosmeticFiltering === false ) {
|
||||
const genericHide =
|
||||
µb.staticNetFilteringEngine.matchStringGenericHide(request.url);
|
||||
response.noGenericCosmeticFiltering = genericHide === 2;
|
||||
if ( genericHide !== 0 && µb.logger.enabled ) {
|
||||
µBlock.filteringContext
|
||||
.duplicate()
|
||||
.fromTabId(tabId)
|
||||
.setURL(request.url)
|
||||
.setRealm('network')
|
||||
.setType('generichide')
|
||||
.setFilter(µb.staticNetFilteringEngine.toLogData())
|
||||
.toLogger();
|
||||
}
|
||||
}
|
||||
request.tabId = tabId;
|
||||
request.frameId = frameId;
|
||||
request.hostname = µb.URI.hostnameFromURI(request.url);
|
||||
|
@ -572,14 +589,11 @@ var onMessage = function(request, sender, callback) {
|
|||
break;
|
||||
|
||||
case 'retrieveGenericCosmeticSelectors':
|
||||
if ( pageStore && pageStore.getGenericCosmeticFilteringSwitch() ) {
|
||||
request.tabId = tabId;
|
||||
request.frameId = frameId;
|
||||
response = {
|
||||
result: µb.cosmeticFilteringEngine
|
||||
.retrieveGenericSelectors(request)
|
||||
};
|
||||
}
|
||||
request.tabId = tabId;
|
||||
request.frameId = frameId;
|
||||
response = {
|
||||
result: µb.cosmeticFilteringEngine.retrieveGenericSelectors(request)
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -310,28 +310,6 @@ PageStore.prototype.init = function(tabId, context) {
|
|||
.toLogger();
|
||||
}
|
||||
|
||||
// Support `generichide` filter option.
|
||||
this.noGenericCosmeticFiltering = masterSwitch !== true;
|
||||
if ( this.noGenericCosmeticFiltering !== true ) {
|
||||
this.noGenericCosmeticFiltering = this.noCosmeticFiltering;
|
||||
if ( this.noGenericCosmeticFiltering !== true ) {
|
||||
let result = µb.staticNetFilteringEngine.matchStringGenericHide(
|
||||
tabContext.normalURL
|
||||
);
|
||||
this.noGenericCosmeticFiltering = result === 2;
|
||||
if (
|
||||
result !== 0 &&
|
||||
µb.logger.enabled &&
|
||||
context === 'tabCommitted'
|
||||
) {
|
||||
fctxt.setRealm('network')
|
||||
.setType('generichide')
|
||||
.setFilter(µb.staticNetFilteringEngine.toLogData())
|
||||
.toLogger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
@ -429,11 +407,6 @@ PageStore.prototype.getSpecificCosmeticFilteringSwitch = function() {
|
|||
return this.noCosmeticFiltering !== true;
|
||||
};
|
||||
|
||||
PageStore.prototype.getGenericCosmeticFilteringSwitch = function() {
|
||||
return this.noGenericCosmeticFiltering !== true &&
|
||||
this.noCosmeticFiltering !== true;
|
||||
};
|
||||
|
||||
PageStore.prototype.toggleNetFilteringSwitch = function(url, scope, state) {
|
||||
µb.toggleNetFilteringSwitch(url, scope, state);
|
||||
this.netFilteringCache.empty();
|
||||
|
|
Loading…
Reference in a new issue