diff --git a/content.js b/content.js index b901df9..7504251 100644 --- a/content.js +++ b/content.js @@ -157,4 +157,37 @@ function setCaretToEnd(element) { selection.removeAllRanges(); selection.addRange(range); element.focus(); -} \ No newline at end of file +} + +document.addEventListener("DOMContentLoaded", async () => { + const inputField = document.querySelector(".ProseMirror[contenteditable='true']") || document.querySelector("#prompt-textarea"); + + if (inputField) { + const autoSaveEnabled = await getUserPreferences(); + + if (autoSaveEnabled) { + inputField.addEventListener("input", () => { + const userId = "user123"; // Replace with actual user ID or method to get it + const url = window.location.href; + const storageKey = `${userId}_${url}`; // Create a unique key for each user and URL + + // Save the input value + chrome.storage.local.set({ [storageKey]: inputField.innerText }, () => { + console.log("Data saved under key:", storageKey, "Value:", inputField.innerText); + }); + }); + } + }else { + console.error("Input field not found."); +} +}); + +// Function to get user preferences from storage +function getUserPreferences() { + return new Promise((resolve) => { + chrome.storage.local.get(["autoSaveEnabled"], (result) => { + console.log("Auto-save preference loaded:", result.autoSaveEnabled); + resolve(result.autoSaveEnabled); + }); + }); +} diff --git a/manifest.json b/manifest.json index 993de4c..3812d4f 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Prompt Save Reuse: ChatGPT & Gemini", "version": "2.0", - "description": "Save and reuse prompts in ChatGPT and Gemini. Single-click to save/retrieve, double-click to append, right-click for more options. Now with improved UX and additional features.", // Updated description if necessary + "description": "Save and reuse prompts in ChatGPT and Gemini. Single-click to save/retrieve, double-click to append, right-click for more options. Now with improved UX and additional features.", "permissions": ["storage", "activeTab", "scripting", "contextMenus"], "background": { "service_worker": "background.js" @@ -19,6 +19,7 @@ }, "action": { "default_title": "Prompt Save Reuse" - } + }, + "options_page": "options.html" } \ No newline at end of file diff --git a/options.css b/options.css new file mode 100644 index 0000000..4f2d442 --- /dev/null +++ b/options.css @@ -0,0 +1,97 @@ +body { + font-family: Arial, sans-serif; + background-color: white; /* Default light background */ + margin: 20px; + padding: 20px; + height: 100vh; +} + +.settings-container { + background-color: #ffffff; + padding: 30px; + border-radius: 10px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); + width: 300px; +} + +h1 { + font-size: 32px; + margin-bottom: 20px; + color: black; + font-weight: 700; +} + +label { + display: flex; + margin: 10px 0; + font-size: 20px; + color: #555; +} + +input[type="checkbox"] { + margin-right: 10px; +} + +button { + background-color: #007bff; + color: #ffffff; + border: none; + border-radius: 5px; + padding: 10px 15px; + cursor: pointer; + font-size: 18px; + transition: background-color 0.3s; + margin-top: 5px; +} + +button:hover { + background-color: #0056b3; +} + +input[type="checkbox"]:checked { + background-color: #007bff; +} + +#custom-command { + padding: 3px 2px; + margin: 0 5px; + width: 25%; +} + +.command-label { + display: flex; + margin: 10px; +} + +.theme-selector { + display: flex; + margin: 10px 0; +} + +/* Dark mode styles */ +body.dark-mode { + background-color: black; + color: white; +} + +body.dark-mode .settings-container { + background-color: #333; + color: white; +} + +body.dark-mode h1 { + color: white; +} + +body.dark-mode label { + color: #ccc; +} + +body.dark-mode button { + background-color: #444; + color: #fff; +} + +body.dark-mode button:hover { + background-color: #666; +} diff --git a/options.html b/options.html new file mode 100644 index 0000000..b1cad6f --- /dev/null +++ b/options.html @@ -0,0 +1,33 @@ + + +
+ + +