aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render/CategoryPill.tsx10
-rw-r--r--src/utils/pageUtils.ts5
2 files changed, 8 insertions, 7 deletions
diff --git a/src/render/CategoryPill.tsx b/src/render/CategoryPill.tsx
index 266796d1..af4f3f1b 100644
--- a/src/render/CategoryPill.tsx
+++ b/src/render/CategoryPill.tsx
@@ -1,5 +1,6 @@
import * as React from "react";
import * as ReactDOM from "react-dom";
+import { createRoot, Root } from "react-dom/client";
import CategoryPillComponent, { CategoryPillState } from "../components/CategoryPillComponent";
import Config from "../config";
import { VoteResponse } from "../messageTypes";
@@ -10,6 +11,7 @@ import { Tooltip } from "./Tooltip";
export class CategoryPill {
container: HTMLElement;
ref: React.RefObject<CategoryPillComponent>;
+ root: Root;
unsavedState: CategoryPillState;
@@ -38,10 +40,8 @@ export class CategoryPill {
this.unsavedState = this.ref.current.state;
}
- ReactDOM.render(
- <CategoryPillComponent ref={this.ref} vote={vote} />,
- this.container
- );
+ this.root = createRoot(this.container);
+ this.root.render(<CategoryPillComponent ref={this.ref} vote={vote} />);
if (this.unsavedState) {
this.ref.current?.setState(this.unsavedState);
@@ -64,7 +64,7 @@ export class CategoryPill {
}
close(): void {
- ReactDOM.unmountComponentAtNode(this.container);
+ this.root.unmount();
this.container.remove();
}
diff --git a/src/utils/pageUtils.ts b/src/utils/pageUtils.ts
index d753752c..db18aae7 100644
--- a/src/utils/pageUtils.ts
+++ b/src/utils/pageUtils.ts
@@ -70,7 +70,8 @@ export function getExistingChapters(currentVideoID: VideoID, duration: number):
const chaptersBox = document.querySelector("ytd-macro-markers-list-renderer");
const chapters: SponsorTime[] = [];
- if (chaptersBox) {
+ // .ytp-timed-markers-container indicates that key-moments are present, which should not be divided
+ if (chaptersBox && !(document.querySelector(".ytp-timed-markers-container")?.childElementCount > 0)) {
let lastSegment: SponsorTime = null;
const links = chaptersBox.querySelectorAll("ytd-macro-markers-list-item-renderer > a");
for (const link of links) {
@@ -78,7 +79,7 @@ export function getExistingChapters(currentVideoID: VideoID, duration: number):
const description = link.querySelector("#details h4") as HTMLElement;
if (timeElement && description?.innerText?.length > 0 && link.getAttribute("href")?.includes(currentVideoID)) {
const time = GenericUtils.getFormattedTimeToSeconds(timeElement.innerText);
- if (!time) return [];
+ if (time === null) return [];
if (lastSegment) {
lastSegment.segment[1] = time;