|
1 | 1 | /* buttons.js |
2 | | - Version: 1.0 |
3 | | -
|
4 | | - Documentation: |
5 | | -
|
6 | | - This file is a dependency. Designed to host helper functions for init.js. Manages the creation and functionality of custom send buttons within the ChatGPT extension. |
7 | | - It provides utility functions to create buttons based on configuration and assigns keyboard shortcuts where applicable. |
8 | | -
|
9 | | - After that, tje |
10 | | -
|
11 | | - Usage: |
12 | | - Ensure that dependencies are loaded before this script to utilize button functionalities. |
13 | | -
|
14 | | - Depends on: |
15 | | - utils.js - object containing all selectors and identifiers |
16 | | - buttons-init.js - handles only some initializations. |
17 | | - + |
18 | | - buttons-clicking-chatgpt.js - handles the send button clicking process for ChatGPT |
19 | | - buttons-clicking-copilot.js - ... for Copilot |
20 | | - buttons-clicking-claude.js - ... Claude |
21 | | -
|
22 | | - Instructions for AI: do not remove comments! MUST NOT REMOVE COMMENTS. This one too! |
| 2 | + Version: 1.0 |
| 3 | +
|
| 4 | + Documentation: |
| 5 | + Button creation + click orchestration. |
| 6 | + - Builds both custom send buttons (from profile/global config) and Cross-Chat buttons ("Copy", "Paste"). |
| 7 | + - Assigns numeric shortcuts (1–10) to the first 10 non-separator buttons (configurable via globalMaxExtensionConfig.enableShortcuts). |
| 8 | + - Composes titles that include autosend status and shortcut hints. |
| 9 | + - Handles click behavior across supported sites and integrates with queue mode in the floating panel. |
| 10 | +
|
| 11 | + Exposed methods: |
| 12 | + - MaxExtensionButtons.createCustomSendButton(buttonConfig, index, onClickHandler, overrideShortcutKey?) |
| 13 | + - MaxExtensionButtons.createCrossChatButton(type: 'copy'|'paste', shortcutKey?) |
| 14 | + - MaxExtensionButtons.determineShortcutKeyForButtonIndex(buttonIndex, offset?) |
| 15 | +
|
| 16 | + Click flow: |
| 17 | + - processCustomSendButtonClick(event, customText, autoSend) |
| 18 | + * Shift inverts autoSend at click time. |
| 19 | + * If the floating panel is visible and queue mode is enabled, the button is enqueued instead of sending immediately. |
| 20 | + * Routes to site-specific handlers based on InjectionTargetsOnWebsite.activeSite: |
| 21 | + - ChatGPT, Claude, Copilot, DeepSeek, AIStudio, Grok, Gemini |
| 22 | +
|
| 23 | + Cross-Chat notes: |
| 24 | + - "Copy": reads from the active editor, saves via service worker, briefly shows "Copied!" in tooltip, |
| 25 | + and triggers autosend with the existing text when configured. |
| 26 | + - "Paste": fetches stored prompt; tooltip shows a debounced preview on hover. |
| 27 | +
|
| 28 | + Usage: |
| 29 | + Load order should ensure `utils.js` and any site-specific clicking modules are present before use. |
| 30 | + Rendering order and placement are orchestrated by buttons-init.js; this file focuses on element creation and behavior. |
| 31 | +
|
| 32 | + Depends on: |
| 33 | + - utils.js (selectors and shared utilities) |
| 34 | + - buttons-init.js (composition/placement) |
| 35 | + - buttons-clicking-*.js (site handlers: chatgpt/claude/copilot/deepseek/aistudio/grok/gemini) |
| 36 | +
|
| 37 | + Instructions for AI: do not remove comments! MUST NOT REMOVE COMMENTS. This one too! |
23 | 38 | */ |
24 | 39 | 'use strict'; |
25 | 40 |
|
|
0 commit comments