send start time
This commit is contained in:
parent
44a0b5c464
commit
5d1390c480
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Puzzle leaderboard tracker",
|
||||
"description": "Base Level Extension",
|
||||
"version": "1.1",
|
||||
"version": "1.1.1",
|
||||
"manifest_version": 3,
|
||||
"action": {
|
||||
"default_popup": "popup.html",
|
||||
|
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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user