Skip to content

Commit

Permalink
Made upvote button close menu and downvote show message
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy committed Jul 16, 2019
1 parent 987b7b0 commit 255f049
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions content.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@
margin-top: 0px;
}

#sponsorTimesThanksForVotingText {
font-size: 20px;
font-weight: bold;
color: #000000;
text-align: center;
}

#sponsorTimesThanksForVotingInfoText {
font-size: 12px;
font-weight: bold;
color: #000000;
text-align: center;
}

.voteButton {
height: 32px;
margin-right: 15px;
Expand Down
24 changes: 24 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,17 @@ function openSkipNotice(){

//thumbs up and down buttons
let voteButtonsContainer = document.createElement("div");
voteButtonsContainer.id = "sponsorTimesVoteButtonsContainer";
voteButtonsContainer.setAttribute("align", "center");

let upvoteButton = document.createElement("img");
upvoteButton.id = "sponsorTimesUpvoteButtonsContainer"
upvoteButton.className = "sponsorSkipObject voteButton";
upvoteButton.src = chrome.extension.getURL("icons/upvote.png");
upvoteButton.addEventListener("click", upvote);

let downvoteButton = document.createElement("img");
downvoteButton.id = "sponsorTimesDownvoteButtonsContainer"
downvoteButton.className = "sponsorSkipObject voteButton";
downvoteButton.src = chrome.extension.getURL("icons/downvote.png");
downvoteButton.addEventListener("click", downvote);
Expand Down Expand Up @@ -315,10 +318,31 @@ function openSkipNotice(){

function upvote() {
vote(1);

closeSkipNotice();
}

function downvote() {
vote(0);

//change text to say thanks for voting
//remove buttons
document.getElementById("sponsorTimesVoteButtonsContainer").removeChild(document.getElementById("sponsorTimesUpvoteButtonsContainer"));
document.getElementById("sponsorTimesVoteButtonsContainer").removeChild(document.getElementById("sponsorTimesDownvoteButtonsContainer"));

//add thanks for voting text
let thanksForVotingText = document.createElement("p");
thanksForVotingText.id = "sponsorTimesThanksForVotingText";
thanksForVotingText.innerText = "Thanks for voting!"

//add extra info for voting
let thanksForVotingInfoText = document.createElement("p");
thanksForVotingInfoText.id = "sponsorTimesThanksForVotingInfoText";
thanksForVotingInfoText.innerText = "Hit go back to get to where you came from."

//add element to div
document.getElementById("sponsorTimesVoteButtonsContainer").appendChild(thanksForVotingText);
document.getElementById("sponsorTimesVoteButtonsContainer").appendChild(thanksForVotingInfoText);
}

function vote(type) {
Expand Down

0 comments on commit 255f049

Please sign in to comment.