Made upvote system submit data to the server.

This commit is contained in:
Ajay Ramachandran
2019-07-15 19:13:09 -04:00
parent 6cd01108f4
commit 987b7b036c
2 changed files with 34 additions and 0 deletions

View File

@@ -264,10 +264,12 @@ function openSkipNotice(){
let upvoteButton = document.createElement("img");
upvoteButton.className = "sponsorSkipObject voteButton";
upvoteButton.src = chrome.extension.getURL("icons/upvote.png");
upvoteButton.addEventListener("click", upvote);
let downvoteButton = document.createElement("img");
downvoteButton.className = "sponsorSkipObject voteButton";
downvoteButton.src = chrome.extension.getURL("icons/downvote.png");
downvoteButton.addEventListener("click", downvote);
//add thumbs up and down buttons to the container
voteButtonsContainer.appendChild(upvoteButton);
@@ -311,6 +313,22 @@ function openSkipNotice(){
referenceNode.prepend(noticeElement);
}
function upvote() {
vote(1);
}
function downvote() {
vote(0);
}
function vote(type) {
chrome.runtime.sendMessage({
message: "submitVote",
type: type,
UUID: lastSponsorTimeSkippedUUID
});
}
//Closes the notice that tells the user that a sponsor was just skipped
function closeSkipNotice(){
let notice = document.getElementById("sponsorSkipNotice");