From 2eb5f103ab1b41477440cc391165ea7ef5f7f959 Mon Sep 17 00:00:00 2001
From: apolinario <joaopaulo.passos@gmail.com>
Date: Mon, 5 Dec 2022 16:30:15 +0100
Subject: [PATCH 1/4] Fix WebUI not working inside of iframes

---
 script.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/script.js b/script.js
index 8b3b67e3e..d9424de99 100644
--- a/script.js
+++ b/script.js
@@ -1,5 +1,5 @@
 function gradioApp(){
-    return document.getElementsByTagName('gradio-app')[0].shadowRoot;
+    return document
 }
 
 function get_uiCurrentTab() {
@@ -82,4 +82,4 @@ function uiElementIsVisible(el) {
         }
     }
     return isVisible;
-}
\ No newline at end of file
+}

From 1075819b16ef328805dd946acaffd43efa2eb444 Mon Sep 17 00:00:00 2001
From: apolinario <joaopaulo.passos@gmail.com>
Date: Tue, 6 Dec 2022 15:13:41 +0100
Subject: [PATCH 2/4] Use shadowRoot if inside of an iframe and don't use it if
 outside

This makes sure it will work everywhere
---
 script.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/script.js b/script.js
index d9424de99..49b6c5576 100644
--- a/script.js
+++ b/script.js
@@ -1,5 +1,5 @@
 function gradioApp(){
-    return document
+    return !!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document
 }
 
 function get_uiCurrentTab() {

From 8eb638cdd3d08ad6e9373569fd81d0a6e8a63f16 Mon Sep 17 00:00:00 2001
From: apolinario <joaopaulo.passos@gmail.com>
Date: Tue, 6 Dec 2022 15:14:22 +0100
Subject: [PATCH 3/4] style change

---
 script.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/script.js b/script.js
index 49b6c5576..1c8fcbf1f 100644
--- a/script.js
+++ b/script.js
@@ -1,5 +1,5 @@
 function gradioApp(){
-    return !!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document
+    return !!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document;
 }
 
 function get_uiCurrentTab() {

From 37139d8aac10bd13758f52e3d361f3d017c4ad46 Mon Sep 17 00:00:00 2001
From: apolinario <joaopaulo.passos+multimodal@gmail.com>
Date: Sat, 10 Dec 2022 12:51:40 +0100
Subject: [PATCH 4/4] No code repeat

---
 script.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/script.js b/script.js
index 1c8fcbf1f..9748ec90e 100644
--- a/script.js
+++ b/script.js
@@ -1,5 +1,6 @@
-function gradioApp(){
-    return !!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document;
+function gradioApp() {
+    const gradioShadowRoot = document.getElementsByTagName('gradio-app')[0].shadowRoot
+    return !!gradioShadowRoot ? gradioShadowRoot : document;
 }
 
 function get_uiCurrentTab() {