From 4c6c652fe235432e9928149fe46580de79f0bee1 Mon Sep 17 00:00:00 2001 From: David Reed Date: Sun, 20 Nov 2022 01:38:57 -0500 Subject: [PATCH] cleanup injection, pass important properties to iframe --- src/uv.handler.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/uv.handler.js b/src/uv.handler.js index 25c5cb4..ead3907 100644 --- a/src/uv.handler.js +++ b/src/uv.handler.js @@ -696,24 +696,27 @@ function __uvHook(window, config = {}, bare = '/bare/') { 'contentWindow' ).get; + function uvInject(that) { + const win = contentWindowGet.call(that); + + try { + win.__uv$bareData = __uv.bareData; + win.__uv$cookies = __uv.cookieStr; + if (!win.__uv) __uvHook(win, config, bare); + } catch (e) {} + } + client.element.hookProperty(HTMLIFrameElement, 'contentWindow', { get: (target, that) => { - const win = target.call(that); - try { - if (!win.__uv) __uvHook(win, config, bare); - } catch (e) {} - return win; + uvInject(that); + return target.call(that); }, }); client.element.hookProperty(HTMLIFrameElement, 'contentDocument', { get: (target, that) => { - const win = contentWindowGet.call(that); - const doc = target.call(that); - try { - if (!win.__uv) __uvHook(win, config, bare); - } catch (e) {} - return doc; + uvInject(that); + return target.call(that); }, });