mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 14:37:23 +03:00
Added a loading indicator when voting.
This commit is contained in:
17
content.css
17
content.css
@@ -56,13 +56,8 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
margin-top: 0px;
|
||||||
|
margin-bottom: 0px;
|
||||||
#sponsorTimesErrorMessage {
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #000000;
|
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#sponsorTimesThanksForVotingInfoText {
|
#sponsorTimesThanksForVotingInfoText {
|
||||||
@@ -70,6 +65,14 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
margin-top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sponsorTimesInfoMessage {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #000000;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.voteButton {
|
.voteButton {
|
||||||
|
|||||||
46
content.js
46
content.js
@@ -339,8 +339,20 @@ function openSkipNotice(){
|
|||||||
function afterDownvote(UUID) {
|
function afterDownvote(UUID) {
|
||||||
//change text to say thanks for voting
|
//change text to say thanks for voting
|
||||||
//remove buttons
|
//remove buttons
|
||||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(document.getElementById("sponsorTimesUpvoteButtonsContainer" + UUID));
|
let upvoteButton = document.getElementById("sponsorTimesUpvoteButtonsContainer" + UUID);
|
||||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(document.getElementById("sponsorTimesDownvoteButtonsContainer" + 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
|
//add thanks for voting text
|
||||||
let thanksForVotingText = document.createElement("p");
|
let thanksForVotingText = document.createElement("p");
|
||||||
@@ -357,15 +369,28 @@ function afterDownvote(UUID) {
|
|||||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).appendChild(thanksForVotingInfoText);
|
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).appendChild(thanksForVotingInfoText);
|
||||||
}
|
}
|
||||||
|
|
||||||
function votingError(message, UUID) {
|
function addLoadingInfo(message, UUID) {
|
||||||
//change text to say thanks for voting
|
//change text to say thanks for message
|
||||||
//remove buttons
|
//remove buttons
|
||||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(document.getElementById("sponsorTimesUpvoteButtonsContainer" + UUID));
|
let upvoteButton = document.getElementById("sponsorTimesUpvoteButtonsContainer" + UUID);
|
||||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).removeChild(document.getElementById("sponsorTimesDownvoteButtonsContainer" + 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
|
//add thanks for voting text
|
||||||
let thanksForVotingText = document.createElement("p");
|
let thanksForVotingText = document.createElement("p");
|
||||||
thanksForVotingText.id = "sponsorTimesErrorMessage";
|
thanksForVotingText.id = "sponsorTimesInfoMessage" + UUID;
|
||||||
|
thanksForVotingText.className = "sponsorTimesInfoMessage";
|
||||||
thanksForVotingText.innerText = message;
|
thanksForVotingText.innerText = message;
|
||||||
|
|
||||||
//add element to div
|
//add element to div
|
||||||
@@ -373,6 +398,9 @@ function votingError(message, UUID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function vote(type, UUID) {
|
function vote(type, UUID) {
|
||||||
|
//add loading info
|
||||||
|
addLoadingInfo("Loading...", UUID)
|
||||||
|
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
message: "submitVote",
|
message: "submitVote",
|
||||||
type: type,
|
type: type,
|
||||||
@@ -389,10 +417,10 @@ function vote(type, UUID) {
|
|||||||
}
|
}
|
||||||
} else if (response.successType == 0) {
|
} else if (response.successType == 0) {
|
||||||
//failure: duplicate vote
|
//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) {
|
} else if (response.successType == -1) {
|
||||||
//failure: duplicate vote
|
//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) {
|
function vote(type, UUID) {
|
||||||
|
//add loading info
|
||||||
|
addVoteMessage("Loading...", UUID)
|
||||||
|
|
||||||
//send the vote message to the tab
|
//send the vote message to the tab
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
message: "submitVote",
|
message: "submitVote",
|
||||||
|
|||||||
Reference in New Issue
Block a user