Compare commits

...

8 Commits

Author SHA1 Message Date
Ajay Ramachandran
64be41b008 Merge pull request #25 from ajayyy/experimental
Fixed old unsponsored times sometimes being used
2019-07-26 20:26:29 -04:00
Ajay Ramachandran
b3684a8730 Added hint about the hotkey. 2019-07-26 20:23:13 -04:00
Ajay Ramachandran
45f0d65f69 Fixed old unsponsored times sometimes being used. 2019-07-26 20:19:51 -04:00
Ajay Ramachandran
5436a1651e Merge pull request #9 from ajayyy/experimental
Added support for hotkeys to submit data
2019-07-26 16:24:11 -04:00
Ajay Ramachandran
33fe63084b Added support for hotkeys to submit data. 2019-07-26 16:20:07 -04:00
Ajay Ramachandran
8f47513c98 Merge pull request #8 from ajayyy/experimental
Added quick fix for changing UUID when submitting two times
2019-07-26 14:21:50 -04:00
Ajay Ramachandran
7a17cc2b0a Updated version number. 2019-07-26 14:19:21 -04:00
Ajay Ramachandran
c7cb845d8a Added quick fix for changing UUID when submitting two times. 2019-07-26 14:19:01 -04:00
5 changed files with 42 additions and 11 deletions

View File

@@ -36,7 +36,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
//this allows the callback to be called later by the submitTimes function
return true;
} else if (request.message == "addSponsorTime") {
addSponsorTime(request.time);
addSponsorTime(request.time, request.videoID);
} else if (request.message == "getSponsorTimes") {
getSponsorTimes(request.videoID, function(sponsorTimes) {
callback({
@@ -69,8 +69,8 @@ function getSponsorTimes(videoID, callback) {
});
}
function addSponsorTime(time) {
getSponsorTimes(previousVideoID, function(sponsorTimes) {
function addSponsorTime(time, videoID) {
getSponsorTimes(videoID, function(sponsorTimes) {
//add to sponsorTimes
if (sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) {
//it is an end time
@@ -84,7 +84,7 @@ function addSponsorTime(time) {
}
//save this info
let sponsorTimeKey = "sponsorTimes" + previousVideoID;
let sponsorTimeKey = "sponsorTimes" + videoID;
chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
});
}
@@ -198,6 +198,12 @@ function getUserID(callback) {
userID = userIDStorage;
callback(userID);
} else {
//double check if a UUID hasn't been created since this was first called
if (userID != null) {
callback(userID);
return;
}
//generate a userID
userID = generateUUID();

View File

@@ -97,11 +97,34 @@ chrome.runtime.onMessage.addListener( // Detect URL Changes
}
});
//check for hotkey pressed
document.onkeydown = function(e){
e = e || window.event;
var key = e.which || e.keyCode;
let video = document.getElementById("movie_player");
//is the video in focus, otherwise they could be typing a comment
if (document.activeElement === video) {
if(key == 186){
//semicolon
startSponsorClicked();
} else if (key == 222) {
//single quote
submitSponsorTimes();
}
}
}
function videoIDChange(id) {
//reset last sponsor times
lastTime = -1;
lastUnixTimeSkipped = -1;
//reset sponsor times
sponsorTimes = undefined;
UUIDs = undefined;
//reset sponsor data found check
sponsorDataFound = false;
sponsorsLookup(id);
@@ -250,11 +273,10 @@ function removePlayerControlsButton() {
//adds or removes the player controls button to what it should be
function updateVisibilityOfPlayerControlsButton() {
addPlayerControlsButton();
addSubmitButton();
if (hideVideoPlayerControls) {
removePlayerControlsButton();
} else {
addPlayerControlsButton();
addSubmitButton();
}
}
@@ -264,7 +286,8 @@ function startSponsorClicked() {
//send back current time with message
chrome.runtime.sendMessage({
message: "addSponsorTime",
time: v.currentTime
time: v.currentTime,
videoID: getYouTubeVideoID(document.URL)
});
}

View File

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

View File

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

View File

@@ -71,7 +71,9 @@
<div>
<button id="sponsorStart" class="greenButton">Sponsorship Starts Now</button>
</div>
<sub>Hint: Press the semicolon key while focused on a video report the start/end of a sponsor and quote to submit.</sub>
<div id="submissionSection" style="display: none">
<h3>Latest Sponsor Message Times Chosen</h3>
<b>