mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 21:47:06 +03:00
Fix mobile support
This commit is contained in:
@@ -293,12 +293,18 @@ async function videoIDChange(id) {
|
|||||||
if (onMobileYouTube) {
|
if (onMobileYouTube) {
|
||||||
// Mobile YouTube workaround
|
// Mobile YouTube workaround
|
||||||
const observer = new MutationObserver(handleMobileControlsMutations);
|
const observer = new MutationObserver(handleMobileControlsMutations);
|
||||||
|
let controlsContainer = null;
|
||||||
|
|
||||||
observer.observe(document.getElementById("player-control-container"), {
|
utils.wait(() => {
|
||||||
attributes: true,
|
controlsContainer = document.getElementById("player-control-container")
|
||||||
childList: true,
|
return controlsContainer !== null
|
||||||
subtree: true
|
}).then(() => {
|
||||||
});
|
observer.observe(document.getElementById("player-control-container"), {
|
||||||
|
attributes: true,
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
}).catch();
|
||||||
} else {
|
} else {
|
||||||
utils.wait(getControls).then(createPreviewBar);
|
utils.wait(getControls).then(createPreviewBar);
|
||||||
}
|
}
|
||||||
@@ -354,18 +360,6 @@ async function videoIDChange(id) {
|
|||||||
function handleMobileControlsMutations(): void {
|
function handleMobileControlsMutations(): void {
|
||||||
const mobileYouTubeSelector = ".progress-bar-background";
|
const mobileYouTubeSelector = ".progress-bar-background";
|
||||||
|
|
||||||
updateVisibilityOfPlayerControlsButton().then((createdButtons) => {
|
|
||||||
if (createdButtons) {
|
|
||||||
if (sponsorTimesSubmitting != null && sponsorTimesSubmitting.length > 0 && sponsorTimesSubmitting[sponsorTimesSubmitting.length - 1].segment.length >= 2) {
|
|
||||||
changeStartSponsorButton(true, true);
|
|
||||||
} else if (sponsorTimesSubmitting != null && sponsorTimesSubmitting.length > 0 && sponsorTimesSubmitting[sponsorTimesSubmitting.length - 1].segment.length < 2) {
|
|
||||||
changeStartSponsorButton(false, true);
|
|
||||||
} else {
|
|
||||||
changeStartSponsorButton(true, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (previewBar !== null) {
|
if (previewBar !== null) {
|
||||||
if (document.body.contains(previewBar.container)) {
|
if (document.body.contains(previewBar.container)) {
|
||||||
updatePreviewBarPositionMobile(document.getElementsByClassName(mobileYouTubeSelector)[0] as HTMLElement);
|
updatePreviewBarPositionMobile(document.getElementsByClassName(mobileYouTubeSelector)[0] as HTMLElement);
|
||||||
@@ -1133,6 +1127,7 @@ async function updateVisibilityOfPlayerControlsButton(): Promise<boolean> {
|
|||||||
if (!sponsorVideoID) return false;
|
if (!sponsorVideoID) return false;
|
||||||
|
|
||||||
const createdButtons = await createButtons();
|
const createdButtons = await createButtons();
|
||||||
|
if (!createdButtons) return;
|
||||||
|
|
||||||
if (Config.config.hideVideoPlayerControls || onInvidious) {
|
if (Config.config.hideVideoPlayerControls || onInvidious) {
|
||||||
document.getElementById("startSponsorButton").style.display = "none";
|
document.getElementById("startSponsorButton").style.display = "none";
|
||||||
@@ -1226,7 +1221,7 @@ function updateSponsorTimesSubmitting(getFromConfig = true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function changeStartSponsorButton(showStartSponsor: boolean, uploadButtonVisible: boolean): Promise<boolean> {
|
async function changeStartSponsorButton(showStartSponsor: boolean, uploadButtonVisible: boolean): Promise<boolean> {
|
||||||
if(!sponsorVideoID) return false;
|
if(!sponsorVideoID || onMobileYouTube) return false;
|
||||||
|
|
||||||
//if it isn't visible, there is no data
|
//if it isn't visible, there is no data
|
||||||
const shouldHide = (uploadButtonVisible && !(Config.config.hideDeleteButtonPlayerControls || onInvidious)) ? "unset" : "none"
|
const shouldHide = (uploadButtonVisible && !(Config.config.hideDeleteButtonPlayerControls || onInvidious)) ? "unset" : "none"
|
||||||
|
|||||||
Reference in New Issue
Block a user