Skip to content
Merged
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.66.5b2 > ubo.js",
"build": "deno build.ts --tagName 1.67.0 > ubo.js",
"test": "node --test"
},
"author": {
Expand Down
31 changes: 8 additions & 23 deletions ubo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1542,35 +1542,17 @@ function hrefSanitizer(
}
return '';
};
const extractParam = (href, source) => {
if ( Boolean(source) === false ) { return href; }
const recursive = source.includes('?', 1);
const end = recursive ? source.indexOf('?', 1) : source.length;
try {
const url = new URL(href, document.location);
let value = url.searchParams.get(source.slice(1, end));
if ( value === null ) { return href }
if ( recursive ) { return extractParam(value, source.slice(end)); }
return value;
} catch {
}
return href;
};
const extractURL = (elem, source) => {
if ( /^\[.*\]$/.test(source) ) {
return elem.getAttribute(source.slice(1,-1).trim()) || '';
}
if ( source === 'text' ) {
return elem.textContent
.replace(/^[^\x21-\x7e]+/, '') // remove leading invalid characters
.replace(/[^\x21-\x7e]+$/, '') // remove trailing invalid characters
;
}
if ( source.startsWith('?') === false ) { return ''; }
const steps = source.replace(/(\S)\?/g, '\\1?').split(/\s+/);
const url = steps.length === 1
? extractParam(elem.href, source)
: urlSkip(elem.href, false, steps);
.replace(/^[^\x21-\x7e]+/, '') // remove leading invalid characters
.replace(/[^\x21-\x7e]+$/, ''); // remove trailing invalid characters
}
const steps = source.replace(/(\S)\?/g, '\\1 ?').split(/\s+/);
const url = urlSkip(elem.href, false, steps);
if ( url === undefined ) { return; }
return url.replace(/ /g, '%20');
};
Expand Down Expand Up @@ -32168,6 +32150,9 @@ function trustedClickElement(
if ( typeof steps[i-1] !== 'string' ) { continue; }
steps.splice(i, 0, clickDelay);
}
if ( steps.length === 1 && delay !== '' ) {
steps.unshift(clickDelay);
}
if ( typeof steps.at(-1) !== 'number' ) {
steps.push(10000);
}
Expand Down