-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
25 lines (25 loc) · 875 Bytes
/
index.html
File metadata and controls
25 lines (25 loc) · 875 Bytes
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
<script>
function getImage(){
console.log("begin");
var xhr = new XMLHttpRequest();
xhr.addEventListener('readystatechange',function(){
if(this.readyState === 4) {
if(this.status !== 200){
window.location = "/";
}
let retxt = this.responseText;
let reJson = eval('(' + retxt + ')');;
let num = Math.floor(Math.random() * reJson.length);
window.location="https://cdn.jsdelivr.net/gh/drew233/imgapi/image/" + reJson[num].path;
}
})
xhr.open('get','https://api.github.com/repos/Drew233/imgapi/contents/image/');
xhr.setRequestHeader('content-Type',"text/json");
xhr.send();
//
}
getImage();
</script>
<head>
<title>Random picture | Artitalk</title>
</head>