Skip to content

Sumanth-nxt/perplexity-toc-navigation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Thread TOC Extension

A lightweight monolithic browser extension that adds a Table of Contents (TOC), Bookmarks and Cross Tab navigation to Perplexity AI thread pages Built using Complexity's Toc plugin logic, this extension enhances the original functionality by adding Bookmarks and Cross-Tab navigation.

##Demo

demo.mp4

Features

  • Automatic TOC Generation: Automatically detects message blocks and creates a navigable table of contents (for >=2 messages)
  • Bookmark: Remembers bookmarks across sessions and auto scrolls there
  • Cross tab Nav: Genrates an Overlay of Tocs of synced tabs (Max 5) for easy cross thread navigation.

Installation

Chrome/Edge (Developer Mode)

  1. Download or clone this repository
  2. Open Chrome/Edge and navigate to chrome://extensions/ (or edge://extensions/)
  3. Enable "Developer mode" in the top right corner
  4. Click "Load unpacked" and select the simple-toc-extension folder
  5. The extension should now be installed and active

How It Works

The extension follows the same architecture as the original thread-toc plugin but implemented in vanilla JavaScript:

Architecture Overview

┌─────────────────────────────────────────────────────────────────┐
│                    Extension Initialization                      │
├─────────────────────────────────────────────────────────────────┤
│ 1. Check if on Perplexity thread page                          │
│ 2. Initialize Zustand store for state management               │
│ 3. Set up DOM observers and intersection observers             │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                    DOM Observation & Detection                  │
├─────────────────────────────────────────────────────────────────┤
│ • MutationObserver watches for new message blocks              │
│ • IntersectionObserver tracks active/visible messages          │
│ • Extracts titles from message content                         │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                    State Management (Zustand)                   │
├─────────────────────────────────────────────────────────────────┤
│ • items: Array of TOC items with titles and elements           │
│ • activeId: Currently highlighted message                      │
│ • topMostId: Top-most visible message                          │
│ • isFloating: Whether TOC is in floating mode                  │
│ • position: Calculated position for TOC placement              │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                    UI Rendering & Interaction                   │
├─────────────────────────────────────────────────────────────────┤
│ • Renders TOC container with message list                      │
│ • Handles click events for navigation                          │
│ • Manages floating toggle button                               │
│ • Responsive positioning and styling                           │
└─────────────────────────────────────────────────────────────────┘

Key Components

  1. State Management: Utilizes Zustand for managing the extension's state, including TOC items, active states, UI configurations, bookmarks, and cross-tab data.
  2. DOM Observers: Employs MutationObserver for detecting changes in thread content and IntersectionObserver for tracking message visibility, enabling dynamic TOC updates.
  3. Bookmark Feature: Manages saving, retrieving, and navigating to bookmarked messages within a thread, persisting across sessions.
  4. Cross-Tab Navigation: Facilitates navigation between synced Perplexity AI tabs by generating an overlay of TOCs from active synced tabs.
  5. Chrome API Handling: Includes mechanisms to manage and mitigate potential delays and rate limits associated with Chrome API interactions for smooth performance.

Usage

  1. Navigate to any Perplexity AI search result page (e.g., https://www.perplexity.ai/search/...)
  2. The TOC will automatically appear when there are 2 or more messages in the thread.
  3. TOC Navigation: Click any item in the Table of Contents to automatically scroll to the corresponding message in the thread.
  4. Bookmark: Click the bookmark icon next to a message in the TOC to save its position. The extension will remember your bookmark across sessions and automatically scroll to it when you revisit the thread.
  5. Sync Specific Tab: A sync button will appear for each tab in the cross-tab view. Click this button to highlight the specific tab in blue, indicating it's the active tab you're navigating from.
  6. Cross-Tab Navigation: Click the cross-tab button to reveal an overlay displaying TOCs from other synced Perplexity AI tabs, allowing for easy navigation between different threads.

Technical Details

Dependencies

  • Zustand: Lightweight state management library (included via CDN)
  • Vanilla JavaScript: No framework dependencies

Development

To modify or extend the extension: Make changes to necessary functions or add

  1. Make changes to the source files
  2. Reload the extension in your browser's extension management page
  3. Refresh any Perplexity pages to see changes

File Structure

simple-toc-extension/
├── manifest.json      # Extension configuration
├── content.js         # Main extension logic - Monolith code 
├── styles.css         # Styling and animations
├── zustand.min.js     # State management library
└── README.md          # This file

License

This extension, including its added features (Bookmarks, Cross Tab navigation), is provided under the MIT License. It is supplied "as-is" without any warranties, and the author is not responsible for any damages arising from its use. Please refer to the original Complexity project for its licensing terms regarding the core TOC logic.

Contributing

Feel free to improve the extension as your own , I'll try my best to fix the bugs when free.

References

https://github.com/pnd280/complexity https://uiverse.io/JulanDeAlb/tall-swan-6 (cross tab button) https://uiverse.io/PriyanshuGupta28/chilly-lion-59 (sync button)

About

Perplexity web extension with Cross Tab Thread Table of Contents with Bookmark

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published