mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-06 02:42:33 +01:00
Add support to urlskip=
media resources
Related feedback: https://github.com/uBlockOrigin/uBlock-issues/issues/3206#issuecomment-2406777654
This commit is contained in:
parent
2c60bb3b07
commit
ce9fc5dc14
@ -166,11 +166,11 @@ export async function benchmarkStaticNetFiltering(options = {}) {
|
||||
let allowCount = 0;
|
||||
let redirectCount = 0;
|
||||
let removeparamCount = 0;
|
||||
let urlskipCount = 0;
|
||||
let cspCount = 0;
|
||||
let permissionsCount = 0;
|
||||
let replaceCount = 0;
|
||||
for ( let i = 0; i < requests.length; i++ ) {
|
||||
const request = requests[i];
|
||||
for ( const request of requests ) {
|
||||
fctxt.setURL(request.url);
|
||||
if ( fctxt.getIPAddress() === '' ) {
|
||||
fctxt.setIPAddress('93.184.215.14\n2606:2800:21f:cb07:6820:80da:af6b:8b2c');
|
||||
@ -186,12 +186,15 @@ export async function benchmarkStaticNetFiltering(options = {}) {
|
||||
if ( sfne.transformRequest(fctxt) ) {
|
||||
redirectCount += 1;
|
||||
}
|
||||
if ( fctxt.redirectURL !== undefined && sfne.hasQuery(fctxt) ) {
|
||||
if ( sfne.filterQuery(fctxt, 'removeparam') ) {
|
||||
if ( sfne.hasQuery(fctxt) ) {
|
||||
if ( sfne.filterQuery(fctxt) ) {
|
||||
removeparamCount += 1;
|
||||
}
|
||||
}
|
||||
if ( fctxt.type === 'main_frame' || fctxt.type === 'sub_frame' ) {
|
||||
if ( sfne.urlSkip(fctxt) ) {
|
||||
urlskipCount += 1;
|
||||
}
|
||||
if ( fctxt.isDocument() ) {
|
||||
if ( sfne.matchAndFetchModifiers(fctxt, 'csp') ) {
|
||||
cspCount += 1;
|
||||
}
|
||||
@ -207,9 +210,9 @@ export async function benchmarkStaticNetFiltering(options = {}) {
|
||||
if ( sfne.redirectRequest(redirectEngine, fctxt) ) {
|
||||
redirectCount += 1;
|
||||
}
|
||||
}
|
||||
if ( fctxt.type === 'main_frame' ) {
|
||||
sfne.matchAndFetchModifiers(fctxt, 'urlskip');
|
||||
if ( fctxt.isRootDocument() && sfne.urlSkip(fctxt) ) {
|
||||
urlskipCount += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
const t1 = performance.now();
|
||||
@ -224,6 +227,7 @@ export async function benchmarkStaticNetFiltering(options = {}) {
|
||||
`\tUnblocked: ${allowCount}`,
|
||||
`\tredirect=: ${redirectCount}`,
|
||||
`\tremoveparam=: ${removeparamCount}`,
|
||||
`\turlskip=: ${urlskipCount}`,
|
||||
`\tcsp=: ${cspCount}`,
|
||||
`\tpermissions=: ${permissionsCount}`,
|
||||
`\treplace=: ${replaceCount}`,
|
||||
|
@ -942,6 +942,9 @@ const PageStore = class {
|
||||
if ( staticNetFilteringEngine.hasQuery(fctxt) ) {
|
||||
staticNetFilteringEngine.filterQuery(fctxt, directives);
|
||||
}
|
||||
if ( this.urlSkippableResources.has(fctxt.itype) ) {
|
||||
staticNetFilteringEngine.urlSkip(fctxt, directives);
|
||||
}
|
||||
if ( directives.length === 0 ) { return; }
|
||||
if ( logger.enabled !== true ) { return; }
|
||||
fctxt.pushFilters(directives.map(a => a.logData()));
|
||||
@ -1132,23 +1135,31 @@ const PageStore = class {
|
||||
response.blockedResources =
|
||||
this.netFilteringCache.lookupAllBlocked(fctxt.getDocHostname());
|
||||
}
|
||||
|
||||
cacheableResults = new Set([
|
||||
µb.FilteringContext.SUB_FRAME
|
||||
]);
|
||||
|
||||
collapsibleResources = new Set([
|
||||
µb.FilteringContext.IMAGE,
|
||||
µb.FilteringContext.MEDIA,
|
||||
µb.FilteringContext.OBJECT,
|
||||
µb.FilteringContext.SUB_FRAME,
|
||||
]);
|
||||
|
||||
urlSkippableResources = new Set([
|
||||
µb.FilteringContext.IMAGE,
|
||||
µb.FilteringContext.MAIN_FRAME,
|
||||
µb.FilteringContext.MEDIA,
|
||||
µb.FilteringContext.OBJECT,
|
||||
µb.FilteringContext.SUB_FRAME,
|
||||
]);
|
||||
|
||||
// To mitigate memory churning
|
||||
static junkyard = [];
|
||||
static junkyardMax = 10;
|
||||
};
|
||||
|
||||
PageStore.prototype.cacheableResults = new Set([
|
||||
µb.FilteringContext.SUB_FRAME,
|
||||
]);
|
||||
|
||||
PageStore.prototype.collapsibleResources = new Set([
|
||||
µb.FilteringContext.IMAGE,
|
||||
µb.FilteringContext.MEDIA,
|
||||
µb.FilteringContext.OBJECT,
|
||||
µb.FilteringContext.SUB_FRAME,
|
||||
]);
|
||||
|
||||
// To mitigate memory churning
|
||||
PageStore.junkyard = [];
|
||||
PageStore.junkyardMax = 10;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
export { PageStore };
|
||||
|
@ -5449,9 +5449,9 @@ StaticNetFilteringEngine.prototype.urlSkip = function(fctxt, out = []) {
|
||||
return out;
|
||||
};
|
||||
|
||||
function urlSkip(directive, urlin, steps) {
|
||||
function urlSkip(directive, url, steps) {
|
||||
try {
|
||||
let urlout = urlin;
|
||||
let urlout = url;
|
||||
for ( const step of steps ) {
|
||||
const urlin = urlout;
|
||||
const c0 = step.charCodeAt(0);
|
||||
|
@ -196,8 +196,9 @@ const onBeforeRootFrameRequest = function(fctxt) {
|
||||
if ( trusted === false && pageStore !== null ) {
|
||||
if ( result !== 1 ) {
|
||||
pageStore.redirectNonBlockedRequest(fctxt);
|
||||
} else {
|
||||
pageStore.skipMainDocument(fctxt);
|
||||
}
|
||||
pageStore.skipMainDocument(fctxt);
|
||||
}
|
||||
|
||||
if ( logger.enabled ) {
|
||||
|
Loading…
Reference in New Issue
Block a user