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.70.1rc0 > ubo.js",
"build": "deno build.ts --tagName 1.71.0 > ubo.js",
"test": "node --test"
},
"author": {
Expand Down
111 changes: 111 additions & 0 deletions ubo.js
Original file line number Diff line number Diff line change
Expand Up @@ -33225,6 +33225,117 @@ multiup(...args);
};


scriptlets['break-on-call.js'] = {
aliases: [],

requiresTrust: false,
func: function (scriptletGlobals = {}, ...args) {
function proxyApplyFn(
target = '',
handler = ''
) {
let context = globalThis;
let prop = target;
for (;;) {
const pos = prop.indexOf('.');
if ( pos === -1 ) { break; }
context = context[prop.slice(0, pos)];
if ( context instanceof Object === false ) { return; }
prop = prop.slice(pos+1);
}
const fn = context[prop];
if ( typeof fn !== 'function' ) { return; }
if ( proxyApplyFn.CtorContext === undefined ) {
proxyApplyFn.ctorContexts = [];
proxyApplyFn.CtorContext = class {
constructor(...args) {
this.init(...args);
}
init(callFn, callArgs) {
this.callFn = callFn;
this.callArgs = callArgs;
return this;
}
reflect() {
const r = Reflect.construct(this.callFn, this.callArgs);
this.callFn = this.callArgs = this.private = undefined;
proxyApplyFn.ctorContexts.push(this);
return r;
}
static factory(...args) {
return proxyApplyFn.ctorContexts.length !== 0
? proxyApplyFn.ctorContexts.pop().init(...args)
: new proxyApplyFn.CtorContext(...args);
}
};
proxyApplyFn.applyContexts = [];
proxyApplyFn.ApplyContext = class {
constructor(...args) {
this.init(...args);
}
init(callFn, thisArg, callArgs) {
this.callFn = callFn;
this.thisArg = thisArg;
this.callArgs = callArgs;
return this;
}
reflect() {
const r = Reflect.apply(this.callFn, this.thisArg, this.callArgs);
this.callFn = this.thisArg = this.callArgs = this.private = undefined;
proxyApplyFn.applyContexts.push(this);
return r;
}
static factory(...args) {
return proxyApplyFn.applyContexts.length !== 0
? proxyApplyFn.applyContexts.pop().init(...args)
: new proxyApplyFn.ApplyContext(...args);
}
};
proxyApplyFn.isCtor = new Map();
proxyApplyFn.proxies = new WeakMap();
proxyApplyFn.nativeToString = Function.prototype.toString;
const proxiedToString = new Proxy(Function.prototype.toString, {
apply(target, thisArg) {
let proxied = thisArg;
for(;;) {
const fn = proxyApplyFn.proxies.get(proxied);
if ( fn === undefined ) { break; }
proxied = fn;
}
return proxyApplyFn.nativeToString.call(proxied);
}
});
proxyApplyFn.proxies.set(proxiedToString, proxyApplyFn.nativeToString);
Function.prototype.toString = proxiedToString;
}
if ( proxyApplyFn.isCtor.has(target) === false ) {
proxyApplyFn.isCtor.set(target, fn.prototype?.constructor === fn);
}
const proxyDetails = {
apply(target, thisArg, args) {
return handler(proxyApplyFn.ApplyContext.factory(target, thisArg, args));
}
};
if ( proxyApplyFn.isCtor.get(target) ) {
proxyDetails.construct = function(target, args) {
return handler(proxyApplyFn.CtorContext.factory(target, args));
};
}
const proxiedTarget = new Proxy(fn, proxyDetails);
proxyApplyFn.proxies.set(proxiedTarget, fn);
context[prop] = proxiedTarget;
}
function breakOnCall(target) {
proxyApplyFn(target, function fetch(context) {
debugger; // eslint-disable-line no-debugger
return context.reflect();
});
};
breakOnCall(...args);
},
};


scriptlets['trusted-replace-node-text.js'] = {
aliases: ["trusted-rpnt.js","replace-node-text.js","rpnt.js"],
world: 'ISOLATED',
Expand Down
Loading