mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 11:37:02 +03:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
808dfe42ce | ||
|
|
600365d998 | ||
|
|
504f0b0ede | ||
|
|
00877fb087 | ||
|
|
d654d8934b | ||
|
|
97e202dbd0 | ||
|
|
64be41b008 | ||
|
|
b3684a8730 | ||
|
|
45f0d65f69 | ||
|
|
5436a1651e | ||
|
|
33fe63084b |
@@ -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,22 +69,22 @@ 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
|
||||
sponsorTimes[sponsorTimes.length - 1][1] = parseInt(time);
|
||||
sponsorTimes[sponsorTimes.length - 1][1] = time;
|
||||
} else {
|
||||
//it is a start time
|
||||
let sponsorTimesIndex = sponsorTimes.length;
|
||||
sponsorTimes[sponsorTimesIndex] = [];
|
||||
|
||||
sponsorTimes[sponsorTimesIndex][0] = parseInt(time);
|
||||
sponsorTimes[sponsorTimesIndex][0] = time;
|
||||
}
|
||||
|
||||
//save this info
|
||||
let sponsorTimeKey = "sponsorTimes" + previousVideoID;
|
||||
let sponsorTimeKey = "sponsorTimes" + videoID;
|
||||
chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
|
||||
});
|
||||
}
|
||||
|
||||
38
content.js
38
content.js
@@ -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)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -570,6 +593,13 @@ function sponsorMessageStarted() {
|
||||
}
|
||||
|
||||
function submitSponsorTimes() {
|
||||
console.log("Tessst")
|
||||
if (document.getElementById("submitButton").style.display == "none") {
|
||||
//don't submit, not ready
|
||||
return;
|
||||
}
|
||||
console.log("Test")
|
||||
|
||||
//add loading animation
|
||||
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
|
||||
document.getElementById("submitButton").style.animation = "rotate 1s 0s infinite";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "SponsorBlock - YouTube Sponsorship Blocker",
|
||||
"short_name": "SponsorBlock",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.10",
|
||||
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
|
||||
"content_scripts": [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "SponsorBlock - YouTube Sponsorship Blocker",
|
||||
"short_name": "SponsorBlock",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.10",
|
||||
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
|
||||
"content_scripts": [
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user