Skip to content

Commit

Permalink
MV3: extend_click: use "new Function" to avoid error reports on chrom…
Browse files Browse the repository at this point in the history
…e://extensions
  • Loading branch information
gdh1995 committed Feb 16, 2024
1 parent caeb84d commit 55e2bc4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion content/extend_click_vc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ hooks = {
, listener: EventListenerOrEventListenerObject): void {
const a = this, args = arguments
const ret = args.length === 4 && type === GlobalConsts.MarkAcrossJSWorlds ? checkIsNotVerifier(args[3])
: apply(_listen, a, args)
: newedCall ? newedCall(apply, [_listen, a, args]) : 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
Expand Down Expand Up @@ -275,6 +275,7 @@ 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)) {
Expand All @@ -292,6 +293,9 @@ 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 {}
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}`
Expand Down

0 comments on commit 55e2bc4

Please sign in to comment.