CHAPTER_ENHANCEMENT_UI - Life-Experimentalist/NovelSynth GitHub Wiki
The Chapter Enhancement UI provides a streamlined interface for enhancing novel chapters with two prominent buttons for the most recently used actions and a dropdown menu for additional features.
- Two prominent buttons display the last 2 used enhancement actions
- Default actions: "Enhance" and "Summarize"
- Auto-reordering: When you use a different action, it becomes a primary button
- Persistent storage: Last used actions are remembered across sessions
- Additional actions available in "More Actions" dropdown
-
Current available actions:
- 🔍 Analyze - Analyze themes and writing style
- 💡 Suggestions - Get improvement suggestions
- 🌐 Translate - Translate to different language
- 📝 Grammar Check - Check and fix grammar issues
- 🎨 Style Check - Improve writing style
- 💬 Dialogue - Enhance dialogue quality
-
Chapter page detection: Automatically detects chapter pages using:
- URL patterns (
/chapter-\d+
,/ch-\d+
,/part-\d+
, etc.) - Novel website domains (fanfiction.net, royalroad.com, etc.)
- Content analysis (word count, structure)
- URL patterns (
- Fallback: Uses floating action button for non-chapter pages
- Smart insertion: Finds the best position to insert the UI
- Content-aware: Looks for chapter content containers
- Fallback positioning: Uses document body if no content area found
-
src/content/index.ts
- Added ChapterEnhancementUI integration
- Chapter page detection logic
- Content insertion point detection
- Action handling and mapping
-
src/utils/ChapterEnhancementUI.ts
- Complete UI implementation
- Action management and persistence
- Event handling
- Processing state management
-
src/styles/content.css
- Complete styling for the enhancement bar
- Responsive design with dark theme support
- Button and dropdown styling
-
manifest.json
- Added CSS file to content_scripts
-
webpack.config.js
- Added CSS copying to build process
class ChapterEnhancementUI {
// Create UI at specified insertion point
createUI(insertionPoint: InsertionPoint): HTMLElement
// Set callback for action events
setActionCallback(callback: (action: string) => void): void
// Show/hide processing state
showProcessing(actionLabel?: string): void
hideProcessing(): void
// Manage UI lifecycle
remove(): void
isVisible(): boolean
}
// Chapter detection
isChapterPage(): boolean
// UI creation
createChapterEnhancementUI(): void
createEnhancementUI(): void
// Action handling
handleChapterAction(action: string): Promise<void>
- Page Load: Content script analyzes the page
- Detection: Checks if it's a chapter page using multiple criteria
- UI Creation: Creates ChapterEnhancementUI if chapter detected
- Positioning: Finds best insertion point for the UI
- Event Handling: Sets up action callbacks
- Action Processing: Maps UI actions to existing enhancement logic
- State Management: Updates last used actions and persists to storage
A test page (test-chapter-ui.html
) is available that simulates a chapter page with:
- Proper chapter content structure
- Mock UI creation for standalone testing
- Action button functionality testing
- Dropdown menu interaction
- Improved Accessibility: No need to open dropdown for common actions
- Personalized Experience: UI adapts to user's most common actions
- Better UX: Prominent buttons for quick access
- Context Awareness: Only appears on relevant chapter pages
- Consistent Design: Matches extension's overall design language
- Customizable Actions: Allow users to configure which actions appear as primary buttons
- Keyboard Shortcuts: Add hotkeys for quick action triggering
- Action History: Show recent actions in a separate section
- Smart Suggestions: Recommend actions based on content type
- Batch Operations: Allow multiple actions on the same content