mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +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
|
//this allows the callback to be called later by the submitTimes function
|
||||||
return true;
|
return true;
|
||||||
} else if (request.message == "addSponsorTime") {
|
} else if (request.message == "addSponsorTime") {
|
||||||
addSponsorTime(request.time);
|
addSponsorTime(request.time, request.videoID);
|
||||||
} else if (request.message == "getSponsorTimes") {
|
} else if (request.message == "getSponsorTimes") {
|
||||||
getSponsorTimes(request.videoID, function(sponsorTimes) {
|
getSponsorTimes(request.videoID, function(sponsorTimes) {
|
||||||
callback({
|
callback({
|
||||||
@@ -69,22 +69,22 @@ function getSponsorTimes(videoID, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSponsorTime(time) {
|
function addSponsorTime(time, videoID) {
|
||||||
getSponsorTimes(previousVideoID, function(sponsorTimes) {
|
getSponsorTimes(videoID, function(sponsorTimes) {
|
||||||
//add to sponsorTimes
|
//add to sponsorTimes
|
||||||
if (sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) {
|
if (sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) {
|
||||||
//it is an end time
|
//it is an end time
|
||||||
sponsorTimes[sponsorTimes.length - 1][1] = parseInt(time);
|
sponsorTimes[sponsorTimes.length - 1][1] = time;
|
||||||
} else {
|
} else {
|
||||||
//it is a start time
|
//it is a start time
|
||||||
let sponsorTimesIndex = sponsorTimes.length;
|
let sponsorTimesIndex = sponsorTimes.length;
|
||||||
sponsorTimes[sponsorTimesIndex] = [];
|
sponsorTimes[sponsorTimesIndex] = [];
|
||||||
|
|
||||||
sponsorTimes[sponsorTimesIndex][0] = parseInt(time);
|
sponsorTimes[sponsorTimesIndex][0] = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
//save this info
|
//save this info
|
||||||
let sponsorTimeKey = "sponsorTimes" + previousVideoID;
|
let sponsorTimeKey = "sponsorTimes" + videoID;
|
||||||
chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
|
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) {
|
function videoIDChange(id) {
|
||||||
//reset last sponsor times
|
//reset last sponsor times
|
||||||
lastTime = -1;
|
lastTime = -1;
|
||||||
lastUnixTimeSkipped = -1;
|
lastUnixTimeSkipped = -1;
|
||||||
|
|
||||||
|
//reset sponsor times
|
||||||
|
sponsorTimes = undefined;
|
||||||
|
UUIDs = undefined;
|
||||||
|
|
||||||
//reset sponsor data found check
|
//reset sponsor data found check
|
||||||
sponsorDataFound = false;
|
sponsorDataFound = false;
|
||||||
sponsorsLookup(id);
|
sponsorsLookup(id);
|
||||||
@@ -250,11 +273,10 @@ function removePlayerControlsButton() {
|
|||||||
|
|
||||||
//adds or removes the player controls button to what it should be
|
//adds or removes the player controls button to what it should be
|
||||||
function updateVisibilityOfPlayerControlsButton() {
|
function updateVisibilityOfPlayerControlsButton() {
|
||||||
|
addPlayerControlsButton();
|
||||||
|
addSubmitButton();
|
||||||
if (hideVideoPlayerControls) {
|
if (hideVideoPlayerControls) {
|
||||||
removePlayerControlsButton();
|
removePlayerControlsButton();
|
||||||
} else {
|
|
||||||
addPlayerControlsButton();
|
|
||||||
addSubmitButton();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +286,8 @@ function startSponsorClicked() {
|
|||||||
//send back current time with message
|
//send back current time with message
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
message: "addSponsorTime",
|
message: "addSponsorTime",
|
||||||
time: v.currentTime
|
time: v.currentTime,
|
||||||
|
videoID: getYouTubeVideoID(document.URL)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,6 +593,13 @@ function sponsorMessageStarted() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submitSponsorTimes() {
|
function submitSponsorTimes() {
|
||||||
|
console.log("Tessst")
|
||||||
|
if (document.getElementById("submitButton").style.display == "none") {
|
||||||
|
//don't submit, not ready
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("Test")
|
||||||
|
|
||||||
//add loading animation
|
//add loading animation
|
||||||
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
|
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
|
||||||
document.getElementById("submitButton").style.animation = "rotate 1s 0s infinite";
|
document.getElementById("submitButton").style.animation = "rotate 1s 0s infinite";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "SponsorBlock - YouTube Sponsorship Blocker",
|
"name": "SponsorBlock - YouTube Sponsorship Blocker",
|
||||||
"short_name": "SponsorBlock",
|
"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.",
|
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "SponsorBlock - YouTube Sponsorship Blocker",
|
"name": "SponsorBlock - YouTube Sponsorship Blocker",
|
||||||
"short_name": "SponsorBlock",
|
"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.",
|
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -71,7 +71,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<button id="sponsorStart" class="greenButton">Sponsorship Starts Now</button>
|
<button id="sponsorStart" class="greenButton">Sponsorship Starts Now</button>
|
||||||
</div>
|
</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">
|
<div id="submissionSection" style="display: none">
|
||||||
<h3>Latest Sponsor Message Times Chosen</h3>
|
<h3>Latest Sponsor Message Times Chosen</h3>
|
||||||
<b>
|
<b>
|
||||||
|
|||||||
Reference in New Issue
Block a user