diff --git a/package.json b/package.json index eb7459e..8b4bfd4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "type": "module", "scripts": { - "build": "deno build.ts --tagName 1.69.1b3 > ubo.js", + "build": "deno build.ts --tagName 1.69.1b4 > ubo.js", "test": "node --test" }, "author": { diff --git a/ubo.js b/ubo.js index 36a3721..aad926d 100644 --- a/ubo.js +++ b/ubo.js @@ -1195,15 +1195,12 @@ function trustedCreateHTML( const duration = parseInt(durationStr, 10); const domParser = new DOMParser(); const externalDoc = domParser.parseFromString(htmlStr, 'text/html'); - const docFragment = new DocumentFragment(); - const toRemove = []; + const toAppend = []; while ( externalDoc.body.firstChild !== null ) { - const imported = document.adoptNode(externalDoc.body.firstChild); - docFragment.appendChild(imported); - if ( isNaN(duration) ) { continue; } - toRemove.push(imported); + toAppend.push(document.adoptNode(externalDoc.body.firstChild)); } - if ( docFragment.firstChild === null ) { return; } + if ( toAppend.length === 0 ) { return; } + const toRemove = []; const remove = ( ) => { for ( const node of toRemove ) { if ( node.parentNode === null ) { continue; } @@ -1211,10 +1208,21 @@ function trustedCreateHTML( } safe.uboLog(logPrefix, 'Node(s) removed'); }; + const appendOne = (target, nodes) => { + for ( const node of nodes ) { + target.append(node); + if ( isNaN(duration) ) { continue; } + toRemove.push(node); + } + }; const append = ( ) => { - const parent = document.querySelector(parentSelector); - if ( parent === null ) { return false; } - parent.append(docFragment); + const targets = document.querySelectorAll(parentSelector); + if ( targets.length === 0 ) { return false; } + const limit = Math.min(targets.length, extraArgs.limit || 1) - 1; + for ( let i = 0; i < limit; i++ ) { + appendOne(targets[i], toAppend.map(a => a.cloneNode(true))); + } + appendOne(targets[limit], toAppend); safe.uboLog(logPrefix, 'Node(s) appended'); if ( toRemove.length === 0 ) { return true; } setTimeout(remove, duration); @@ -20722,6 +20730,7 @@ function preventFetchFn( const propNeedles = parsePropertiesToMatchFn(propsToMatch, 'url'); const validResponseProps = { ok: [ false, true ], + status: [ 403 ], statusText: [ '', 'Not Found' ], type: [ 'basic', 'cors', 'default', 'error', 'opaque' ], }; @@ -21237,6 +21246,7 @@ function preventFetchFn( const propNeedles = parsePropertiesToMatchFn(propsToMatch, 'url'); const validResponseProps = { ok: [ false, true ], + status: [ 403 ], statusText: [ '', 'Not Found' ], type: [ 'basic', 'cors', 'default', 'error', 'opaque' ], };