From a1d51656c50dd0288c1f915090fa0de54a3a49d5 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 13 Jul 2019 19:15:47 -0400 Subject: [PATCH 1/6] Updated background.js to use config server as well --- README.md | 4 ++-- background.js | 2 +- content-config.js.example => config.js | 2 +- config.js.example | 3 +++ content.js | 2 +- manifest.json | 7 +++++-- 6 files changed, 13 insertions(+), 7 deletions(-) rename content-config.js.example => config.js (68%) create mode 100644 config.js.example diff --git a/README.md b/README.md index 1a90287f..290296e4 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ This project is partially based off of [this experimental extension](https://git # Chrome extension -It will be on the chrome webstore soon once I get some more UI features in, such as an icon. For now, you can load this project as an unpacked extension. Make sure to rename the `content-config.js.example` file to `content-config.js` before installing. +It will be on the chrome webstore soon once I get some more UI features in, such as an icon. For now, you can load this project as an unpacked extension. Make sure to rename the `config.js.example` file to `config.js` before installing. # Firefox extension -None at the moment +None at the moment \ No newline at end of file diff --git a/background.js b/background.js index 3997e50e..388d4cd3 100644 --- a/background.js +++ b/background.js @@ -92,7 +92,7 @@ function submitTimes(videoID) { let userIDStorage = getUserID(function(userIDStorage) { //submit the sponsorTime - xmlhttp.open('GET', 'http://localhost/api/postVideoSponsorTimes?videoID=' + videoID + "&startTime=" + sponsorTimes[i][0] + "&endTime=" + sponsorTimes[i][1] + xmlhttp.open('GET', serverAddress + "/api/postVideoSponsorTimes?videoID=" + videoID + "&startTime=" + sponsorTimes[i][0] + "&endTime=" + sponsorTimes[i][1] + "&userID=" + userIDStorage, true); xmlhttp.send(); }); diff --git a/content-config.js.example b/config.js similarity index 68% rename from content-config.js.example rename to config.js index b7b454de..005793a7 100644 --- a/content-config.js.example +++ b/config.js @@ -1,3 +1,3 @@ //this file is loaded along iwth content.js //this file sets the server to connect to, and is gitignored -var serverAddresss = "https://sponsor.ajay.app"; \ No newline at end of file +var serverAddress = "http://localhost"; \ No newline at end of file diff --git a/config.js.example b/config.js.example new file mode 100644 index 00000000..23cc0be3 --- /dev/null +++ b/config.js.example @@ -0,0 +1,3 @@ +//this file is loaded along iwth content.js +//this file sets the server to connect to, and is gitignored +var serverAddress = "https://sponsor.ajay.app"; \ No newline at end of file diff --git a/content.js b/content.js index a15885ae..d63b8fc5 100644 --- a/content.js +++ b/content.js @@ -114,7 +114,7 @@ function sponsorsLookup(id) { let xmlhttp = new XMLHttpRequest(); //check database for sponsor times - xmlhttp.open('GET', serverAddresss + "/api/getVideoSponsorTimes?videoID=" + id, true); + xmlhttp.open('GET', serverAddress + "/api/getVideoSponsorTimes?videoID=" + id, true); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { diff --git a/manifest.json b/manifest.json index 9c7a7dd6..5c8a5325 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "https://*.youtube.com/*" ], "js": [ - "content-config.js", + "config.js", "content.js" ], "css": [ @@ -33,7 +33,10 @@ "default_popup": "popup.html" }, "background": { - "scripts":["background.js"] + "scripts":[ + "config.js", + "background.js" + ] }, "icons": { "16": "icons/IconSponsorBlocker16px.png", From 762039e2f65225d1ae0726679fb152ad28a1b73c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 14 Jul 2019 13:10:53 -0400 Subject: [PATCH 2/6] Fixed sponsor getting added each time a video was loaded even though it's already in the player. --- content.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/content.js b/content.js index d63b8fc5..f5b82b2c 100644 --- a/content.js +++ b/content.js @@ -166,6 +166,11 @@ function goBackToPreviousTime() { //Adds a sponsorship starts button to the player controls function addPlayerControlsButton() { + if (document.getElementById("startSponsorButton") != null) { + //it's already added + return; + } + let startSponsorButton = document.createElement("button"); startSponsorButton.id = "startSponsorButton"; startSponsorButton.className = "ytp-button"; From f3cc497bd63863a5b8653d6fc7a812fd3f462164 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 15 Jul 2019 16:28:41 -0400 Subject: [PATCH 3/6] Added thumbs up and down buttons. --- README.md | 6 ++- content.css | 28 ++++++++++++- content.js | 22 ++++++++-- icons/downvote.png | Bin 0 -> 6513 bytes icons/upvote.png | Bin 0 -> 6600 bytes icons/upvote.svg | 98 +++++++++++++++++++++++++++++++++++++++++++++ manifest.json | 4 +- popup.css | 16 ++++++++ 8 files changed, 166 insertions(+), 8 deletions(-) create mode 100644 icons/downvote.png create mode 100644 icons/upvote.png create mode 100644 icons/upvote.svg diff --git a/README.md b/README.md index 290296e4..70756792 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,8 @@ It will be on the chrome webstore soon once I get some more UI features in, such # Firefox extension -None at the moment \ No newline at end of file +None at the moment + +# Credit + +Some i made by Gregor Cresnar from www.flaticon.com and are licensed by CC 3.0 BY \ No newline at end of file diff --git a/content.css b/content.css index 89cfcdea..10032d41 100644 --- a/content.css +++ b/content.css @@ -12,12 +12,13 @@ } #sponsorSkipNotice { - min-height: 125px; + min-height: 165px; min-width: 400px; background-color: rgba(255, 217, 217, 0.8); position: absolute; z-index: 1; border: 3px solid rgba(0, 0, 0, 0.8); + margin-top: -50px; } #sponsorSkipMessage { @@ -26,12 +27,23 @@ text-align: center; margin-top: 10px; font-weight: bold; + margin-top: 4px; } #sponsorSkipInfo { font-size: 10px; color: #000000; - text-align: center; + text-align: center; + margin-top: 0px; +} + +.voteButton { + height: 32px; + margin-right: 15px; + cursor: pointer; +} +.voteButton:hover { + filter: brightness(80%); } .sponsorSkipButton { @@ -54,6 +66,12 @@ .sponsorSkipButton:hover { background-color:#bf2a2a; } + +.sponsorSkipButton:focus { + outline: none; + background-color:#bf2a2a; +} + .sponsorSkipButton:active { position:relative; top:1px; @@ -79,6 +97,12 @@ .sponsorSkipDontShowButton:hover { background-color:#bc3315; } + +.sponsorSkipDontShowButton:focus { + outline: none; + background-color:#bc3315; +} + .sponsorSkipDontShowButton:active { position:relative; top:1px; diff --git a/content.js b/content.js index f5b82b2c..08fc07e3 100644 --- a/content.js +++ b/content.js @@ -250,26 +250,39 @@ function openSkipNotice(){ let noticeInfo = document.createElement("p"); noticeInfo.id = "sponsorSkipInfo"; noticeInfo.className = "sponsorSkipObject"; - noticeInfo.innerText = "This message will disapear in 7 seconds"; + noticeInfo.innerText = "This message will disapear in 7 seconds"; + + //thumbs up and down buttons + let voteButtonsContainer = document.createElement("div"); + voteButtonsContainer.setAttribute("align", "center"); + + let upvoteButton = document.createElement("img"); + upvoteButton.className = "sponsorSkipObject voteButton"; + upvoteButton.src = chrome.extension.getURL("icons/upvote.png"); + + let downvoteButton = document.createElement("img"); + downvoteButton.className = "sponsorSkipObject voteButton"; + downvoteButton.src = chrome.extension.getURL("icons/downvote.png"); + + //add thumbs up and down buttons to the container + voteButtonsContainer.appendChild(upvoteButton); + voteButtonsContainer.appendChild(downvoteButton); let buttonContainer = document.createElement("div"); buttonContainer.setAttribute("align", "center"); let goBackButton = document.createElement("button"); goBackButton.innerText = "Go back"; - goBackButton.className = "sponsorSkipObject"; goBackButton.className = "sponsorSkipButton"; goBackButton.addEventListener("click", goBackToPreviousTime); let hideButton = document.createElement("button"); hideButton.innerText = "Dismiss"; - hideButton.className = "sponsorSkipObject"; hideButton.className = "sponsorSkipButton"; hideButton.addEventListener("click", closeSkipNotice); let dontShowAgainButton = document.createElement("button"); dontShowAgainButton.innerText = "Don't Show This Again"; - dontShowAgainButton.className = "sponsorSkipObject"; dontShowAgainButton.className = "sponsorSkipDontShowButton"; dontShowAgainButton.addEventListener("click", dontShowNoticeAgain); @@ -282,6 +295,7 @@ function openSkipNotice(){ noticeElement.appendChild(logoElement); noticeElement.appendChild(noticeMessage); noticeElement.appendChild(noticeInfo); + noticeElement.appendChild(voteButtonsContainer); noticeElement.appendChild(buttonContainer); let referenceNode = document.getElementById("info"); diff --git a/icons/downvote.png b/icons/downvote.png new file mode 100644 index 0000000000000000000000000000000000000000..1af50e786119880f4766255f7ffa1d2b4173cdf9 GIT binary patch literal 6513 zcmY*ec|26@-#%j&3}atvtRY7BT~dg#7KVzl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R zjsY&DqhoG0@K~zuyUcpPC`<&)T|$J`zv!4C%crpCLA0Z0eE}xigX!$Mp?Rq?z+n#WllqAye^!H4nTZfih3VZyO4KADSHM;py z_nCLsfz0;U;LSQXhB9R438^g9zCQ@`X}K*-xY&z>B9WRCWFe0@A4K7^=>e0`-`5U- zE8D&UYmV?;fe4()Dqx|rJCxsZ>l+7a~xM=o` zFoq35r)B%Y!tB0t`ql5|c%<#F9v(L?O}+@j;*5GMH33hY&!tzdeM8@={g4|y17c50 zfZ1^(M%n_8^GNB`R77C|TeK8!4^;jW?-Ywl^#zPui;6MuHhNfdF>>Y$nVV2f1gq__ zx`2I11;&=f`qAL&1%JieW4o4xw}2ktrWA|xq%lO#sh71PEp!3*vpDeA*2*d}B)uO; zJxf>u2mjeDho+i<^A|KjHFe$xpGMvYW+hn$a}s&Mb<1ptt6n6*AMo(x*sXLDKC(FL z22z9@4l|~~UcKMNyWpj~YYRWW!k)A}j9bJY~iY*8(sk!&pQ7;FnmkD+&oOM4^ zW>n25m%mYQ>55QXw#8AY=94NVpSTRCtv*X93aS8`pFjy)&_$kbRE`$cJc6wJI4Pc^ zCULnIA3jbq4TfWJLIe|6h$l_2Hv*JJ$5FB7_yDxN3KnPEmBbMBa8@OwKm?(-O%7zQ zglneVzEQ1pi?b3~`hx?P>{}JLJD;cE=kL;>(MJ4z_oS7u?JWtmubd;c?2t^HA48OI zwgMEcfA?o1_X}vH>Blum)}AP~?C3U7*RhIx!@Fw63BhG2e+TLz-R>sTpuL8VuZuA# z)D^KU=^mgmHGO8}dvg#L*C;DNZ6#`t^I#+Xjh57oxCZq1D8kijC=R`1)y-i%4gMnn*kJ7~Do*0#{|AnNAp-ya literal 0 HcmV?d00001 diff --git a/icons/upvote.png b/icons/upvote.png new file mode 100644 index 0000000000000000000000000000000000000000..56eb5c5b86886cc06dd95188866649af5d653230 GIT binary patch literal 6600 zcmY*ec|6nqAODzUj!epJk}miC#oQ#Mz73H(QXvsr$j#heWF3-XSURSm91(I1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OpHI!bbs7cTVFeoL&8pH`5sFpEB-Ht!>zFO5<&fFR(H#C0Ksnu}lOb8I5sTJ2x0x}scWXN>C7 z{qOVPTi59BlwE=ba-ECqvHYR&gEq=!hgG9`fiI)%7a4;Z4aDNN@Rl&1dQh0sMP20M z=1ToqnOGqs{!POi^F;F;$G9yHI0H-Lwv$SiYx*3+RWsd>qK8pCtB0@8c4YVmaPZF43WW=63;=;BaPj$TcTS6?UvUJOgfL5Z>C + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/manifest.json b/manifest.json index 5c8a5325..c742d16d 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,9 @@ "icons/LogoSponsorBlocker256px.png", "icons/IconSponsorBlocker256px.png", "icons/PlayerStartIconSponsorBlocker256px.png", - "icons/PlayerStopIconSponsorBlocker256px.png" + "icons/PlayerStopIconSponsorBlocker256px.png", + "icons/upvote.png", + "icons/downvote.png" ], "permissions": [ "tabs", diff --git a/popup.css b/popup.css index 9c59f74f..64ae0a17 100644 --- a/popup.css +++ b/popup.css @@ -29,6 +29,10 @@ body { .greenButton:hover { background-color:#bf2a2a; } +.greenButton:focus { + outline: none; + background-color:#bf2a2a; +} .greenButton:active { position:relative; top:1px; @@ -54,6 +58,10 @@ body { .dangerButton:hover { background-color:#bc3315; } +.dangerButton:focus { + outline: none; + background-color:#bc3315; +} .dangerButton:active { position:relative; top:1px; @@ -79,6 +87,10 @@ body { .warningButton:hover { background-color:#bc8215; } +.warningButton:focus { + outline: none; + background-color:#bc8215; +} .warningButton:active { position:relative; top:1px; @@ -100,6 +112,10 @@ body { .smallButton:hover { background-color:#fa9806; } +.smallButton:focus { + outline: none; + background-color:#fa9806; +} .smallButton:active { position:relative; top:1px; From 6cd01108f42c87bb9fae80936572ef2a7ef7659c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 15 Jul 2019 18:56:16 -0400 Subject: [PATCH 4/6] Save UUIDs of the sponsors times along with sponsor times. --- content.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/content.js b/content.js index 08fc07e3..f50a08b4 100644 --- a/content.js +++ b/content.js @@ -11,8 +11,9 @@ if(id = getYouTubeVideoID(document.URL)){ // Direct Links //was sponsor data found when doing SponsorsLookup var sponsorDataFound = false; -//the actual sponsorTimes if loaded +//the actual sponsorTimes if loaded and UUIDs associated with them var sponsorTimes = undefined; +var UUIDs = undefined; //the video var v; @@ -23,6 +24,8 @@ var lastTime; //the last time in the video a sponsor was skipped //used for the go back button var lastSponsorTimeSkipped = null; +//used for ratings +var lastSponsorTimeSkippedUUID = null; //if showing the start sponsor button or the end sponsor button on the player var showingStartSponsor = true; @@ -121,6 +124,7 @@ function sponsorsLookup(id) { sponsorDataFound = true; sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes; + UUIDs = JSON.parse(xmlhttp.responseText).UUIDs; // If the sponsor data exists, add the event to run on the videos "ontimeupdate" v.ontimeupdate = function () { @@ -135,15 +139,16 @@ function sponsorsLookup(id) { function sponsorCheck(sponsorTimes) { // Video skipping //see if any sponsor start time was just passed - sponsorTimes.forEach(function (sponsorTime, index) { // Foreach Sponsor in video + for (let i = 0; i < sponsorTimes.length; i++) { //the sponsor time is in between these times, skip it //if the time difference is more than 1 second, than the there was probably a skip in time, // and it's not due to playback - if (Math.abs(v.currentTime - lastTime) < 1 && sponsorTime[0] >= lastTime && sponsorTime[0] <= v.currentTime) { + if (Math.abs(v.currentTime - lastTime) < 1 && sponsorTimes[i][0] >= lastTime && sponsorTimes[i][0] <= v.currentTime) { //skip it - v.currentTime = sponsorTime[1]; + v.currentTime = sponsorTimes[i][1]; - lastSponsorTimeSkipped = sponsorTime[0]; + lastSponsorTimeSkipped = sponsorTimes[i][0]; + lastSponsorTimeSkippedUUID = UUIDs[i]; //send out the message saying that a sponsor message was skipped openSkipNotice(); @@ -152,7 +157,7 @@ function sponsorCheck(sponsorTimes) { // Video skipping } lastTime = v.currentTime; - }); + } } function goBackToPreviousTime() { From 987b7b036c004c0c42cc4be1c643b45d1c71f3b2 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 15 Jul 2019 19:13:09 -0400 Subject: [PATCH 5/6] Made upvote system submit data to the server. --- background.js | 16 ++++++++++++++++ content.js | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/background.js b/background.js index 388d4cd3..c619bcbb 100644 --- a/background.js +++ b/background.js @@ -41,6 +41,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) { //this allows the callback to be called later return true; + } else if (request.message == "submitVote") { + submitVote(request.type, request.UUID) } }); @@ -79,6 +81,19 @@ function addSponsorTime(time) { }); } +function submitVote(type, UUID) { + let xmlhttp = new XMLHttpRequest(); + + getUserID(function(userID) { + //publish this vote + console.log(serverAddress + "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type); + xmlhttp.open('GET', serverAddress + "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, true); + + //submit this vote + xmlhttp.send(); + }) +} + function submitTimes(videoID) { //get the video times from storage let sponsorTimeKey = 'sponsorTimes' + videoID; @@ -130,6 +145,7 @@ function videoIDChange(currentVideoID) { function getUserID(callback) { if (userID != null) { callback(userID); + return; } //if it is not cached yet, grab it from storage diff --git a/content.js b/content.js index f50a08b4..5cbc538d 100644 --- a/content.js +++ b/content.js @@ -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"); From 255f049c9609e7c47b5bb32cf1dca36771baef0c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 15 Jul 2019 20:38:26 -0400 Subject: [PATCH 6/6] 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) {