diff --git a/content.css b/content.css index 1d118fcf69..c05f2f16f7 100644 --- a/content.css +++ b/content.css @@ -1,3 +1,21 @@ +#previewbar { + overflow: visible; + padding: 0; + margin: 0; + position: absolute; + width: 100%; + pointer-events: none; + + height: 100%; + transform: scaleY(0.6) translateY(-30%) translateY(1.5px); + z-index: 40; +} + +.previewbar { + display: inline-block; + height: 100%; +} + .popup { z-index: 10; width: 100%; diff --git a/content.js b/content.js index 3ee26aeb49..0a181560bb 100644 --- a/content.js +++ b/content.js @@ -7,6 +7,9 @@ var UUIDs = null; //what video id are these sponsors for var sponsorVideoID = null; +//these are sponsors that have been downvoted +var hiddenSponsorTimes = []; + //the time this video is starting at when first played, if not zero var youtubeVideoStartTime = null; @@ -19,6 +22,10 @@ var channelURL; //is this channel whitelised from getting sponsors skipped var channelWhitelisted = false; +// create preview bar +let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0]; +var previewBar = new PreviewBar(progressBar); + if(id = getYouTubeVideoID(document.URL)){ // Direct Links videoIDChange(id); } @@ -102,6 +109,7 @@ function messageListener(request, sender, sendResponse) { sendResponse({ found: sponsorDataFound, sponsorTimes: sponsorTimes, + hiddenSponsorTimes: hiddenSponsorTimes, UUIDs: UUIDs }); @@ -310,6 +318,10 @@ function sponsorsLookup(id) { sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes; UUIDs = JSON.parse(xmlhttp.responseText).UUIDs; + //update the preview bar + //leave the type blank for now until categories are added + previewBar.set(sponsorTimes, [], v.duration); + getChannelID(); sponsorLookupRetries = 0; @@ -423,7 +435,7 @@ function checkSponsorTime(sponsorTimes, index, openNotice) { lastTime = v.currentTime - 0.0001; } - if (checkIfTimeToSkip(v.currentTime, sponsorTimes[index][0])) { + if (checkIfTimeToSkip(v.currentTime, sponsorTimes[index][0]) && !hiddenSponsorTimes.includes(index)) { //skip it skipToTime(v, index, sponsorTimes, openNotice); @@ -934,6 +946,26 @@ function afterDownvote(UUID) { //add element to div document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).appendChild(thanksForVotingText); document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).appendChild(thanksForVotingInfoText); + + //remove this sponsor from the sponsors looked up + //find which one it is + for (let i = 0; i < sponsorTimes.length; i++) { + if (UUIDs[i] == UUID) { + //this one is the one to hide + + //add this as a hidden sponsorTime + hiddenSponsorTimes.push(i); + + let sponsorTimesLeft = sponsorTimes.slice(); + for (let j = 0; j < hiddenSponsorTimes.length; j++) { + //remove this sponsor time + sponsorTimesLeft.splice(hiddenSponsorTimes[j], 1); + } + + //update the preview + previewBar.set(sponsorTimesLeft, [], v.duration); + } + } } function addLoadingInfo(message, UUID) { diff --git a/manifest.json b/manifest.json index 23204e4b11..9d3208b877 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "SponsorBlock for YouTube - Skip Sponsorships", "short_name": "SponsorBlock", - "version": "1.0.33", + "version": "1.0.34", "description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", "content_scripts": [ { @@ -11,6 +11,7 @@ "all_frames": true, "js": [ "config.js", + "utils/previewBar.js", "utils.js", "content.js", "popup.js" diff --git a/popup.html b/popup.html index 82c2d66c79..0c829494ee 100644 --- a/popup.html +++ b/popup.html @@ -114,6 +114,31 @@

+
+
+
+ + +
+ + +