mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Code review of session filters commit
Related commits: -46d36cb0b0
-59c9a34d34
This commit is contained in:
parent
16261aa6b5
commit
7912e919b6
5 changed files with 28 additions and 8 deletions
|
@ -205,7 +205,13 @@ const FilterContainer = function() {
|
|||
this.specificFilters = new µb.staticExtFilteringEngine.HostnameBasedDB(2);
|
||||
|
||||
// temporary filters
|
||||
this.sessionFilterDB = new µb.staticExtFilteringEngine.SessionDB();
|
||||
this.sessionFilterDB = new (
|
||||
class extends µb.staticExtFilteringEngine.SessionDB {
|
||||
compile(s) {
|
||||
return µb.staticExtFilteringEngine.compileSelector(s);
|
||||
}
|
||||
}
|
||||
)();
|
||||
|
||||
// low generic cosmetic filters, organized by id/class then simple/complex.
|
||||
this.lowlyGeneric = Object.create(null);
|
||||
|
|
|
@ -29,7 +29,14 @@
|
|||
const duplicates = new Set();
|
||||
|
||||
const filterDB = new µb.staticExtFilteringEngine.HostnameBasedDB(2);
|
||||
const sessionFilterDB = new µb.staticExtFilteringEngine.SessionDB();
|
||||
const sessionFilterDB = new (
|
||||
class extends µb.staticExtFilteringEngine.SessionDB {
|
||||
compile(s) {
|
||||
return µb.staticExtFilteringEngine.compileSelector(s.slice(1));
|
||||
}
|
||||
}
|
||||
)();
|
||||
|
||||
let acceptedCount = 0;
|
||||
let discardedCount = 0;
|
||||
let docRegister;
|
||||
|
|
|
@ -1282,21 +1282,18 @@ const getURLFilteringData = function(details) {
|
|||
const compileTemporaryException = function(filter) {
|
||||
const match = /#@?#/.exec(filter);
|
||||
if ( match === null ) { return; }
|
||||
let selector = filter.slice(match.index + match[0].length);
|
||||
let selector = filter.slice(match.index + match[0].length).trim();
|
||||
let session;
|
||||
if ( selector.startsWith('+js') ) {
|
||||
session = µb.scriptletFilteringEngine.getSession();
|
||||
selector = selector.slice(4, -1).trim();
|
||||
} else {
|
||||
if ( selector.startsWith('^') ) {
|
||||
session = µb.htmlFilteringEngine.getSession();
|
||||
selector = selector.slice(1).trim();
|
||||
} else {
|
||||
session = µb.cosmeticFilteringEngine.getSession();
|
||||
}
|
||||
selector = µb.staticExtFilteringEngine.compileSelector(selector);
|
||||
}
|
||||
return { session, selector };
|
||||
return { session, selector: session.compile(selector) };
|
||||
};
|
||||
|
||||
const toggleTemporaryException = function(details) {
|
||||
|
|
|
@ -30,7 +30,14 @@
|
|||
const reEscapeScriptArg = /[\\'"]/g;
|
||||
|
||||
const scriptletDB = new µb.staticExtFilteringEngine.HostnameBasedDB(1);
|
||||
const sessionScriptletDB = new µb.staticExtFilteringEngine.SessionDB();
|
||||
const sessionScriptletDB = new (
|
||||
class extends µb.staticExtFilteringEngine.SessionDB {
|
||||
compile(s) {
|
||||
return s.slice(4, -1).trim();
|
||||
}
|
||||
}
|
||||
)();
|
||||
|
||||
let acceptedCount = 0;
|
||||
let discardedCount = 0;
|
||||
|
||||
|
|
|
@ -643,6 +643,9 @@
|
|||
constructor() {
|
||||
this.db = new Map();
|
||||
}
|
||||
compile(s) {
|
||||
return s;
|
||||
}
|
||||
add(bits, s) {
|
||||
const bucket = this.db.get(bits);
|
||||
if ( bucket === undefined ) {
|
||||
|
|
Loading…
Reference in a new issue