-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
51 lines (51 loc) · 1.78 KB
/
index.html
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
<!DOCTYPE html>
<html style="background-color: Azure;">
<head>
<title>WBIB Viewer</title>
<link rel="icon" type="image/jpg" href="/WBIB/favicon.ico">
<link rel="stylesheet" href="main.css">
</head>
<body>
<input class="site" type="text" id="siteinput" name="siteinput" placeholder="Site">
<iframe id="embedsite"></iframe>
<script>
function loadText(text) {
var html_string = text;
document.getElementById('embedsite').srcdoc = html_string;
};
/* function loadFavicon() {
var favicon = document.querySelector('[rel=icon]');
var step1 = document.getElementById('siteinput').value;
var step2 = step1.split('.');
var step2 = step2[step2.length - 1];
var step2 = step2.split('/');
var step3 = step2[0];
var step3 = step1.split(step3);
var step3 = step3[0] + step2[0] + '/favicon.ico';
var step4 = "https://t0.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=" + step3 + "&size=16"́;
favicon.href = step4;
};
function fullLoad(text) {
loadText(text);
loadFavicon();
}; */
function myFunction() {
loadText('<br><br><p>Loading...</p>');
var site = document.getElementById('siteinput').value;
fetch(`https://api.allorigins.win/get?url=${encodeURIComponent(site)}`)
.then(response => {
if (response.ok) return response.json()
document.getElementById("embedsite").innerHTML = 'Uh-oh, the website has run into an error. (Error code: Proxy&RES-NOT-OK)';
throw new Error('Network response was not ok.')
})
.then(data => loadText(data.contents));
};
var siteinput = document.getElementById("siteinput");
siteinput.addEventListener("keydown", function (e) {
if (e.code === "Enter") {
myFunction();
}
});
</script>
</body>
</html>