diff options
author | Ajay Ramachandran <[email protected]> | 2019-08-12 23:32:10 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2019-08-12 23:32:10 -0400 |
commit | b9091c3a97750bfbe75cd5eedb27e2671aaaddf4 (patch) | |
tree | 467263a798397a11ffd61ba096105d87f68c54ce | |
parent | 5445146b5610f171d992e4e3acd2b92cb76f2495 (diff) | |
download | SponsorBlock-b9091c3a97750bfbe75cd5eedb27e2671aaaddf4.tar.gz SponsorBlock-b9091c3a97750bfbe75cd5eedb27e2671aaaddf4.zip |
Made it get the current username when letting you edit it.
-rw-r--r-- | popup.js | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -1013,8 +1013,27 @@ function runThePopup() { //make the options username setting option visible function setUsernameButton() { - SB.setUsernameContainer.style.display = "none"; - SB.setUsername.style.display = "unset"; + //get the userID + chrome.storage.sync.get(["userID"], function(result) { + //get username from the server + sendRequestToServer("GET", "/api/getUsername?userID=" + result.userID, function (xmlhttp, error) { + if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { + SB.usernameInput.value = JSON.parse(xmlhttp.responseText).userName; + + SB.submitUsername.style.display = "unset"; + SB.usernameInput.style.display = "unset"; + + SB.setUsernameContainer.style.display = "none"; + SB.setUsername.style.display = "unset"; + } else { + SB.setUsername.style.display = "unset"; + SB.submitUsername.style.display = "none"; + SB.usernameInput.style.display = "none"; + + SB.setUsernameStatus.innerText = "Couldn't connect to server. Error code: " + xmlhttp.status; + } + }); + }); } //submit the new username |