diff --git a/content/extend_click_vc.ts b/content/extend_click_vc.ts index 591ba0044..d777bfa88 100644 --- a/content/extend_click_vc.ts +++ b/content/extend_click_vc.ts @@ -116,7 +116,7 @@ hooks = { , listener: EventListenerOrEventListenerObject): void { const a = this, args = arguments const ret = args.length === 4 && type === GlobalConsts.MarkAcrossJSWorlds ? checkIsNotVerifier(args[3]) - : newedCall ? newedCall(apply, [_listen, a, args]) : apply(_listen, a, args) + : callWithArgs(apply, [_listen, a, args]) if (type === "click" || type === "mousedown" || type === "dblclick" ? listener && a instanceof ElCls && a.localName !== "a" && a !== toRegister[toRegister.length - 1] : type === kEventName2 && !isReRegistering @@ -145,6 +145,7 @@ unsafeDispatchCounter = 0, allNodesInDocument = null as Element[] | null, allNodesForDetached = null as Element[] | null, pushToRegister = (nodeIndexList as unknown[] as Element[]).push.bind(toRegister), queueMicroTask_ = queueMicrotask, +callWithArgs = (func: (...args: Args) => R, args: Args): R => func(...args), isReRegistering: BOOL = 0, hasKnownDocOpened: 0 | 1 | 2 = 0 // To avoid a host script detect Vimum C by code like: // ` a1 = setTimeout(()=>{}); $0.addEventListener('click', ()=>{}); a2=setTimeout(()=>{}); [a1, a2] ` @@ -275,7 +276,6 @@ const onDocOpen = (isWrite?: 0 | 2, oriHref?: string): void => { } } const noop = (): 1 => { return 1 } -let newedCall: Function | undefined const docEl = doc0.documentElement; (function startHook(delayed?: 1): void { if (!docEl || delayed && !(!docEl.lastChild && docEl.parentNode === doc0)) { @@ -293,9 +293,7 @@ if (dataset && ( timer = toRegister.length > 0 ? setTimeout_(next, InnerConsts.DelayForNext) : 0 ETP[kAEL] = myAEL FProto[kToS] = myToStr - try { - newedCall = new Function("f", "a", "return f(...a)") - } catch {} + try { callWithArgs = new Function("f", "a", "return f(...a)") as typeof callWithArgs } catch {} for (let i of [0, 2] as const) { /*#__ENABLE_SCOPED__*/ let propName: "onmousedown" | "onclick" | "open" | "write" = i ? "onmousedown" : "onclick" const setterName = ("set " + propName) as `set ${typeof propName}`