File size: 1,587 Bytes
2a9eaae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324acde
2a9eaae
324acde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2a9eaae
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Wrapper</title>
    <style>
        body,
        html {
            margin: 0;
            padding: 0;
            height: 100%;
            overflow: hidden;
        }

        .fullscreen-iframe {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        iframe {
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <div class="fullscreen-iframe">
        <iframe id="dynamic-iframe" frameborder="0" allowfullscreen crossorigin allow="cross-origin-isolated"></iframe>
    </div>

    <script>
		function onDOMContentLoaded() {
			document.removeEventListener("DOMContentLoaded", onDOMContentLoaded);
			
			var currentUrl = window.location.href;

            var regex = /https:\/\/([\w]+)-([\w-]+)\.static\.hf\.space/;
            var match = currentUrl.match(regex);

            if (match) {
                var repo = match[1];
                var space = match[2];
            	var targetUrl = "https://huggingface.cu.bzh/?script=huggingface.co/spaces/" + repo + "/" + space
            	console.log("targetUrl:", targetUrl)
            	document.getElementById("dynamic-iframe").src = targetUrl;
            } else {
                console.error("URL pattern does not match.");
            }
		}
		document.addEventListener("DOMContentLoaded", onDOMContentLoaded);

    </script>
</body>

</html>