Compare commits

..

8 Commits

Author SHA1 Message Date
Ajay Ramachandran
137ba895bb Merge pull request #110 from ajayyy/experimental
Update master
2019-08-13 13:06:10 -04:00
Ajay Ramachandran
ecc48de396 Merge pull request #109 from ajayyy/experimental-ajay
Fixed preview bar
2019-08-13 13:05:52 -04:00
Ajay Ramachandran
aa95687b56 Update version number 2019-08-13 13:03:08 -04:00
Ajay Ramachandran
a8147738ef Raised retry limit for when the server is down. 2019-08-13 13:02:54 -04:00
Ajay Ramachandran
4a3d36b952 Fixed preview bar.
Made it reset when no sponsors are found.

Made it wait until the video metadata is loaded if necessary.
2019-08-13 13:02:35 -04:00
Ajay Ramachandran
f9bd82db35 Merge pull request #103 from OfficialNoob/patch-20
Added switch for chrome.runtime.onMessage
2019-08-13 00:32:43 -04:00
Ajay Ramachandran
c8438b9d59 Updated formatting 2019-08-13 00:32:33 -04:00
Official Noob
44c4671977 Added switch for chrome.runtime.onMessage 2019-08-12 17:41:26 +01:00
3 changed files with 55 additions and 35 deletions

View File

@@ -5,38 +5,39 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
}); });
chrome.runtime.onMessage.addListener(function (request, sender, callback) { chrome.runtime.onMessage.addListener(function (request, sender, callback) {
if (request.message == "submitTimes") { switch(request.message) {
submitTimes(request.videoID, callback); case "submitTimes":
submitTimes(request.videoID, callback);
//this allows the callback to be called later by the submitTimes function
return true; //this allows the callback to be called later by the submitTimes function
} else if (request.message == "addSponsorTime") { return true;
addSponsorTime(request.time, request.videoID, callback); case "addSponsorTime":
addSponsorTime(request.time, request.videoID, callback);
//this allows the callback to be called later
return true; //this allows the callback to be called later
} else if (request.message == "getSponsorTimes") { return true;
getSponsorTimes(request.videoID, function(sponsorTimes) { case "getSponsorTimes":
callback({ getSponsorTimes(request.videoID, function(sponsorTimes) {
sponsorTimes: sponsorTimes callback({
}) sponsorTimes: sponsorTimes
}); })
});
//this allows the callback to be called later
return true; //this allows the callback to be called later
} else if (request.message == "submitVote") { return true;
submitVote(request.type, request.UUID, callback); case "submitVote":
submitVote(request.type, request.UUID, callback);
//this allows the callback to be called later
return true; //this allows the callback to be called later
} else if (request.message == "alertPrevious") { return true;
chrome.notifications.create("stillThere" + Math.random(), { case "alertPrevious":
type: "basic", chrome.notifications.create("stillThere" + Math.random(), {
title: "Do you want to submit the sponsor times for video id " + request.previousVideoID + "?", type: "basic",
message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).", title: "Do you want to submit the sponsor times for video id " + request.previousVideoID + "?",
iconUrl: "./icons/LogoSponsorBlocker256px.png" message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).",
}); iconUrl: "./icons/LogoSponsorBlocker256px.png"
} });
}
}); });
//add help page on install //add help page on install

View File

@@ -16,6 +16,8 @@ var youtubeVideoStartTime = null;
//the video //the video
var v; var v;
var listenerAdded;
//the channel this video is about //the channel this video is about
var channelURL; var channelURL;
@@ -241,6 +243,9 @@ function videoIDChange(id) {
sponsorVideoID = id; sponsorVideoID = id;
sponsorLookupRetries = 0; sponsorLookupRetries = 0;
//empty the preview bar
previewBar.set([], [], 0);
//see if there is a video start time //see if there is a video start time
youtubeVideoStartTime = getYouTubeVideoStartTime(document.URL); youtubeVideoStartTime = getYouTubeVideoStartTime(document.URL);
@@ -320,7 +325,14 @@ function sponsorsLookup(id) {
//update the preview bar //update the preview bar
//leave the type blank for now until categories are added //leave the type blank for now until categories are added
previewBar.set(sponsorTimes, [], v.duration); console.log(v.duration)
if (isNaN(v.duration)) {
//wait until it is loaded
v.addEventListener('durationchange', updatePreviewBar);
} else {
//set it now
updatePreviewBar();
}
getChannelID(); getChannelID();
@@ -342,7 +354,7 @@ function sponsorsLookup(id) {
}); });
sponsorLookupRetries = 0; sponsorLookupRetries = 0;
} else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 15) { } else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 90) {
//some error occurred, try again in a second //some error occurred, try again in a second
setTimeout(() => sponsorsLookup(id), 1000); setTimeout(() => sponsorsLookup(id), 1000);
@@ -356,6 +368,13 @@ function sponsorsLookup(id) {
}; };
} }
function updatePreviewBar() {
previewBar.set(sponsorTimes, [], v.duration);
//the listener is only needed once
v.removeEventListener('durationchange', updatePreviewBar);
}
function getChannelID() { function getChannelID() {
//get channel id //get channel id
let channelContainers = document.querySelectorAll("#owner-name"); let channelContainers = document.querySelectorAll("#owner-name");

View File

@@ -1,7 +1,7 @@
{ {
"name": "SponsorBlock for YouTube - Skip Sponsorships", "name": "SponsorBlock for YouTube - Skip Sponsorships",
"short_name": "SponsorBlock", "short_name": "SponsorBlock",
"version": "1.0.34", "version": "1.0.35",
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", "description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
"content_scripts": [ "content_scripts": [
{ {