⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
30 changes: 20 additions & 10 deletions ubo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1195,26 +1195,34 @@ 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; }
node.parentNode.removeChild(node);
}
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);
Expand Down Expand Up @@ -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' ],
};
Expand Down Expand Up @@ -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' ],
};
Expand Down