<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Admin Panel</title> <link rel="stylesheet" href="/static/css/styles.css"> </head> <body> <h1>Admin Panel</h1> <p>Note: this admin panel will only work for moderators and streamers</p> <button id="startPoll">Start Bet</button> <button id="endPoll">End Bet</button> <button id="startStream">Start Stream</button> <button id="endStream">End Stream</button> <script> let possible = []; document.getElementById('startPoll').addEventListener('click', async () => { let question = prompt("What is the question of the bet?") possible = prompt("What outcomes can the poll have (comma seperated)?").split(", ") let time = prompt("How long should the poll last (in seconds)?") let response = await fetch("/api/startBet", { method: "POST", body: JSON.stringify({ "question": question, "possible": possible, "timeToBet": parseInt(time) }) }) if (response.ok) { alert("Poll started!") } else { alert("Error starting poll") } }) document.getElementById('endPoll').addEventListener('click', async () => { let response = await fetch("/api/endBet", { method: "POST", body: JSON.stringify({ "correct": possible.indexOf(prompt("What was the correct answer?")) }) }) if (response.ok) { alert("Poll ended!") } else { alert("Error ending poll") } }) document.getElementById('startStream').addEventListener('click', async () => { // First, fetch the broadcasts from YouTube let response = await fetch("https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet&mine=true", { headers: { "Authorization": "Bearer " + localStorage.getItem("oauthToken") } }) let data = await response.json() let liveChatID = data.items[0]["snippet"]["liveChatId"] // Now that we have the live chat ID, we can start the stream let response2 = await fetch("/api/startStream", { method: "POST", body: JSON.stringify({ "liveChatID": prompt("What is the live chat ID? (Get this from youtuber api tester)"), }) }) if (response2.ok) { alert("Stream started!") } else { alert("Error starting stream") } }) document.getElementById('endStream').addEventListener('click', async () => { let response = await fetch("/api/endStream", { method: "GET" }) if (response.ok) { alert("Stream ended!") } else { alert("Error ending stream") } }) </script> </body> </html>