send start time
This commit is contained in:
15
popup.js
15
popup.js
@@ -61,6 +61,7 @@ function startContest() {
|
||||
document.getElementById('reset-button').style.display = 'none';
|
||||
document.getElementById('messages').innerHTML = '';
|
||||
if (showMessages) switchMessages();
|
||||
sendStartTime(startTime);
|
||||
}
|
||||
|
||||
function endContest() {
|
||||
@@ -104,13 +105,21 @@ function switchConnectForm() {
|
||||
showConnect = !showConnect;
|
||||
}
|
||||
|
||||
async function sendStartTime(startTime) {
|
||||
const data = await chrome.storage.local.get(['puzzleScoreboard']);
|
||||
if (!data?.puzzleScoreboard || !data.puzzleScoreboard.includes('/message')) return;
|
||||
fetch(data.puzzleScoreboard.replace('/message', '/start'), {
|
||||
method: "post",
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({startTime}),
|
||||
});
|
||||
}
|
||||
|
||||
async function scoreboardConnect(puzzleScoreboard) {
|
||||
if (puzzleScoreboard.includes('/message')) {
|
||||
const resp = await fetch(puzzleScoreboard.replace('/message', '/connect'), {
|
||||
method: "post",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
});
|
||||
if (resp.status != 200) return {connected: false, error: 'Invalid contest token'};
|
||||
const json = await resp.json();
|
||||
|
||||
Reference in New Issue
Block a user