1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00
This commit is contained in:
Raymond Hill 2018-07-22 10:47:02 -04:00
parent 1836f7656e
commit 51a4e9ccf4
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
6 changed files with 28 additions and 28 deletions

View File

@ -1363,7 +1363,7 @@ var reverseLookupManager = (function() {
'loggerUI',
{
what: 'listsFromCosmeticFilter',
hostname: row.getAttribute('data-hn-frame') || '',
url: row.cells[5].textContent,
rawFilter: rawFilter,
},
reverseLookupDone

View File

@ -69,11 +69,7 @@ var onMessage = function(request, sender, callback) {
return;
case 'listsFromCosmeticFilter':
µb.staticFilteringReverseLookup.fromCosmeticFilter(
request.hostname,
request.rawFilter,
callback
);
µb.staticFilteringReverseLookup.fromCosmeticFilter(request, callback);
return;
case 'reloadAllFilters':

View File

@ -1,7 +1,7 @@
/*******************************************************************************
uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2018 Raymond Hill
Copyright (C) 2014-present Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -319,10 +319,8 @@ PageStore.prototype.init = function(tabId, context) {
// Support `generichide` filter option.
this.noGenericCosmeticFiltering = this.noCosmeticFiltering;
if ( this.noGenericCosmeticFiltering !== true ) {
var result = µb.staticNetFilteringEngine.matchStringExactType(
this.createContextFromPage(),
tabContext.normalURL,
'generichide'
let result = µb.staticNetFilteringEngine.matchStringGenericHide(
tabContext.normalURL
);
this.noGenericCosmeticFiltering = result === 2;
if (

View File

@ -172,6 +172,12 @@ var fromCosmeticFilter = function(details) {
if ( end === -1 ) { end = content.length; }
pos = end;
fargs = JSON.parse(content.slice(beg, end));
// https://github.com/gorhill/uBlock/issues/2763
if ( fargs[0] >= 0 && fargs[0] <= 5 && details.ignoreGeneric ) {
continue;
}
switch ( fargs[0] ) {
case 0: // id-based
if (

View File

@ -161,12 +161,10 @@ var fromNetFilter = function(compiledFilter, rawFilter, callback) {
/******************************************************************************/
var fromCosmeticFilter = function(hostname, rawFilter, callback) {
if ( typeof callback !== 'function' ) {
return;
}
var fromCosmeticFilter = function(details, callback) {
if ( typeof callback !== 'function' ) { return; }
if ( rawFilter === '' ) {
if ( details.rawFilter === '' ) {
callback();
return;
}
@ -176,17 +174,19 @@ var fromCosmeticFilter = function(hostname, rawFilter, callback) {
workerTTLTimer = null;
}
var onWorkerReady = function() {
var id = messageId++;
var message = {
let onWorkerReady = function() {
let id = messageId++;
let hostname = µBlock.URI.hostnameFromURI(details.url);
pendingResponses[id] = callback;
worker.postMessage({
what: 'fromCosmeticFilter',
id: id,
domain: µBlock.URI.domainFromHostname(hostname),
hostname: hostname,
rawFilter: rawFilter
};
pendingResponses[id] = callback;
worker.postMessage(message);
ignoreGeneric: µBlock.staticNetFilteringEngine
.matchStringGenericHide(details.url) === 2,
rawFilter: details.rawFilter
});
// The worker will be shutdown after n minutes without being used.
workerTTLTimer = vAPI.setTimeout(stopWorker, workerTTL);

View File

@ -1,7 +1,7 @@
/*******************************************************************************
uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2018 Raymond Hill
Copyright (C) 2014-present Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -2525,14 +2525,14 @@ FilterContainer.prototype.matchTokens = function(bucket, url) {
// https://github.com/gorhill/uBlock/issues/2103
// User may want to override `generichide` exception filters.
FilterContainer.prototype.matchStringGenericHide = function(context, requestURL) {
var url = this.urlTokenizer.setURL(requestURL);
FilterContainer.prototype.matchStringGenericHide = function(requestURL) {
let url = this.urlTokenizer.setURL(requestURL);
// https://github.com/gorhill/uBlock/issues/2225
// Important: this is used by FilterHostnameDict.match().
requestHostnameRegister = µb.URI.hostnameFromURI(url);
var bucket = this.categories.get(genericHideException);
let bucket = this.categories.get(genericHideException);
if ( !bucket || this.matchTokens(bucket, url) === false ) {
this.fRegister = null;
return 0;
@ -2557,7 +2557,7 @@ FilterContainer.prototype.matchStringGenericHide = function(context, requestURL)
FilterContainer.prototype.matchStringExactType = function(context, requestURL, requestType) {
// Special cases.
if ( requestType === 'generichide' ) {
return this.matchStringGenericHide(context, requestURL);
return this.matchStringGenericHide(requestURL);
}
var type = typeNameToTypeValue[requestType];
if ( type === undefined ) {