From 255f049c9609e7c47b5bb32cf1dca36771baef0c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 15 Jul 2019 20:38:26 -0400 Subject: [PATCH] Made upvote button close menu and downvote show message --- content.css | 14 ++++++++++++++ content.js | 24 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/content.css b/content.css index 10032d41..1a85c3ac 100644 --- a/content.css +++ b/content.css @@ -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; diff --git a/content.js b/content.js index 5cbc538d..91e217f6 100644 --- a/content.js +++ b/content.js @@ -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); @@ -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) {