Improve prevent-set[Timeout|Interval] scriptlets

This commit is contained in:
Raymond Hill 2025-03-17 08:02:30 -04:00
parent 0e8de98411
commit d36ea89a02
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
2 changed files with 7 additions and 6 deletions

View file

@ -95,8 +95,8 @@ export function preventSetTimeout(
proxyApplyFn('setTimeout', function(context) {
const { callArgs } = context;
const a = callArgs[0] instanceof Function
? String(safe.Function_toString(callArgs[0]))
: String(callArgs[0]);
? safe.String(safe.Function_toString(callArgs[0]))
: safe.String(callArgs[0]);
const b = callArgs[1];
if ( needleRaw === '' && range.unbound() ) {
safe.uboLog(logPrefix, `Called:\n${a}\n${b}`);
@ -159,8 +159,8 @@ export function preventSetInterval(
proxyApplyFn('setInterval', function(context) {
const { callArgs } = context;
const a = callArgs[0] instanceof Function
? String(safe.Function_toString(callArgs[0]))
: String(callArgs[0]);
? safe.String(safe.Function_toString(callArgs[0]))
: safe.String(callArgs[0]);
const b = callArgs[1];
if ( needleRaw === '' && range.unbound() ) {
safe.uboLog(logPrefix, `Called:\n${a}\n${b}`);
@ -212,8 +212,8 @@ export function preventRequestAnimationFrame(
proxyApplyFn('requestAnimationFrame', function(context) {
const { callArgs } = context;
const a = callArgs[0] instanceof Function
? String(safe.Function_toString(callArgs[0]))
: String(callArgs[0]);
? safe.String(safe.Function_toString(callArgs[0]))
: safe.String(callArgs[0]);
if ( needleRaw === '' ) {
safe.uboLog(logPrefix, `Called:\n${a}`);
} else if ( reNeedle.test(a) !== needleNot ) {

View file

@ -50,6 +50,7 @@ export function safeSelf() {
'RegExp_test': self.RegExp.prototype.test,
'RegExp_exec': self.RegExp.prototype.exec,
'Request_clone': self.Request.prototype.clone,
'String': self.String,
'String_fromCharCode': String.fromCharCode,
'String_split': String.prototype.split,
'XMLHttpRequest': self.XMLHttpRequest,