mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +03:00
Fixed formatting issues + previewBar not displaying.
Also changed the isSubmitButtonLoaded function to be checking for the right button and fixed the startSponsorButton not hiding. Useless function was removed.
This commit is contained in:
34
content.js
34
content.js
@@ -206,28 +206,31 @@ function resetValues() {
|
|||||||
sponsorLookupRetries = 0;
|
sponsorLookupRetries = 0;
|
||||||
|
|
||||||
//empty the preview bar
|
//empty the preview bar
|
||||||
previewBar = null;
|
previewBar.set([], [], 0);
|
||||||
|
|
||||||
//reset sponsor data found check
|
//reset sponsor data found check
|
||||||
sponsorDataFound = false;
|
sponsorDataFound = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function videoIDChange(id) {
|
function videoIDChange(id) {
|
||||||
// ID has not changed return
|
//if the id has not changed return
|
||||||
if (sponsorVideoID === id) return
|
if (sponsorVideoID === id) return
|
||||||
// Global ID
|
|
||||||
|
//set the global videoID
|
||||||
sponsorVideoID = id;
|
sponsorVideoID = id;
|
||||||
resetValues();
|
|
||||||
|
|
||||||
// ID is not valid
|
|
||||||
if (id === false) return;
|
|
||||||
|
|
||||||
|
//setup the preview bar
|
||||||
if (previewBar == null) {
|
if (previewBar == null) {
|
||||||
//create it
|
//create it
|
||||||
let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0];
|
let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0];
|
||||||
previewBar = new PreviewBar(progressBar);
|
previewBar = new PreviewBar(progressBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetValues();
|
||||||
|
|
||||||
|
//id is not valid
|
||||||
|
if (id === false) return;
|
||||||
|
|
||||||
//warn them if they had unsubmitted times
|
//warn them if they had unsubmitted times
|
||||||
if (previousVideoID != null) {
|
if (previousVideoID != null) {
|
||||||
//get the sponsor times from storage
|
//get the sponsor times from storage
|
||||||
@@ -256,9 +259,6 @@ function videoIDChange(id) {
|
|||||||
//close popup
|
//close popup
|
||||||
closeInfoMenu();
|
closeInfoMenu();
|
||||||
|
|
||||||
//see if there is a video start time
|
|
||||||
youtubeVideoStartTime = sponsorVideoID;
|
|
||||||
|
|
||||||
sponsorsLookup(id);
|
sponsorsLookup(id);
|
||||||
|
|
||||||
//make sure everything is properly added
|
//make sure everything is properly added
|
||||||
@@ -546,12 +546,14 @@ function reskipSponsorTime(UUID) {
|
|||||||
function removePlayerControlsButton() {
|
function removePlayerControlsButton() {
|
||||||
if (!sponsorVideoID) return;
|
if (!sponsorVideoID) return;
|
||||||
|
|
||||||
document.getElementById("changeStartSponsor").style.display = "none";
|
document.getElementById("startSponsorButton").style.display = "none";
|
||||||
document.getElementById("submitButton").style.display = "none";
|
document.getElementById("submitButton").style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
function createButton(baseID, title, callback, imageName, isDraggable=false) {
|
function createButton(baseID, title, callback, imageName, isDraggable=false) {
|
||||||
|
|
||||||
if (document.getElementById(baseID+"Button") != null) return;
|
if (document.getElementById(baseID+"Button") != null) return;
|
||||||
|
|
||||||
// Button HTML
|
// Button HTML
|
||||||
let newButton = document.createElement("button");
|
let newButton = document.createElement("button");
|
||||||
newButton.draggable = isDraggable;
|
newButton.draggable = isDraggable;
|
||||||
@@ -559,14 +561,17 @@ function createButton(baseID, title, callback, imageName, isDraggable=false) {
|
|||||||
newButton.className = "ytp-button playerButton";
|
newButton.className = "ytp-button playerButton";
|
||||||
newButton.setAttribute("title", chrome.i18n.getMessage(title));
|
newButton.setAttribute("title", chrome.i18n.getMessage(title));
|
||||||
newButton.addEventListener("click", callback);
|
newButton.addEventListener("click", callback);
|
||||||
|
|
||||||
// Image HTML
|
// Image HTML
|
||||||
let newButtonImage = document.createElement("img");
|
let newButtonImage = document.createElement("img");
|
||||||
newButton.draggable = isDraggable;
|
newButton.draggable = isDraggable;
|
||||||
newButtonImage.id = baseID+"Image";
|
newButtonImage.id = baseID+"Image";
|
||||||
newButtonImage.className = "playerButtonImage";
|
newButtonImage.className = "playerButtonImage";
|
||||||
newButtonImage.src = chrome.extension.getURL("icons/"+imageName);
|
newButtonImage.src = chrome.extension.getURL("icons/"+imageName);
|
||||||
|
|
||||||
// Append image to button
|
// Append image to button
|
||||||
newButton.appendChild(newButtonImage);
|
newButton.appendChild(newButtonImage);
|
||||||
|
|
||||||
// Add the button to player
|
// Add the button to player
|
||||||
controls.prepend(newButton);
|
controls.prepend(newButton);
|
||||||
}
|
}
|
||||||
@@ -638,11 +643,14 @@ function updateSponsorTimesSubmitting() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isSubmitLoaded = () => (document.getElementById("startSponsorImage") !== null);
|
//is the submit button on the player loaded yet
|
||||||
|
function isSubmitButtonLoaded() {
|
||||||
|
return document.getElementById("submitButton") !== null;
|
||||||
|
}
|
||||||
|
|
||||||
function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
|
function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
|
||||||
if(!sponsorVideoID) return false;
|
if(!sponsorVideoID) return false;
|
||||||
wait(isSubmitLoaded).then(result => {
|
wait(isSubmitButtonLoaded).then(result => {
|
||||||
//if it isn't visible, there is no data
|
//if it isn't visible, there is no data
|
||||||
let shouldHide = (uploadButtonVisible && !hideDeleteButtonPlayerControls) ? "unset":"none"
|
let shouldHide = (uploadButtonVisible && !hideDeleteButtonPlayerControls) ? "unset":"none"
|
||||||
document.getElementById("deleteButton").style.display = shouldHide;
|
document.getElementById("deleteButton").style.display = shouldHide;
|
||||||
|
|||||||
10
utils.js
10
utils.js
@@ -39,13 +39,3 @@ function getYouTubeVideoID(url) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns the start time of the video if there was one specified (ex. ?t=5s)
|
|
||||||
function getYouTubeVideoStartTime(url) {
|
|
||||||
let searchParams = new URL(url).searchParams;
|
|
||||||
let startTime = searchParams.get("t");
|
|
||||||
if (startTime == null) {
|
|
||||||
startTime = searchParams.get("time_continue");
|
|
||||||
}
|
|
||||||
return startTime;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user