mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
Added ability to set your username
This commit is contained in:
parent
13d0e4a33a
commit
5445146b56
2 changed files with 71 additions and 2 deletions
27
popup.html
27
popup.html
|
@ -114,6 +114,31 @@
|
|||
|
||||
</div>
|
||||
|
||||
<div id="setUsernameContainer" class="popupElement">
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<button id="setUsernameButton" class="warningButton popupElement">Set Username</button>
|
||||
</div>
|
||||
|
||||
<div id="setUsername" class="popupElement" style="display: none">
|
||||
<br/>
|
||||
|
||||
<h3>Set Username</h3>
|
||||
|
||||
<div id="setUsernameStatusContainer" style="display: none">
|
||||
<h2 id="setUsernameStatus"></h2>
|
||||
</div>
|
||||
|
||||
|
||||
<input id="usernameInput" hint="Username"></input>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<button id="submitUsername" class="warningButton popupElement">Submit Username</button>
|
||||
</div>
|
||||
|
||||
<div id="discordButtonContainer" class="popupElement" style="display: none">
|
||||
<br/>
|
||||
|
||||
|
@ -121,7 +146,7 @@
|
|||
|
||||
<br/>
|
||||
|
||||
Come join the official discord server to give suggestions and feedback!
|
||||
Come join the official discord server to give suggestions and feedback!
|
||||
|
||||
<br/>
|
||||
|
||||
|
|
46
popup.js
46
popup.js
|
@ -54,6 +54,14 @@ function runThePopup() {
|
|||
// submitTimesInfoMessage
|
||||
"submitTimesInfoMessageContainer",
|
||||
"submitTimesInfoMessage",
|
||||
// Username
|
||||
"setUsernameContainer",
|
||||
"setUsernameButton",
|
||||
"setUsernameStatusContainer",
|
||||
"setUsernameStatus",
|
||||
"setUsername",
|
||||
"usernameInput",
|
||||
"submitUsername",
|
||||
// More
|
||||
"submissionSection",
|
||||
"mainControls",
|
||||
|
@ -78,6 +86,8 @@ function runThePopup() {
|
|||
SB.showDeleteButtonPlayerControls.addEventListener("click", showDeleteButtonPlayerControls);
|
||||
SB.disableSponsorViewTracking.addEventListener("click", disableSponsorViewTracking);
|
||||
SB.enableSponsorViewTracking.addEventListener("click", enableSponsorViewTracking);
|
||||
SB.setUsernameButton.addEventListener("click", setUsernameButton);
|
||||
SB.submitUsername.addEventListener("click", submitUsername);
|
||||
SB.optionsButton.addEventListener("click", openOptions);
|
||||
SB.reportAnIssue.addEventListener("click", reportAnIssue);
|
||||
SB.hideDiscordButton.addEventListener("click", hideDiscordButton);
|
||||
|
@ -995,11 +1005,45 @@ function runThePopup() {
|
|||
}
|
||||
}
|
||||
|
||||
//make the options div visisble
|
||||
//make the options div visible
|
||||
function openOptions() {
|
||||
document.getElementById("optionsButtonContainer").style.display = "none";
|
||||
document.getElementById("options").style.display = "unset";
|
||||
}
|
||||
|
||||
//make the options username setting option visible
|
||||
function setUsernameButton() {
|
||||
SB.setUsernameContainer.style.display = "none";
|
||||
SB.setUsername.style.display = "unset";
|
||||
}
|
||||
|
||||
//submit the new username
|
||||
function submitUsername() {
|
||||
//add loading indicator
|
||||
SB.setUsernameStatusContainer.style.display = "unset";
|
||||
SB.setUsernameStatus.innerText = "Loading...";
|
||||
|
||||
//get the userID
|
||||
chrome.storage.sync.get(["userID"], function(result) {
|
||||
sendRequestToServer("POST", "/api/setUsername?userID=" + result.userID + "&username=" + SB.usernameInput.value, function (xmlhttp, error) {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
//submitted
|
||||
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.setUsernameContainer.style.display = "none";
|
||||
SB.setUsername.style.display = "unset";
|
||||
}
|
||||
|
||||
//this is not a YouTube video page
|
||||
function displayNoVideo() {
|
||||
|
|
Loading…
Reference in a new issue