diff --git a/owe.js b/owe.js index ffee475..13a7eea 100644 --- a/owe.js +++ b/owe.js @@ -55,6 +55,24 @@ async function loadConfig() { }); } +function getUsernameFromCookie() { + // Split the document.cookie string into individual cookie key-value pairs + var cookies = document.cookie.split(';').map(cookie => cookie.trim()); + + // Loop through the cookies to find the 'owe_user' cookie + for (var i = 0; i < cookies.length; i++) { + var cookie = cookies[i]; + if (cookie.startsWith('owe_user=')) { + // Extract the username from the 'owe_user' cookie + return decodeURIComponent(cookie.substring('owe_user='.length)); + } + } + + // Return null if the 'owe_user' cookie is not set + return null; +} + + function onReloadClicked() { loadSentences(); document.querySelector("#but-reload").style.visibility = "hidden";