Skip to content

Commit 057d509

Browse files
committed
Better documentation.
1 parent 0b90919 commit 057d509

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

code-notes.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
This document provides a high-level overview of the OneClickPrompts Chrome Extension codebase. It describes the purpose of each file and its role within the extension. Extension was previously called "ChatGPT Quick Buttons for your text".
44

5-
65
## Core Functionality
76

87
The OneClickPrompts extension enhances AI chat platforms like ChatGPT, Claude, Copilot, DeepSeek, AI Studio, and Grok by adding customizable buttons that inject pre-defined prompts into the chat input area. It also includes features for managing profiles, enabling keyboard shortcuts, and customizing the user interface.
@@ -16,8 +15,22 @@ The OneClickPrompts extension enhances AI chat platforms like ChatGPT, Claude, C
1615

1716
### `config.js`
1817

19-
* **Purpose:** Service worker responsible for managing the extension's configuration data using Chrome's storage API.
20-
* **Role:** Handles loading, saving, switching, creating, deleting, and listing profiles. Also manages settings like dark theme and floating panel state. This file is the central source of truth for all configurable extension settings.
18+
* **Purpose:** Service worker script that manages extension configuration and settings.
19+
* **Role:** Handles message passing between content scripts, popup pages, and storage. Key responsibilities:
20+
* Acts as a central hub for configuration management
21+
* Stores and retrieves button configurations in Chrome storage
22+
* Manages profiles (saving, loading, deleting)
23+
* Handles custom selector configurations
24+
* Manages floating panel settings across different websites
25+
* Provides unified storage for all extension settings
26+
* Implements reset functionality for various setting types
27+
* **Message Handlers:**
28+
* Processes messages from content scripts and popup pages
29+
* Handles floating panel settings with message types:
30+
* 'getFloatingPanelSettings': Retrieves settings for a specific website
31+
* 'saveFloatingPanelSettings': Saves settings for a specific website
32+
* 'resetFloatingPanelSettings': Removes all floating panel settings
33+
* Stores floating panel settings with the prefix 'floating_panel_' followed by the website hostname
2134

2235
### `default-config.json`
2336

@@ -43,11 +56,15 @@ The OneClickPrompts extension enhances AI chat platforms like ChatGPT, Claude, C
4356
* **Role:** Creates a draggable, resizable panel that can be toggled as an alternative to the inline injected buttons. Features include:
4457
* Dark, semi-transparent appearance (rgba(50, 50, 50, 0.7))
4558
* Positioning with the panel's bottom-left corner at the cursor location
46-
* Persistent state and position saved per website using localStorage
59+
* Persistent state and position saved per website using Chrome's extension storage via the service worker
4760
* Draggable header and resizable body
4861
* Toggle button in the original injected button container
4962
* Closing via an "x" button to return to the injected buttons
50-
* Debounced saving (150ms delay) for efficient localStorage operations
63+
* Debounced saving (150ms delay) for efficient storage operations
64+
* **Dependencies:**
65+
* **config.js (Service Worker):** Directly communicates with the service worker using `chrome.runtime.sendMessage` to save and load panel settings per website hostname. Sends messages with types 'getFloatingPanelSettings' and 'saveFloatingPanelSettings'.
66+
* **utils.js:** Uses utility functions for logging.
67+
* **profile-switcher.js:** For managing profile switching within the floating panel.
5168

5269
### `init.js`
5370

@@ -138,6 +155,18 @@ These scripts are responsible for the user interface in the extension's popup wi
138155
* **Purpose:** Handles the advanced selector configuration.
139156
* **Role:** Enables users to customize CSS selectors for different AI chat platforms.
140157

158+
### `popup-page-scripts/popup-page-floating-window-handler.js`
159+
160+
* **Purpose:** Handles the resetting of floating panel settings across all websites.
161+
* **Role:** Provides functionality for the "Reset Floating Window Settings" button in the Settings section of the popup interface. Features include:
162+
* Clearing all floating panel settings from Chrome's extension storage
163+
* Targeting only settings with the 'floating_panel_' prefix
164+
* Providing user feedback through console logs and toast notifications
165+
* Allowing panels to naturally reset to default positions and states on next page load
166+
* **Dependencies:**
167+
* **config.js (Service Worker):** Directly communicates with the service worker using `chrome.runtime.sendMessage` to reset all floating panel settings by sending a message with type 'resetFloatingPanelSettings'. The service worker handles finding and removing all relevant settings from Chrome's storage.
168+
* **popup.js:** Integrated with the popup interface to provide user feedback via toast notifications and console logging.
169+
141170
### `popup-page-styles/*`
142171

143172
* **Purpose:** Contains CSS files for styling the popup page.

0 commit comments

Comments
 (0)