@@ -1195,26 +1195,34 @@ function trustedCreateHTML(
11951195 const duration = parseInt(durationStr, 10);
11961196 const domParser = new DOMParser();
11971197 const externalDoc = domParser.parseFromString(htmlStr, 'text/html');
1198- const docFragment = new DocumentFragment();
1199- const toRemove = [];
1198+ const toAppend = [];
12001199 while ( externalDoc.body.firstChild !== null ) {
1201- const imported = document.adoptNode(externalDoc.body.firstChild);
1202- docFragment.appendChild(imported);
1203- if ( isNaN(duration) ) { continue; }
1204- toRemove.push(imported);
1200+ toAppend.push(document.adoptNode(externalDoc.body.firstChild));
12051201 }
1206- if ( docFragment.firstChild === null ) { return; }
1202+ if ( toAppend.length === 0 ) { return; }
1203+ const toRemove = [];
12071204 const remove = ( ) => {
12081205 for ( const node of toRemove ) {
12091206 if ( node.parentNode === null ) { continue; }
12101207 node.parentNode.removeChild(node);
12111208 }
12121209 safe.uboLog(logPrefix, 'Node(s) removed');
12131210 };
1211+ const appendOne = (target, nodes) => {
1212+ for ( const node of nodes ) {
1213+ target.append(node);
1214+ if ( isNaN(duration) ) { continue; }
1215+ toRemove.push(node);
1216+ }
1217+ };
12141218 const append = ( ) => {
1215- const parent = document.querySelector(parentSelector);
1216- if ( parent === null ) { return false; }
1217- parent.append(docFragment);
1219+ const targets = document.querySelectorAll(parentSelector);
1220+ if ( targets.length === 0 ) { return false; }
1221+ const limit = Math.min(targets.length, extraArgs.limit || 1) - 1;
1222+ for ( let i = 0; i < limit; i++ ) {
1223+ appendOne(targets[i], toAppend.map(a => a.cloneNode(true)));
1224+ }
1225+ appendOne(targets[limit], toAppend);
12181226 safe.uboLog(logPrefix, 'Node(s) appended');
12191227 if ( toRemove.length === 0 ) { return true; }
12201228 setTimeout(remove, duration);
@@ -20722,6 +20730,7 @@ function preventFetchFn(
2072220730 const propNeedles = parsePropertiesToMatchFn(propsToMatch, 'url');
2072320731 const validResponseProps = {
2072420732 ok: [ false, true ],
20733+ status: [ 403 ],
2072520734 statusText: [ '', 'Not Found' ],
2072620735 type: [ 'basic', 'cors', 'default', 'error', 'opaque' ],
2072720736 };
@@ -21237,6 +21246,7 @@ function preventFetchFn(
2123721246 const propNeedles = parsePropertiesToMatchFn(propsToMatch, 'url');
2123821247 const validResponseProps = {
2123921248 ok: [ false, true ],
21249+ status: [ 403 ],
2124021250 statusText: [ '', 'Not Found' ],
2124121251 type: [ 'basic', 'cors', 'default', 'error', 'opaque' ],
2124221252 };
0 commit comments