diff --git a/manifest.json b/manifest.json index 61a69e0..10ab1f5 100644 --- a/manifest.json +++ b/manifest.json @@ -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", diff --git a/popup.js b/popup.js index 91f8681..3b33271 100644 --- a/popup.js +++ b/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();