-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
112 lines (104 loc) · 4.34 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>KahootFetcher</title>
<style>
body {
background-color: black;
color: white;
font-family: 'Roboto', sans-serif;
margin: 0;
padding: 0;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
}
iframe {
width: 80%;
height: 80%;
border: none;
}
.button {
padding: 20px 40px;
background-color: #ffd700;
color: black;
text-decoration: none;
font-size: 1.5rem;
font-weight: 700;
border-radius: 10px;
margin: 8px;
border: none;
cursor: pointer;
outline: none;
transition: background-color 0.3s, transform 0.2s;
}
.button:hover {
background-color: #555;
color: white;
transform: scale(1.05);
}
.button:active {
transform: scale(0.95);
}
</style>
</head>
<body>
<button class="button" id="startButton">Start</button>
<button class="button" onclick="window.open('https://kahootfetcher.oragne.dev/lite')">Lite Version</button>
<script>
document.getElementById('startButton').addEventListener('click', function() {
const uuid = prompt("Please enter the Kahoot UUID:");
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
if (uuidPattern.test(uuid)) {
const corsProxyURL = "https://cors-anywhere-oragne.vercel.app/api/cors?url=";
const kahootAPIURL = `https://kahoot.it/rest/kahoots/${uuid}`;
fetch(corsProxyURL + kahootAPIURL, {headers: {'X-Requested-With': 'XMLHttpRequest'}})
.then(response => response.json())
.then(data => {
const colorMap = {
2: ['Blue', 'Red'],
4: ['Red', 'Blue', 'Yellow', 'Green']
};
const questions = data.questions || [];
questions.forEach((question, i) => {
if (!question.choices) {
if (question.type === 'content') {
alert((i + 1) + ': This is a slide');
} else {
alert((i + 1) + ': No answers found');
}
} else {
const numChoices = question.choices.length;
const correctIndex = question.choices.findIndex(choice => choice.correct);
const correctChoice = question.choices[correctIndex];
const answerText = correctChoice ? correctChoice.answer : undefined;
const color = colorMap[numChoices][correctIndex];
const answerDisplay = answerText ? ' (' + answerText + ')' : '';
if (question.type === 'jumble') {
const jumbleAnswer = question.choices.map(choice => choice.answer).join(', ');
alert((i + 1) + ': ' + jumbleAnswer);
} else if (question.type === 'survey') {
alert((i + 1) + ': This question is a poll');
} else if (question.type === 'open_ended') {
const openEndedAnswers = question.choices.map(choice => choice.answer).join(' OR ');
alert((i + 1) + ': ' + openEndedAnswers);
} else {
alert((i + 1) + ': ' + '[' + (correctIndex + 1) + '] ' + color + answerDisplay);
}
}
});
})
.catch(error => {
console.error('Error fetching Kahoot data: ', error);
});
} else {
alert("Invalid UUID provided. Please ensure the UUID is in the correct format.");
}
});
</script>
</body>
</html>