Spaces:
Running
Running
Update goo
Browse files
goo
CHANGED
@@ -3,11 +3,9 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>HTML Viewer</title>
|
7 |
<style>
|
8 |
-
.hidden {
|
9 |
-
display: none;
|
10 |
-
}
|
11 |
</style>
|
12 |
</head>
|
13 |
<body>
|
@@ -17,7 +15,7 @@
|
|
17 |
<select id="modeSelect">
|
18 |
<option value="html">HTML่กจ็คบใขใผใ</option>
|
19 |
<option value="url">URLใฎiframe่กจ็คบใขใผใ</option>
|
20 |
-
<option value="pip">PiP
|
21 |
</select>
|
22 |
<br>
|
23 |
|
@@ -25,12 +23,11 @@
|
|
25 |
<select id="displayTarget">
|
26 |
<option value="blob">blobURL</option>
|
27 |
<option value="blank">about:blank</option>
|
|
|
28 |
</select>
|
29 |
|
30 |
<div id="htmlMode">
|
31 |
-
<textarea id="htmlInput" placeholder="ใใใซHTMLใๅ
ฅๅใใฆใใ ใใ" rows="10" cols="50">
|
32 |
-
<!DOCTYPE html><html lang="ja"><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title> </title><style>html,body{margin:0;padding:0;overflow:hidden;width:100vw;height:100vh}</style><iframe src="https://gooberdash.winterpixel.io/" style="width:100vw;height:100vh;border:none;display:block;margin:0;padding:0"></iframe>
|
33 |
-
</textarea><br>
|
34 |
</div>
|
35 |
|
36 |
<div id="urlMode" class="hidden">
|
@@ -43,10 +40,6 @@
|
|
43 |
</datalist>
|
44 |
</div>
|
45 |
|
46 |
-
<div id="pipMode" class="hidden">
|
47 |
-
<input id="videoUrlInput" type="text" placeholder="ๅ็ปURL๏ผMP4ใชใฉ๏ผใๅ
ฅๅใใฆใใ ใใ" size="50">
|
48 |
-
</div>
|
49 |
-
|
50 |
<button id="displayButton">่กจ็คบ</button>
|
51 |
<button onclick="location.replace('index.html');">close</button>
|
52 |
<button id="clearButton">ใฏใชใข</button>
|
@@ -57,22 +50,21 @@
|
|
57 |
const displayTarget = document.getElementById('displayTarget');
|
58 |
const htmlMode = document.getElementById('htmlMode');
|
59 |
const urlMode = document.getElementById('urlMode');
|
60 |
-
const pipMode = document.getElementById('pipMode');
|
61 |
const displayButton = document.getElementById('displayButton');
|
62 |
const clearButton = document.getElementById('clearButton');
|
63 |
const errorMessage = document.getElementById('errorMessage');
|
64 |
|
|
|
65 |
modeSelect.addEventListener('change', () => {
|
66 |
-
htmlMode.classList.add('hidden');
|
67 |
-
urlMode.classList.add('hidden');
|
68 |
-
pipMode.classList.add('hidden');
|
69 |
-
|
70 |
if (modeSelect.value === 'html') {
|
71 |
htmlMode.classList.remove('hidden');
|
|
|
72 |
} else if (modeSelect.value === 'url') {
|
|
|
73 |
urlMode.classList.remove('hidden');
|
74 |
-
} else
|
75 |
-
|
|
|
76 |
}
|
77 |
});
|
78 |
|
@@ -80,55 +72,93 @@
|
|
80 |
errorMessage.textContent = '';
|
81 |
const target = displayTarget.value;
|
82 |
|
83 |
-
if (modeSelect.value === 'html') {
|
84 |
const htmlContent = document.getElementById('htmlInput').value;
|
|
|
85 |
if (!htmlContent.trim()) {
|
86 |
errorMessage.textContent = 'HTMLใๅ
ฅๅใใฆใใ ใใใ';
|
87 |
return;
|
88 |
}
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
const
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
const
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
|
|
|
|
106 |
}
|
107 |
-
} catch (e) {
|
108 |
-
errorMessage.textContent = 'ใจใฉใผใ็บ็ใใพใใ: ' + e.message;
|
109 |
}
|
|
|
110 |
} else if (modeSelect.value === 'url') {
|
111 |
const url = document.getElementById('urlInput').value;
|
|
|
112 |
if (!url.trim()) {
|
113 |
errorMessage.textContent = 'URLใๅ
ฅๅใใฆใใ ใใใ';
|
114 |
return;
|
115 |
}
|
116 |
|
117 |
-
const iframeHtml =
|
118 |
-
<!DOCTYPE html><html lang="ja"><meta charset="UTF-8">
|
119 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
120 |
-
<title></title>
|
121 |
-
<style>html,body{margin:0;padding:0;overflow:hidden;width:100vw;height:100vh}</style>
|
122 |
-
<iframe src="${url}" style="width:100vw;height:100vh;border:none;"></iframe>
|
123 |
-
</html>`;
|
124 |
-
|
125 |
try {
|
126 |
if (target === 'blob') {
|
127 |
const blob = new Blob([iframeHtml], { type: 'text/html' });
|
128 |
const blobUrl = URL.createObjectURL(blob);
|
129 |
const newWindow = window.open(blobUrl);
|
130 |
if (!newWindow) {
|
131 |
-
errorMessage.textContent = '
|
132 |
}
|
133 |
} else if (target === 'blank') {
|
134 |
const newWindow = window.open('about:blank');
|
@@ -136,54 +166,22 @@
|
|
136 |
newWindow.document.write(iframeHtml);
|
137 |
newWindow.document.close();
|
138 |
} else {
|
139 |
-
errorMessage.textContent = '
|
140 |
}
|
|
|
|
|
141 |
}
|
142 |
} catch (e) {
|
143 |
errorMessage.textContent = 'ใจใฉใผใ็บ็ใใพใใ: ' + e.message;
|
144 |
}
|
145 |
-
} else if (modeSelect.value === 'pip') {
|
146 |
-
const videoUrl = document.getElementById('videoUrlInput').value;
|
147 |
-
if (!videoUrl.trim()) {
|
148 |
-
errorMessage.textContent = 'ๅ็ปURLใๅ
ฅๅใใฆใใ ใใใ';
|
149 |
-
return;
|
150 |
-
}
|
151 |
-
|
152 |
-
try {
|
153 |
-
const pipHtml = `
|
154 |
-
<!DOCTYPE html><html lang="ja"><meta charset="UTF-8">
|
155 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
156 |
-
<title>PiP</title>
|
157 |
-
<body>
|
158 |
-
<video id="video" src="${videoUrl}" autoplay controls style="max-width: 100%; height: auto;"></video>
|
159 |
-
<script>
|
160 |
-
const video = document.getElementById('video');
|
161 |
-
video.addEventListener('loadedmetadata', () => {
|
162 |
-
video.requestPictureInPicture().catch(err => alert("PiPใจใฉใผ: " + err.message));
|
163 |
-
});
|
164 |
-
<\/script>
|
165 |
-
</body>
|
166 |
-
</html>`;
|
167 |
-
|
168 |
-
const blob = new Blob([pipHtml], { type: 'text/html' });
|
169 |
-
const blobUrl = URL.createObjectURL(blob);
|
170 |
-
const newWindow = window.open(blobUrl);
|
171 |
-
if (!newWindow) {
|
172 |
-
errorMessage.textContent = 'PiPใฆใฃใณใใฆใ้ใใพใใใงใใใ';
|
173 |
-
}
|
174 |
-
} catch (e) {
|
175 |
-
errorMessage.textContent = 'PiPใจใฉใผ: ' + e.message;
|
176 |
-
}
|
177 |
}
|
178 |
});
|
179 |
|
180 |
clearButton.addEventListener('click', () => {
|
181 |
-
if (modeSelect.value === 'html') {
|
182 |
document.getElementById('htmlInput').value = '';
|
183 |
} else if (modeSelect.value === 'url') {
|
184 |
document.getElementById('urlInput').value = '';
|
185 |
-
} else if (modeSelect.value === 'pip') {
|
186 |
-
document.getElementById('videoUrlInput').value = '';
|
187 |
}
|
188 |
errorMessage.textContent = '';
|
189 |
});
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>HTML Viewer with PiP</title>
|
7 |
<style>
|
8 |
+
.hidden { display: none; }
|
|
|
|
|
9 |
</style>
|
10 |
</head>
|
11 |
<body>
|
|
|
15 |
<select id="modeSelect">
|
16 |
<option value="html">HTML่กจ็คบใขใผใ</option>
|
17 |
<option value="url">URLใฎiframe่กจ็คบใขใผใ</option>
|
18 |
+
<option value="pip">PiPใฆใฃใณใใฆ่กจ็คบใขใผใ</option>
|
19 |
</select>
|
20 |
<br>
|
21 |
|
|
|
23 |
<select id="displayTarget">
|
24 |
<option value="blob">blobURL</option>
|
25 |
<option value="blank">about:blank</option>
|
26 |
+
<option value="pip">PiPใฆใฃใณใใฆ</option>
|
27 |
</select>
|
28 |
|
29 |
<div id="htmlMode">
|
30 |
+
<textarea id="htmlInput" placeholder="ใใใซHTMLใๅ
ฅๅใใฆใใ ใใ" rows="10" cols="50"><div style='font-size: 2rem; background: yellow; height: 100%; display: flex; align-items: center; justify-content: center;'>ใใใฏPiPใฆใฃใณใใฆ่กจ็คบ็จใฎHTMLใงใ</div></textarea><br>
|
|
|
|
|
31 |
</div>
|
32 |
|
33 |
<div id="urlMode" class="hidden">
|
|
|
40 |
</datalist>
|
41 |
</div>
|
42 |
|
|
|
|
|
|
|
|
|
43 |
<button id="displayButton">่กจ็คบ</button>
|
44 |
<button onclick="location.replace('index.html');">close</button>
|
45 |
<button id="clearButton">ใฏใชใข</button>
|
|
|
50 |
const displayTarget = document.getElementById('displayTarget');
|
51 |
const htmlMode = document.getElementById('htmlMode');
|
52 |
const urlMode = document.getElementById('urlMode');
|
|
|
53 |
const displayButton = document.getElementById('displayButton');
|
54 |
const clearButton = document.getElementById('clearButton');
|
55 |
const errorMessage = document.getElementById('errorMessage');
|
56 |
|
57 |
+
// ใขใผใๅใๆฟใ
|
58 |
modeSelect.addEventListener('change', () => {
|
|
|
|
|
|
|
|
|
59 |
if (modeSelect.value === 'html') {
|
60 |
htmlMode.classList.remove('hidden');
|
61 |
+
urlMode.classList.add('hidden');
|
62 |
} else if (modeSelect.value === 'url') {
|
63 |
+
htmlMode.classList.add('hidden');
|
64 |
urlMode.classList.remove('hidden');
|
65 |
+
} else {
|
66 |
+
htmlMode.classList.remove('hidden');
|
67 |
+
urlMode.classList.add('hidden');
|
68 |
}
|
69 |
});
|
70 |
|
|
|
72 |
errorMessage.textContent = '';
|
73 |
const target = displayTarget.value;
|
74 |
|
75 |
+
if (modeSelect.value === 'html' || modeSelect.value === 'pip') {
|
76 |
const htmlContent = document.getElementById('htmlInput').value;
|
77 |
+
|
78 |
if (!htmlContent.trim()) {
|
79 |
errorMessage.textContent = 'HTMLใๅ
ฅๅใใฆใใ ใใใ';
|
80 |
return;
|
81 |
}
|
82 |
|
83 |
+
if (target === 'pip') {
|
84 |
+
try {
|
85 |
+
const video = document.createElement('video');
|
86 |
+
video.setAttribute('autoplay', '');
|
87 |
+
video.setAttribute('muted', '');
|
88 |
+
video.setAttribute('playsinline', '');
|
89 |
+
video.style.display = 'none';
|
90 |
+
|
91 |
+
const canvas = document.createElement('canvas');
|
92 |
+
const ctx = canvas.getContext('2d');
|
93 |
+
canvas.width = 640;
|
94 |
+
canvas.height = 360;
|
95 |
+
|
96 |
+
const htmlContainer = document.createElement('div');
|
97 |
+
htmlContainer.style.width = '640px';
|
98 |
+
htmlContainer.style.height = '360px';
|
99 |
+
htmlContainer.innerHTML = htmlContent;
|
100 |
+
|
101 |
+
document.body.appendChild(video); // ๅฟ
้ : ๅ็ปใDOMใซใชใใจPiPใฏ่จฑๅฏใใใชใ
|
102 |
+
document.body.appendChild(htmlContainer);
|
103 |
+
htmlContainer.style.position = 'absolute';
|
104 |
+
htmlContainer.style.left = '-9999px'; // ็ป้ขใซ่กจ็คบใใใชใ
|
105 |
+
|
106 |
+
const stream = canvas.captureStream();
|
107 |
+
video.srcObject = stream;
|
108 |
+
|
109 |
+
video.play();
|
110 |
+
|
111 |
+
// ๆ็ปใซใผใ
|
112 |
+
const draw = () => {
|
113 |
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
114 |
+
ctx.drawImage(htmlContainer, 0, 0, canvas.width, canvas.height);
|
115 |
+
requestAnimationFrame(draw);
|
116 |
+
};
|
117 |
+
draw();
|
118 |
+
|
119 |
+
await video.requestPictureInPicture();
|
120 |
+
} catch (e) {
|
121 |
+
errorMessage.textContent = 'PiP่กจ็คบใซๅคฑๆใใพใใ: ' + e.message;
|
122 |
+
}
|
123 |
+
} else {
|
124 |
+
try {
|
125 |
+
if (target === 'blob') {
|
126 |
+
const blob = new Blob([htmlContent], { type: 'text/html' });
|
127 |
+
const url = URL.createObjectURL(blob);
|
128 |
+
const newWindow = window.open(url);
|
129 |
+
if (!newWindow) {
|
130 |
+
errorMessage.textContent = 'ๆฐใใใฟใใ้ใใพใใใงใใใใใใใขใใใใใญใใฏใใใฆใใๅฏ่ฝๆงใใใใพใใ';
|
131 |
+
}
|
132 |
+
} else if (target === 'blank') {
|
133 |
+
const newWindow = window.open('about:blank');
|
134 |
+
if (newWindow) {
|
135 |
+
newWindow.document.write(htmlContent);
|
136 |
+
newWindow.document.close();
|
137 |
+
} else {
|
138 |
+
errorMessage.textContent = 'ๆฐใใใฟใใ้ใใพใใใงใใใใใใใขใใใใใญใใฏใใใฆใใๅฏ่ฝๆงใใใใพใใ';
|
139 |
+
}
|
140 |
}
|
141 |
+
} catch (e) {
|
142 |
+
errorMessage.textContent = 'ใจใฉใผใ็บ็ใใพใใ: ' + e.message;
|
143 |
}
|
|
|
|
|
144 |
}
|
145 |
+
|
146 |
} else if (modeSelect.value === 'url') {
|
147 |
const url = document.getElementById('urlInput').value;
|
148 |
+
|
149 |
if (!url.trim()) {
|
150 |
errorMessage.textContent = 'URLใๅ
ฅๅใใฆใใ ใใใ';
|
151 |
return;
|
152 |
}
|
153 |
|
154 |
+
const iframeHtml = `<!DOCTYPE html><html lang="ja"><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title> </title><style>html,body{margin:0;padding:0;overflow:hidden;width:100vw;height:100vh}</style><iframe src="${url}" style="width:100vw;height:100vh;border:none;display:block;margin:0;padding:0"></iframe></html>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
try {
|
156 |
if (target === 'blob') {
|
157 |
const blob = new Blob([iframeHtml], { type: 'text/html' });
|
158 |
const blobUrl = URL.createObjectURL(blob);
|
159 |
const newWindow = window.open(blobUrl);
|
160 |
if (!newWindow) {
|
161 |
+
errorMessage.textContent = 'ๆฐใใใฟใใ้ใใพใใใงใใใใใใใขใใใใใญใใฏใใใฆใใๅฏ่ฝๆงใใใใพใใ';
|
162 |
}
|
163 |
} else if (target === 'blank') {
|
164 |
const newWindow = window.open('about:blank');
|
|
|
166 |
newWindow.document.write(iframeHtml);
|
167 |
newWindow.document.close();
|
168 |
} else {
|
169 |
+
errorMessage.textContent = 'ๆฐใใใฟใใ้ใใพใใใงใใใใใใใขใใใใใญใใฏใใใฆใใๅฏ่ฝๆงใใใใพใใ';
|
170 |
}
|
171 |
+
} else if (target === 'pip') {
|
172 |
+
errorMessage.textContent = 'URLใขใผใใงใฏPiP่กจ็คบใฏใตใใผใใใใฆใใพใใใ';
|
173 |
}
|
174 |
} catch (e) {
|
175 |
errorMessage.textContent = 'ใจใฉใผใ็บ็ใใพใใ: ' + e.message;
|
176 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
}
|
178 |
});
|
179 |
|
180 |
clearButton.addEventListener('click', () => {
|
181 |
+
if (modeSelect.value === 'html' || modeSelect.value === 'pip') {
|
182 |
document.getElementById('htmlInput').value = '';
|
183 |
} else if (modeSelect.value === 'url') {
|
184 |
document.getElementById('urlInput').value = '';
|
|
|
|
|
185 |
}
|
186 |
errorMessage.textContent = '';
|
187 |
});
|