mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Added language support to setUsername. Fixed error messages not appearing. Reset error messages properly.
Resolves https://github.com/ajayyy/SponsorBlock/issues/111
This commit is contained in:
parent
279e49a143
commit
b1393a563f
4 changed files with 28 additions and 11 deletions
|
@ -103,7 +103,10 @@
|
|||
"noVideoID": {
|
||||
"message": "This probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again."
|
||||
},
|
||||
"Voted": {
|
||||
"success": {
|
||||
"message": "Success!"
|
||||
},
|
||||
"voted": {
|
||||
"message": "Voted!"
|
||||
},
|
||||
"voteFail": {
|
||||
|
|
|
@ -978,7 +978,6 @@ function sendSubmitMessage(){
|
|||
//request the sponsors from the server again
|
||||
sponsorsLookup(currentVideoID);
|
||||
} else {
|
||||
//for a more detailed error message, they should check the popup
|
||||
//show that the upload failed
|
||||
document.getElementById("submitButton").style.animation = "unset";
|
||||
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png");
|
||||
|
|
31
popup.js
31
popup.js
|
@ -799,7 +799,13 @@ function runThePopup() {
|
|||
|
||||
clearTimes();
|
||||
} else {
|
||||
let errorMessage = getErrorMessage(response.statusCode);
|
||||
let errorMessage = "";
|
||||
|
||||
if([400,429,409,502].includes(response.statusCode)) {
|
||||
errorMessage = chrome.i18n.getMessage(response.statusCode);
|
||||
} else {
|
||||
errorMessage = chrome.i18n.getMessage("connectionError") + response.statusCode;
|
||||
}
|
||||
|
||||
document.getElementById("submitTimesInfoMessage").innerText = errorMessage;
|
||||
document.getElementById("submitTimesInfoMessageContainer").style.display = "unset";
|
||||
|
@ -1010,11 +1016,14 @@ function runThePopup() {
|
|||
|
||||
SB.setUsernameContainer.style.display = "none";
|
||||
SB.setUsername.style.display = "unset";
|
||||
} else {
|
||||
|
||||
SB.setUsernameStatusContainer.style.display = "none";
|
||||
} else if (xmlhttp.readyState == 4) {
|
||||
SB.setUsername.style.display = "unset";
|
||||
SB.submitUsername.style.display = "none";
|
||||
SB.usernameInput.style.display = "none";
|
||||
|
||||
SB.setUsernameStatusContainer.style.display = "unset";
|
||||
SB.setUsernameStatus.innerText = "Couldn't connect to server. Error code: " + xmlhttp.status;
|
||||
}
|
||||
});
|
||||
|
@ -1035,11 +1044,17 @@ function runThePopup() {
|
|||
SB.submitUsername.style.display = "none";
|
||||
SB.usernameInput.style.display = "none";
|
||||
|
||||
SB.setUsernameStatus.innerText = "Success!";
|
||||
} else if (xmlhttp.readyState == 4 && xmlhttp.status == 400) {
|
||||
SB.setUsernameStatus.innerText = "Bad Request";
|
||||
} else {
|
||||
SB.setUsernameStatus.innerText = getErrorMessage(EN_US, xmlhttp.status);
|
||||
SB.setUsernameStatus.innerText = chrome.i18n.getMessage("success");
|
||||
} else if (xmlhttp.readyState == 4) {
|
||||
let errorMessage = "";
|
||||
|
||||
if([400, 429, 409, 502].includes(xmlhttp.status)) {
|
||||
errorMessage = chrome.i18n.getMessage(xmlhttp.status);
|
||||
} else {
|
||||
errorMessage = chrome.i18n.getMessage("connectionError") + xmlhttp.status;
|
||||
}
|
||||
|
||||
SB.setUsernameStatus.innerText = errorMessage;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1088,7 +1103,7 @@ function runThePopup() {
|
|||
//see if it was a success or failure
|
||||
if (response.successType == 1) {
|
||||
//success
|
||||
addVoteMessage(chrome.i18n.getMessage("Voted"), UUID)
|
||||
addVoteMessage(chrome.i18n.getMessage("voted"), UUID)
|
||||
} else if (response.successType == 0) {
|
||||
//failure: duplicate vote
|
||||
addVoteMessage(chrome.i18n.getMessage("voteFail"), UUID)
|
||||
|
|
|
@ -268,7 +268,7 @@ class SkipNotice {
|
|||
}
|
||||
|
||||
afterDownvote() {
|
||||
this.addVoteButtonInfo(chrome.i18n.getMessage("Voted"));
|
||||
this.addVoteButtonInfo(chrome.i18n.getMessage("voted"));
|
||||
this.addNoticeInfoMessage(chrome.i18n.getMessage("hitGoBack"));
|
||||
|
||||
//remove this sponsor from the sponsors looked up
|
||||
|
|
Loading…
Reference in a new issue