From 9bc2ef291649afe276dc3f97e4f8bd317126d99b Mon Sep 17 00:00:00 2001 From: "NGOCDG280\\ngocdg" Date: Wed, 27 Nov 2024 20:52:08 +0700 Subject: [PATCH] fix: ToC item title --- docs/changelog.md | 6 ++++++ package.json | 2 +- src/content-script/hooks/useThreadTocObserver.ts | 13 ++++--------- src/utils/DomSelectors.ts | 1 + 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 9cc6bd88..13672753 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -12,6 +12,12 @@ Consider giving a star ⭐ on [Github](https://github.com/pnd280/complexity). --- +## v0.0.5.18 + +_Release date: 27th Nov, 2024_ + +- **FIX**: Fixed Thread ToC title retrieval. + ## v0.0.5.16 _Release date: 23rd Nov, 2024_ diff --git a/package.json b/package.json index 23653e28..df199fc7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "complexity", "displayName": "Complexity - Perplexity AI Supercharged", - "version": "0.0.5.17", + "version": "0.0.5.18", "author": "pnd280", "description": "⚡ Supercharge your Perplexity AI", "type": "module", diff --git a/src/content-script/hooks/useThreadTocObserver.ts b/src/content-script/hooks/useThreadTocObserver.ts index 32c320af..bf9c0036 100644 --- a/src/content-script/hooks/useThreadTocObserver.ts +++ b/src/content-script/hooks/useThreadTocObserver.ts @@ -8,7 +8,7 @@ import throttle from "lodash/throttle"; import { AnchorProps } from "@/content-script/components/ThreadToc"; import useRouter from "@/content-script/hooks/useRouter"; import { useCanvasStore } from "@/content-script/session-store/canvas"; -import { DomHelperSelectors } from "@/utils/DomSelectors"; +import { DomSelectors } from "@/utils/DomSelectors"; import UiUtils from "@/utils/UiUtils"; import { scrollToElement } from "@/utils/utils"; @@ -60,14 +60,9 @@ export default function useThreadTocObserver() { $messageBlocks.forEach(({ $query, $answer, $messageBlock }) => { queueMicrotask(() => { - const title = - $query.find("textarea").val() || - $query - .find( - `>*:not(${DomHelperSelectors.THREAD.MESSAGE.TEXT_COL_CHILD.MARKDOWN_QUERY}):not(.tw-sticky)`, - ) - .first() - .text(); + const title = $query + .find(DomSelectors.THREAD.MESSAGE.TEXT_COL_CHILD.QUERY_TITLE) + .text(); if (!title.length) return; diff --git a/src/utils/DomSelectors.ts b/src/utils/DomSelectors.ts index 4bfcc2b4..cd6ab9c0 100644 --- a/src/utils/DomSelectors.ts +++ b/src/utils/DomSelectors.ts @@ -19,6 +19,7 @@ const DomSelectors = { TEXT_COL_CHILD: { /** The query box */ QUERY: ".my-md.md\\:my-lg", + QUERY_TITLE: ".group\\/title>:last-child", /** The answer box */ ANSWER: ".mb-md", /** The answer heading */