Skip to content

Commit

Permalink
Remove live or premiere video support
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Sep 14, 2024
1 parent 614dfd8 commit 60b0dbb
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 30 deletions.
3 changes: 0 additions & 3 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,6 @@
"shortCheck": {
"message": "以下的提交短于您的最小持续时间选项。这代表它们可能已经被提交,只是由于该选项被忽略了。您确定要提交吗?"
},
"liveOrPremiere": {
"message": "无法在进行中的直播或首播提交片段。请等待直播结束后刷新页面并确认片段仍然有效,再次提交。"
},
"customServerAddress": {
"message": "空降助手服务器地址"
},
Expand Down
3 changes: 0 additions & 3 deletions public/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,6 @@
"shortCheck": {
"message": "以下的提交短于您的最小持续时间选项。这代表它们可能已经被提交,只是由于该选项被忽略了。您确定要提交吗?"
},
"liveOrPremiere": {
"message": "无法在进行中的直播或首播提交片段。请等待直播结束后刷新页面并确认片段仍然有效,再次提交。"
},
"customServerAddress": {
"message": "空降助手服务器地址"
},
Expand Down
3 changes: 0 additions & 3 deletions public/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,6 @@
"shortCheck": {
"message": "以下的提交短於您的最小持續時間選項。這代表它們可能已經被提交,只是由於該選項被忽略了。您確定要提交嗎?"
},
"liveOrPremiere": {
"message": "無法在進行中的直播或首播提交片段。請等待直播結束後刷新頁面並確認片段仍然有效,再次提交。"
},
"customServerAddress": {
"message": "Bilibili Sponsor Block伺服器地址"
},
Expand Down
13 changes: 3 additions & 10 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { getErrorMessage, getFormattedTime } from "./utils/formating";
import { GenericUtils } from "./utils/genericUtils";
import { getHash, HashedValue } from "./utils/hash";
import { logDebug } from "./utils/logger";
import { getControls, getHashParams, getProgressBar, isPlayingPlaylist, isVisible } from "./utils/pageUtils";
import { getControls, getHashParams, getProgressBar, isPlayingPlaylist } from "./utils/pageUtils";
import { getBilibiliVideoID } from "./utils/parseVideoID";
import { generateUserID } from "./utils/setup";
import { getStartTimeFromUrl } from "./utils/urlParser";
Expand All @@ -54,12 +54,11 @@ import {
checkVideoIDChange,
detectPageType,
getChannelIDInfo,
updateFrameRate,
getIsLivePremiere,
getPageType,
getVideo,
getVideoID,
setupVideoModule,
updateFrameRate
} from "./utils/video";
import { openWarningDialog } from "./utils/warnings";

Expand Down Expand Up @@ -2277,13 +2276,7 @@ function submitSegments() {
//send the message to the background js
//called after all the checks have been made that it's okay to do so
async function sendSubmitMessage(): Promise<boolean> {
// check if all segments are full video
const onlyFullVideo = sponsorTimesSubmitting.every((segment) => segment.actionType === ActionType.Full);
// Block if submitting on a running livestream or premiere
if (!onlyFullVideo && (getIsLivePremiere() || isVisible(document.querySelector(".ytp-live-badge")))) {
showMessage(chrome.i18n.getMessage("liveOrPremiere"), "warning");
return false;
}
// TODO: add checks for premiere videos

if (
!previewedSegment &&
Expand Down
11 changes: 0 additions & 11 deletions src/utils/video.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as documentScript from "../../dist/js/document.js";
import Config from "../config";
import { isSafari } from "../config/config";
import { newThumbnails } from "../thumbnail-utils/thumbnailManagement";
import { PageType } from "../types";
import { waitFor } from "./";
Expand Down Expand Up @@ -31,9 +30,6 @@ let videoMutationListenerElement: HTMLElement | null = null;
const videosSetup: HTMLVideoElement[] = [];
let waitingForNewVideo = false;

// if video is live or premiere
let isLivePremiere: boolean;

let videoID: VideoID | null = null;
let pageType: PageType = PageType.Unknown;
let channelIDInfo: ChannelIDInfo;
Expand Down Expand Up @@ -159,7 +155,6 @@ function resetValues() {
status: ChannelIDStatus.Fetching,
id: null,
};
isLivePremiere = false;

// Reset the last media session link
window.postMessage(
Expand Down Expand Up @@ -357,8 +352,6 @@ function windowListenerHandler(event: MessageEvent): void {
void videoIDChange(data.videoID);
} else if (dataType === "data" && data.videoID) {
void videoIDChange(data.videoID);

isLivePremiere = data.isLive || data.isPremiere;
} else if (dataType === "newElement") {
newThumbnails();
}
Expand Down Expand Up @@ -415,10 +408,6 @@ export function getChannelIDInfo(): ChannelIDInfo {
return channelIDInfo;
}

export function getIsLivePremiere(): boolean {
return isLivePremiere;
}

export function getPageType(): PageType {
return pageType;
}

0 comments on commit 60b0dbb

Please sign in to comment.