Add getUsernameFromCookie function
This commit is contained in:
parent
4c904551dc
commit
83231a085d
18
owe.js
18
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";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user