aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2019-08-12 23:32:10 -0400
committerAjay Ramachandran <[email protected]>2019-08-12 23:32:10 -0400
commitb9091c3a97750bfbe75cd5eedb27e2671aaaddf4 (patch)
tree467263a798397a11ffd61ba096105d87f68c54ce
parent5445146b5610f171d992e4e3acd2b92cb76f2495 (diff)
downloadSponsorBlock-b9091c3a97750bfbe75cd5eedb27e2671aaaddf4.tar.gz
SponsorBlock-b9091c3a97750bfbe75cd5eedb27e2671aaaddf4.zip
Made it get the current username when letting you edit it.
-rw-r--r--popup.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/popup.js b/popup.js
index ae9a9499..309d5eeb 100644
--- a/popup.js
+++ b/popup.js
@@ -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