mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-26 04:12:50 +01:00
[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 excludeMatches = [];
|
||||
let targetHostnames = [];
|
||||
if ( hasBroadHostPermission ) {
|
||||
excludeMatches.push(...permissionRevokedMatches);
|
||||
matches.push(...ut.matchesFromHostnames(scriptletHostnames));
|
||||
if ( scriptletHostnames.length > 100 ) {
|
||||
targetHostnames = [ '*' ];
|
||||
} else {
|
||||
targetHostnames = scriptletHostnames;
|
||||
}
|
||||
} else if ( permissionGrantedHostnames.length !== 0 ) {
|
||||
matches.push(
|
||||
...ut.matchesFromHostnames(
|
||||
ut.intersectHostnameIters(
|
||||
permissionGrantedHostnames,
|
||||
scriptletHostnames
|
||||
)
|
||||
)
|
||||
);
|
||||
if ( scriptletHostnames.includes('*') ) {
|
||||
targetHostnames = permissionGrantedHostnames;
|
||||
} else {
|
||||
targetHostnames = ut.intersectHostnameIters(
|
||||
permissionGrantedHostnames,
|
||||
scriptletHostnames
|
||||
);
|
||||
}
|
||||
}
|
||||
if ( matches.length === 0 ) { continue; }
|
||||
if ( targetHostnames.length === 0 ) { continue; }
|
||||
matches.push(...ut.matchesFromHostnames(targetHostnames));
|
||||
|
||||
before.delete(id); // Important!
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user