mirror of https://github.com/gorhill/uBlock.git
[mv3] Let the scriplet sort out targeted sites when too many targets
This is too avoid `matches` property with too many hostnames at registerContentScripts() time. Threshold has been arbitrarily set at 100.
This commit is contained in:
parent
d300f2119a
commit
7e712246a9
|
@ -369,20 +369,26 @@ function registerScriptlet(context, scriptletDetails) {
|
||||||
|
|
||||||
const matches = [];
|
const matches = [];
|
||||||
const excludeMatches = [];
|
const excludeMatches = [];
|
||||||
|
let targetHostnames = [];
|
||||||
if ( hasBroadHostPermission ) {
|
if ( hasBroadHostPermission ) {
|
||||||
excludeMatches.push(...permissionRevokedMatches);
|
excludeMatches.push(...permissionRevokedMatches);
|
||||||
matches.push(...ut.matchesFromHostnames(scriptletHostnames));
|
if ( scriptletHostnames.length > 100 ) {
|
||||||
|
targetHostnames = [ '*' ];
|
||||||
|
} else {
|
||||||
|
targetHostnames = scriptletHostnames;
|
||||||
|
}
|
||||||
} else if ( permissionGrantedHostnames.length !== 0 ) {
|
} else if ( permissionGrantedHostnames.length !== 0 ) {
|
||||||
matches.push(
|
if ( scriptletHostnames.includes('*') ) {
|
||||||
...ut.matchesFromHostnames(
|
targetHostnames = permissionGrantedHostnames;
|
||||||
ut.intersectHostnameIters(
|
} else {
|
||||||
permissionGrantedHostnames,
|
targetHostnames = ut.intersectHostnameIters(
|
||||||
scriptletHostnames
|
permissionGrantedHostnames,
|
||||||
)
|
scriptletHostnames
|
||||||
)
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
if ( matches.length === 0 ) { continue; }
|
if ( targetHostnames.length === 0 ) { continue; }
|
||||||
|
matches.push(...ut.matchesFromHostnames(targetHostnames));
|
||||||
|
|
||||||
before.delete(id); // Important!
|
before.delete(id); // Important!
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue