mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-11-07 12:47:02 +01:00
fix: disable sponsorblock on shorts (#135)
This commit is contained in:
parent
3fd6df8277
commit
37974389ac
@ -108,6 +108,7 @@ public enum SettingsEnum {
|
||||
SB_SHOW_BROWSER_BUTTON("sb-browser-button", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
|
||||
SB_API_URL("sb-api-url", "https://sponsor.ajay.app/api/", SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.STRING);
|
||||
|
||||
public static boolean shorts_playing = false;
|
||||
private final String path;
|
||||
private final Object defaultValue;
|
||||
private final SharedPrefHelper.SharedPrefNames sharedPref;
|
||||
@ -250,5 +251,4 @@ public enum SettingsEnum {
|
||||
public boolean shouldRebootOnChange() {
|
||||
return rebootApp;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -87,7 +87,9 @@ public class PlayerController {
|
||||
* Called when creating some kind of youtube internal player controlled, every time when new video starts to play
|
||||
*/
|
||||
public static void onCreate(final Object o) {
|
||||
// "Plugin.printStackTrace();
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
// "Plugin.printStackTrace();
|
||||
|
||||
if (o == null) {
|
||||
LogHelper.printException(PlayerController.class, "onCreate called with null object");
|
||||
@ -132,6 +134,8 @@ public class PlayerController {
|
||||
* Called when it's time to update the UI with new second, about once per second, only when playing, also in background
|
||||
*/
|
||||
public static void setCurrentVideoTime(long millis) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
LogHelper.debug(PlayerController.class, "setCurrentVideoTime: current video time: " + millis);
|
||||
VideoInformation.lastKnownVideoTime = millis;
|
||||
if (!SettingsEnum.SB_ENABLED.getBoolean()) return;
|
||||
@ -216,6 +220,8 @@ public class PlayerController {
|
||||
* Called very high frequency (once every about 100ms), also in background. It sometimes triggers when a video is paused (couple times in the row with the same value)
|
||||
*/
|
||||
public static void setCurrentVideoTimeHighPrecision(final long millis) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
if ((millis < lastKnownVideoTime && lastKnownVideoTime >= currentVideoLength) || millis == 0) {
|
||||
SponsorBlockUtils.showShieldButton(); // skipping from end to the video will show the buttons again
|
||||
SponsorBlockUtils.showVoteButton();
|
||||
@ -239,12 +245,16 @@ public class PlayerController {
|
||||
* Called before onDraw method on time bar object, sets video length in millis
|
||||
*/
|
||||
public static void setVideoLength(final long length) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
LogHelper.debug(PlayerController.class, "setVideoLength: length=" + length);
|
||||
currentVideoLength = length;
|
||||
}
|
||||
|
||||
|
||||
public static void setSponsorBarAbsoluteLeft(final Rect rect) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
setSponsorBarAbsoluteLeft(rect.left);
|
||||
}
|
||||
|
||||
@ -255,6 +265,8 @@ public class PlayerController {
|
||||
}
|
||||
|
||||
public static void setSponsorBarRect(final Object self) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
try {
|
||||
Field field = self.getClass().getDeclaredField("replaceMeWithsetSponsorBarRect");
|
||||
field.setAccessible(true);
|
||||
@ -269,6 +281,8 @@ public class PlayerController {
|
||||
}
|
||||
|
||||
public static void setSponsorBarAbsoluteRight(final Rect rect) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
setSponsorBarAbsoluteRight(rect.right);
|
||||
}
|
||||
|
||||
@ -279,6 +293,8 @@ public class PlayerController {
|
||||
}
|
||||
|
||||
public static void setSponsorBarThickness(final int thickness) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
setSponsorBarThickness((float) thickness);
|
||||
}
|
||||
|
||||
@ -296,6 +312,8 @@ public class PlayerController {
|
||||
|
||||
|
||||
public static void addSkipSponsorView15(final View view) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
playerActivity = new WeakReference<>((Activity) view.getContext());
|
||||
LogHelper.debug(PlayerController.class, "addSkipSponsorView15: view=" + view.toString());
|
||||
|
||||
@ -321,6 +339,8 @@ public class PlayerController {
|
||||
* Called when it's time to draw time bar
|
||||
*/
|
||||
public static void drawSponsorTimeBars(final Canvas canvas, final float posY) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
if (sponsorBarThickness < 0.1) return;
|
||||
if (sponsorSegmentsOfCurrentVideo == null) return;
|
||||
|
||||
|
@ -28,6 +28,8 @@ public class ShieldButton {
|
||||
static boolean isShowing;
|
||||
|
||||
public static void initialize(Object viewStub) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
try {
|
||||
LogHelper.debug(ShieldButton.class, "initializing shield button");
|
||||
|
||||
@ -62,10 +64,14 @@ public class ShieldButton {
|
||||
}
|
||||
|
||||
public static void changeVisibilityNegatedImmediate(boolean visible) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
changeVisibility(!visible, true);
|
||||
}
|
||||
|
||||
public static void changeVisibility(boolean visible) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
changeVisibility(visible, false);
|
||||
}
|
||||
|
||||
|
@ -403,6 +403,8 @@ public abstract class SponsorBlockUtils {
|
||||
}
|
||||
|
||||
public static String appendTimeWithoutSegments(String totalTime) {
|
||||
if (SettingsEnum.shorts_playing) return totalTime;
|
||||
|
||||
if (videoHasSegments && (SettingsEnum.SB_ENABLED.getBoolean() && SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getBoolean()) && !TextUtils.isEmpty(totalTime) && getCurrentVideoLength() > 1) {
|
||||
if (timeWithoutSegments.isEmpty()) {
|
||||
timeWithoutSegments = getTimeWithoutSegments(sponsorSegmentsOfCurrentVideo);
|
||||
|
@ -27,6 +27,8 @@ public class VotingButton {
|
||||
static boolean isShowing;
|
||||
|
||||
public static void initialize(Object viewStub) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
try {
|
||||
LogHelper.debug(VotingButton.class, "initializing voting button");
|
||||
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
||||
@ -60,10 +62,14 @@ public class VotingButton {
|
||||
}
|
||||
|
||||
public static void changeVisibilityNegatedImmediate(boolean visible) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
changeVisibility(!visible, true);
|
||||
}
|
||||
|
||||
public static void changeVisibility(boolean visible) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
changeVisibility(visible, false);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import android.widget.RelativeLayout;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.sponsorblock.player.PlayerType;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
@ -22,6 +23,8 @@ public class SponsorBlockView {
|
||||
static boolean shouldShowOnPlayerType = true;
|
||||
|
||||
public static void initialize(Object viewGroup) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
try {
|
||||
LogHelper.debug(SponsorBlockView.class, "initializing");
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package app.revanced.integrations.videoplayer;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
|
||||
public class VideoInformation {
|
||||
@ -14,6 +15,8 @@ public class VideoInformation {
|
||||
|
||||
// Call hook in the YT code when the video changes
|
||||
public static void setCurrentVideoId(final String videoId) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
if (videoId == null) {
|
||||
LogHelper.debug(VideoInformation.class, "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId);
|
||||
clearInformation(true);
|
||||
|
Loading…
Reference in New Issue
Block a user