mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
Added a loading indicator when voting.
This commit is contained in:
parent
4bb6cd0dcf
commit
4cc44258e8
3 changed files with 50 additions and 16 deletions
17
content.css
17
content.css
|
@ -56,13 +56,8 @@
|
|||
font-weight: bold;
|
||||
color: #000000;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#sponsorTimesErrorMessage {
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
color: #000000;
|
||||
text-align: center;
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
#sponsorTimesThanksForVotingInfoText {
|
||||
|
@ -70,6 +65,14 @@
|
|||
font-weight: bold;
|
||||
color: #000000;
|
||||
text-align: center;
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
.sponsorTimesInfoMessage {
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
color: #000000;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.voteButton {
|
||||
|
|
46
content.js
46
content.js
|
@ -339,8 +339,20 @@ function openSkipNotice(){
|
|||
function afterDownvote(UUID) {
|
||||
//change text to say thanks for voting
|
||||
//remove buttons
|
||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(document.getElementById("sponsorTimesUpvoteButtonsContainer" + UUID));
|
||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(document.getElementById("sponsorTimesDownvoteButtonsContainer" + UUID));
|
||||
let upvoteButton = document.getElementById("sponsorTimesUpvoteButtonsContainer" + UUID);
|
||||
let downvoteButton = document.getElementById("sponsorTimesDownvoteButtonsContainer" + UUID);
|
||||
if (upvoteButton != null) {
|
||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(upvoteButton);
|
||||
}
|
||||
if (downvoteButton != null) {
|
||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(downvoteButton);
|
||||
}
|
||||
|
||||
let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + UUID);
|
||||
if (previousInfoMessage != null) {
|
||||
//remove it
|
||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(previousInfoMessage);
|
||||
}
|
||||
|
||||
//add thanks for voting text
|
||||
let thanksForVotingText = document.createElement("p");
|
||||
|
@ -357,15 +369,28 @@ function afterDownvote(UUID) {
|
|||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).appendChild(thanksForVotingInfoText);
|
||||
}
|
||||
|
||||
function votingError(message, UUID) {
|
||||
//change text to say thanks for voting
|
||||
function addLoadingInfo(message, UUID) {
|
||||
//change text to say thanks for message
|
||||
//remove buttons
|
||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(document.getElementById("sponsorTimesUpvoteButtonsContainer" + UUID));
|
||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(document.getElementById("sponsorTimesDownvoteButtonsContainer" + UUID));
|
||||
let upvoteButton = document.getElementById("sponsorTimesUpvoteButtonsContainer" + UUID);
|
||||
let downvoteButton = document.getElementById("sponsorTimesDownvoteButtonsContainer" + UUID);
|
||||
if (upvoteButton != null) {
|
||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(upvoteButton);
|
||||
}
|
||||
if (downvoteButton != null) {
|
||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(downvoteButton);
|
||||
}
|
||||
|
||||
let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + UUID);
|
||||
if (previousInfoMessage != null) {
|
||||
//remove it
|
||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(previousInfoMessage);
|
||||
}
|
||||
|
||||
//add thanks for voting text
|
||||
let thanksForVotingText = document.createElement("p");
|
||||
thanksForVotingText.id = "sponsorTimesErrorMessage";
|
||||
thanksForVotingText.id = "sponsorTimesInfoMessage" + UUID;
|
||||
thanksForVotingText.className = "sponsorTimesInfoMessage";
|
||||
thanksForVotingText.innerText = message;
|
||||
|
||||
//add element to div
|
||||
|
@ -373,6 +398,9 @@ function votingError(message, UUID) {
|
|||
}
|
||||
|
||||
function vote(type, UUID) {
|
||||
//add loading info
|
||||
addLoadingInfo("Loading...", UUID)
|
||||
|
||||
chrome.runtime.sendMessage({
|
||||
message: "submitVote",
|
||||
type: type,
|
||||
|
@ -389,10 +417,10 @@ function vote(type, UUID) {
|
|||
}
|
||||
} else if (response.successType == 0) {
|
||||
//failure: duplicate vote
|
||||
votingError("It seems you've already voted before", UUID)
|
||||
addLoadingInfo("It seems you've already voted before", UUID)
|
||||
} else if (response.successType == -1) {
|
||||
//failure: duplicate vote
|
||||
votingError("A connection error has occured.", UUID)
|
||||
addLoadingInfo("A connection error has occured.", UUID)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
3
popup.js
3
popup.js
|
@ -386,6 +386,9 @@ function addVoteMessage(message, UUID) {
|
|||
}
|
||||
|
||||
function vote(type, UUID) {
|
||||
//add loading info
|
||||
addVoteMessage("Loading...", UUID)
|
||||
|
||||
//send the vote message to the tab
|
||||
chrome.runtime.sendMessage({
|
||||
message: "submitVote",
|
||||
|
|
Loading…
Reference in a new issue