From 55c7529731c4c4a2175ae66eb738ef25ea2680d8 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 23 Jul 2019 20:06:08 -0400 Subject: [PATCH 1/5] Update README.md --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 89aa4c8e..274fe20a 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,12 @@ SponsorBlock is an extension that will skip over sponsored segments of YouTube videos. SponsorBlock is a crowdsourced browser extension that let's anyone submit the start and end time's of sponsored segments of YouTube videos. Once one person submits this information, everyone else with this extension will skip right over the sponsored segment. +# Available for Chrome and Firefox + +Chrome: https://chrome.google.com/webstore/detail/mnjggcdmjocbbbhaepdhchncahnbgone/ + +Firefox: https://addons.mozilla.org/addon/sponsorblock/ + # Server The backend server code is available here: https://github.com/ajayyy/SponsorBlockServer @@ -19,13 +25,9 @@ Hopefully this project can be combined with projects like [this](https://github. This project is partially based off of [this experimental extension](https://github.com/OfficialNoob/YTSponsorSkip). That extension has the basic video skipping functionality. -# Chrome extension +# Build Yourself -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 +You can load this project as an unpacked extension. Make sure to rename the `config.js.example` file to `config.js` before installing. # Credit From 08cb324125d9a3b631c0fc85131b09822cc7b287 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sat, 27 Jul 2019 12:57:44 +0100 Subject: [PATCH 2/5] Added confirm for submitSponsorTimes --- content.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content.js b/content.js index 4c624aaa..5e46eff7 100644 --- a/content.js +++ b/content.js @@ -593,6 +593,7 @@ function sponsorMessageStarted() { } function submitSponsorTimes() { + if(!confirm("Are you sure you want to submit this?")) return; //add loading animation document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png"); document.getElementById("submitButton").style.animation = "rotate 1s 0s infinite"; @@ -670,4 +671,4 @@ function getYouTubeVideoID(url) { // Returns with video id else returns false var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; var match = url.match(regExp); return (match && match[7].length == 11) ? match[7] : false; -} \ No newline at end of file +} From 569699cbc190f8d83f914a03c0ff5938062ece39 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sat, 27 Jul 2019 13:57:04 +0100 Subject: [PATCH 3/5] Added references --- popup.js | 98 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 46 deletions(-) diff --git a/popup.js b/popup.js index cec46eb9..af754f2d 100644 --- a/popup.js +++ b/popup.js @@ -1,14 +1,29 @@ +// References +SB.sponsorStart = document.getElementById("sponsorStart"); +SB.clearTimes = document.getElementById("clearTimes"); +SB.submitTimes = document.getElementById("submitTimes"); +SB.showNoticeAgain = document.getElementById("showNoticeAgain"); +SB.hideVideoPlayerControls = document.getElementById("hideVideoPlayerControls"); +SB.showVideoPlayerControls = document.getElementById("showVideoPlayerControls"); +SB.disableSponsorViewTracking = document.getElementById("disableSponsorViewTracking"); +SB.enableSponsorViewTracking = document.getElementById("enableSponsorViewTracking"); +SB.optionsButton = document.getElementById("optionsButton"); +SB.reportAnIssue = document.getElementById("reportAnIssue"); +// sponsorTimesContributions +SB.sponsorTimesContributionsContainer = document.getElementById("sponsorTimesContributionsContainer"); +SB.sponsorTimesContributionsDisplay = document.getElementById("sponsorTimesContributionsDisplay"); +SB.sponsorTimesContributionsDisplayEndWord = document.getElementById("sponsorTimesContributionsDisplayEndWord"); //setup click listeners -document.getElementById("sponsorStart").addEventListener("click", sendSponsorStartMessage); -document.getElementById("clearTimes").addEventListener("click", clearTimes); -document.getElementById("submitTimes").addEventListener("click", submitTimes); -document.getElementById("showNoticeAgain").addEventListener("click", showNoticeAgain); -document.getElementById("hideVideoPlayerControls").addEventListener("click", hideVideoPlayerControls); -document.getElementById("showVideoPlayerControls").addEventListener("click", showVideoPlayerControls); -document.getElementById("disableSponsorViewTracking").addEventListener("click", disableSponsorViewTracking); -document.getElementById("enableSponsorViewTracking").addEventListener("click", enableSponsorViewTracking); -document.getElementById("optionsButton").addEventListener("click", openOptions); -document.getElementById("reportAnIssue").addEventListener("click", reportAnIssue); +SB.sponsorStart.addEventListener("click", sendSponsorStartMessage); +SB.clearTimes.addEventListener("click", clearTimes); +SB.submitTimes.addEventListener("click", submitTimes); +SB.showNoticeAgain.addEventListener("click", showNoticeAgain); +SB.hideVideoPlayerControls.addEventListener("click", hideVideoPlayerControls); +SB.showVideoPlayerControls.addEventListener("click", showVideoPlayerControls); +SB.disableSponsorViewTracking.addEventListener("click", disableSponsorViewTracking); +SB.enableSponsorViewTracking.addEventListener("click", enableSponsorViewTracking); +SB.optionsButton.addEventListener("click", openOptions); +SB.reportAnIssue.addEventListener("click", reportAnIssue); //if true, the button now selects the end time var startTimeChosen = false; @@ -27,7 +42,7 @@ var isYouTubeTab = false; chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { let dontShowNoticeAgain = result.dontShowNoticeAgain; if (dontShowNoticeAgain != undefined && dontShowNoticeAgain) { - document.getElementById("showNoticeAgain").style.display = "unset"; + SB.showNoticeAgain.style.display = "unset"; } }); @@ -35,8 +50,8 @@ chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) { let hideVideoPlayerControls = result.hideVideoPlayerControls; if (hideVideoPlayerControls != undefined && hideVideoPlayerControls) { - document.getElementById("hideVideoPlayerControls").style.display = "none"; - document.getElementById("showVideoPlayerControls").style.display = "unset"; + SB.hideVideoPlayerControls.style.display = "none"; + SB.showVideoPlayerControls.style.display = "unset"; } }); @@ -44,25 +59,21 @@ chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) { chrome.storage.sync.get(["trackViewCount"], function(result) { let trackViewCount = result.trackViewCount; if (trackViewCount != undefined && !trackViewCount) { - document.getElementById("disableSponsorViewTracking").style.display = "none"; - document.getElementById("enableSponsorViewTracking").style.display = "unset"; + SB.disableSponsorViewTracking.style.display = "none"; + SB.enableSponsorViewTracking.style.display = "unset"; } }); //get the amount of times this user has contributed and display it to thank them chrome.storage.sync.get(["sponsorTimesContributed"], function(result) { if (result.sponsorTimesContributed != undefined) { - let sponsorTimesContributionsContainer = document.getElementById("sponsorTimesContributionsContainer"); - let sponsorTimesContributionsDisplay = document.getElementById("sponsorTimesContributionsDisplay"); - let sponsorTimesContributionsDisplayEndWord = document.getElementById("sponsorTimesContributionsDisplayEndWord"); - if (result.sponsorTimesContributed > 1) { - sponsorTimesContributionsDisplayEndWord.innerText = "sponsors." + SB.sponsorTimesContributionsDisplayEndWord.innerText = "sponsors." } else { - sponsorTimesContributionsDisplayEndWord.innerText = "sponsor." + SB.sponsorTimesContributionsDisplayEndWord.innerText = "sponsor." } - sponsorTimesContributionsDisplay.innerText = result.sponsorTimesContributed; - sponsorTimesContributionsContainer.style.display = "unset"; + SB.sponsorTimesContributionsDisplay.innerText = result.sponsorTimesContributed; + SB.sponsorTimesContributionsContainer.style.display = "unset"; //get the userID chrome.storage.sync.get(["userID"], function(result) { @@ -73,19 +84,14 @@ chrome.storage.sync.get(["sponsorTimesContributed"], function(result) { sendRequestToServer("GET", "/api/getViewsForUser?userID=" + userID, function(xmlhttp) { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { let viewCount = JSON.parse(xmlhttp.responseText).viewCount; - if (viewCount != 0) { - let sponsorTimesViewsContainer = document.getElementById("sponsorTimesViewsContainer"); - let sponsorTimesViewsDisplay = document.getElementById("sponsorTimesViewsDisplay"); - let sponsorTimesViewsDisplayEndWord = document.getElementById("sponsorTimesViewsDisplayEndWord"); - if (viewCount > 1) { - sponsorTimesViewsDisplayEndWord.innerText = "sponsor segments." + SB.sponsorTimesViewsDisplayEndWord.innerText = "sponsor segments." } else { - sponsorTimesViewsDisplayEndWord.innerText = "sponsor segment." + SB.sponsorTimesViewsDisplayEndWord.innerText = "sponsor segment." } - sponsorTimesViewsDisplay.innerText = viewCount; - sponsorTimesViewsContainer.style.display = "unset"; + SB.sponsorTimesViewsDisplay.innerText = viewCount; + SB.sponsorTimesViewsContainer.style.display = "unset"; } } }); @@ -117,7 +123,7 @@ function loadTabData(tabs) { if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) { if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) { startTimeChosen = true; - document.getElementById("sponsorStart").innerHTML = "Sponsorship Ends Now"; + SB.sponsorStart.innerHTML = "Sponsorship Ends Now"; } sponsorTimes = sponsorTimesStorage; @@ -372,7 +378,7 @@ function showNoticeAgain() { }); }); - document.getElementById("showNoticeAgain").style.display = "none"; + SB.showNoticeAgain.style.display = "none"; } function hideVideoPlayerControls() { @@ -388,8 +394,8 @@ function hideVideoPlayerControls() { }); }); - document.getElementById("hideVideoPlayerControls").style.display = "none"; - document.getElementById("showVideoPlayerControls").style.display = "unset"; + SB.hideVideoPlayerControls.style.display = "none"; + SB.showVideoPlayerControls.style.display = "unset"; } function showVideoPlayerControls() { @@ -405,8 +411,8 @@ function showVideoPlayerControls() { }); }); - document.getElementById("hideVideoPlayerControls").style.display = "unset"; - document.getElementById("showVideoPlayerControls").style.display = "none"; + SB.hideVideoPlayerControls.style.display = "unset"; + SB.showVideoPlayerControls.style.display = "none"; } function disableSponsorViewTracking() { @@ -422,8 +428,8 @@ function disableSponsorViewTracking() { }); }); - document.getElementById("disableSponsorViewTracking").style.display = "none"; - document.getElementById("enableSponsorViewTracking").style.display = "unset"; + SB.disableSponsorViewTracking.style.display = "none"; + SB.enableSponsorViewTracking.style.display = "unset"; } function enableSponsorViewTracking() { @@ -439,15 +445,15 @@ function enableSponsorViewTracking() { }); }); - document.getElementById("enableSponsorViewTracking").style.display = "none"; - document.getElementById("disableSponsorViewTracking").style.display = "unset"; + SB.enableSponsorViewTracking.style.display = "none"; + SB.disableSponsorViewTracking.style.display = "unset"; } function updateStartTimeChosen() { //update startTimeChosen variable if (!startTimeChosen) { startTimeChosen = true; - document.getElementById("sponsorStart").innerHTML = "Sponsorship Ends Now"; + SB.sponsorStart.innerHTML = "Sponsorship Ends Now"; } else { resetStartTimeChosen(); } @@ -456,7 +462,7 @@ function updateStartTimeChosen() { //set it to false function resetStartTimeChosen() { startTimeChosen = false; - document.getElementById("sponsorStart").innerHTML = "Sponsorship Starts Now"; + SB.sponsorStart.innerHTML = "Sponsorship Starts Now"; } //hides and shows the submit times button when needed @@ -485,7 +491,7 @@ function displayNoVideo() { function reportAnIssue() { document.getElementById("issueReporterContainer").style.display = "unset"; - document.getElementById("reportAnIssue").style.display = "none"; + SB.reportAnIssue.style.display = "none"; } function addVoteMessage(message, UUID) { @@ -566,4 +572,4 @@ function getYouTubeVideoID(url) { // Return video id or false var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; var match = url.match(regExp); return (match && match[7].length == 11) ? match[7] : false; -} \ No newline at end of file +} From 30c1b2d91981020f3b0fa50f7a31573b21782c02 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 27 Jul 2019 11:18:50 -0400 Subject: [PATCH 4/5] Added reference and updated version number. --- firefox_manifest.json | 2 +- manifest.json | 2 +- popup.js | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/firefox_manifest.json b/firefox_manifest.json index 7021c6ff..042acf13 100644 --- a/firefox_manifest.json +++ b/firefox_manifest.json @@ -1,7 +1,7 @@ { "name": "SponsorBlock - YouTube Sponsorship Blocker", "short_name": "SponsorBlock", - "version": "1.0.10", + "version": "1.0.11", "description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", "content_scripts": [ { diff --git a/manifest.json b/manifest.json index 8a397921..4cadb2fe 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "SponsorBlock - YouTube Sponsorship Blocker", "short_name": "SponsorBlock", - "version": "1.0.10", + "version": "1.0.11", "description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", "content_scripts": [ { diff --git a/popup.js b/popup.js index af754f2d..4526bfbe 100644 --- a/popup.js +++ b/popup.js @@ -1,4 +1,7 @@ + // References +var SB = {}; + SB.sponsorStart = document.getElementById("sponsorStart"); SB.clearTimes = document.getElementById("clearTimes"); SB.submitTimes = document.getElementById("submitTimes"); @@ -13,6 +16,7 @@ SB.reportAnIssue = document.getElementById("reportAnIssue"); SB.sponsorTimesContributionsContainer = document.getElementById("sponsorTimesContributionsContainer"); SB.sponsorTimesContributionsDisplay = document.getElementById("sponsorTimesContributionsDisplay"); SB.sponsorTimesContributionsDisplayEndWord = document.getElementById("sponsorTimesContributionsDisplayEndWord"); + //setup click listeners SB.sponsorStart.addEventListener("click", sendSponsorStartMessage); SB.clearTimes.addEventListener("click", clearTimes); From 71008319569ba94846257c11558f094f1af68b92 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sat, 27 Jul 2019 22:18:43 +0100 Subject: [PATCH 5/5] getYouTubeVideoID Video ID Parser --- content.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content.js b/content.js index 522fb810..6e5d27ef 100644 --- a/content.js +++ b/content.js @@ -676,5 +676,6 @@ function sendRequestToCustomServer(type, fullAddress, callback) { function getYouTubeVideoID(url) { // Returns with video id else returns false var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; var match = url.match(regExp); - return (match && match[7].length == 11) ? match[7] : false; + var id = new URL(url).searchParams.get("v"); + return (match && match[7].length == 11) ? id : false; }