Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.text) {
// Simulate optimization logic
const optimizedText = message.text.trim().toUpperCase(); // Example: Convert to uppercase
sendResponse({ optimizedText });
}
});
62 changes: 62 additions & 0 deletions contentScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Inject the floating button
const button = document.createElement("button");
button.textContent = "🐋 Optimize";
button.style.position = "fixed";
button.style.bottom = "20px";
button.style.right = "20px";
button.style.padding = "10px 15px";
button.style.backgroundColor = "#007bff";
button.style.color = "#fff";
button.style.border = "none";
button.style.borderRadius = "5px";
button.style.cursor = "pointer";
button.style.boxShadow = "0 4px 6px rgba(0, 0, 0, 0.1)";
button.style.zIndex = "10000";
button.style.transition = "background-color 0.3s ease";
button.addEventListener("mouseover", () => {
button.style.backgroundColor = "#0056b3";
});
button.addEventListener("mouseout", () => {
button.style.backgroundColor = "#007bff";
});
document.body.appendChild(button);

// Handle button click
button.addEventListener("click", () => {
const activeElement = document.activeElement;
if (
activeElement &&
(activeElement.tagName === "TEXTAREA" ||
(activeElement.tagName === "INPUT" &&
activeElement.getAttribute("type") === "text"))
) {
const originalText = activeElement.value;
chrome.runtime.sendMessage({ text: originalText }, (response) => {
if (response && response.optimizedText) {
activeElement.value = response.optimizedText;

// Show confirmation message
const confirmation = document.createElement("div");
confirmation.textContent = "✅ Prompt Optimized!";
confirmation.style.position = "fixed";
confirmation.style.bottom = "60px";
confirmation.style.right = "20px";
confirmation.style.backgroundColor = "#28a745";
confirmation.style.color = "#fff";
confirmation.style.padding = "5px 10px";
confirmation.style.borderRadius = "5px";
confirmation.style.boxShadow = "0 4px 6px rgba(0, 0, 0, 0.1)";
confirmation.style.zIndex = "10000";
document.body.appendChild(confirmation);

setTimeout(() => {
confirmation.style.transition = "opacity 0.5s ease";
confirmation.style.opacity = "0";
setTimeout(() => confirmation.remove(), 500);
}, 2000);
}
});
} else {
alert("Please focus on a text input or textarea to optimize.");
}
});
8 changes: 2 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@
},
"content_scripts": [
{
"matches": [
"*://*.anthropic.com/*",
"*://*.openai.com/*",
"*://*.google.com/*"
],
"js": ["query-patterns.js", "query-optimizer.js", "content.js"]
"matches": ["<all_urls>"],
"js": ["contentScript.js"]
}
],
"background": {
Expand Down