Skip to content

Commit 716c249

Browse files
authored
Added overlay to edit
1 parent 40af414 commit 716c249

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

background.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,56 @@ chrome.runtime.onInstalled.addListener(() => {
4141
}
4242
});
4343

44+
// The overlay HTML structure
45+
const overlayHTML = `
46+
<div id="openai-overlay" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); display: flex; align-items: center; justify-content: center; z-index: 9999;">
47+
<div style="width: 40%; padding: 20px; background-color: #2c2c2c; border: 1px solid #444; border-radius: 8px;">
48+
<div id="prompt-suggestions" style="margin-bottom: 10px;">
49+
<span style="color: #888; cursor: pointer;" onclick="document.getElementById('openai-textbox').value = 'Secret Textbox'">Press [Esc] to exit</span>
50+
</div>
51+
<textarea id="openai-textbox" style="width: 100%; height: 100px; padding: 10px 10px; font-size: 16px; background-color: #2c2c2c; color: #ffffff; border: none; border-radius: 8px; resize: vertical; outline: none;"></textarea>
52+
</div>
53+
</div>
54+
`;
55+
56+
// Function to show the overlay
57+
function showOverlay(tabId) {
58+
chrome.scripting.executeScript({
59+
target: { tabId: tabId },
60+
func: function(overlayContent) {
61+
// Check if overlay already exists
62+
if (document.getElementById('openai-overlay')) {
63+
document.getElementById('openai-overlay').remove();
64+
return;
65+
}
66+
67+
const overlay = document.createElement('div');
68+
overlay.innerHTML = overlayContent;
69+
document.body.appendChild(overlay);
70+
71+
const textbox = document.getElementById('openai-textbox');
72+
textbox.focus();
73+
74+
textbox.addEventListener('keydown', function(e) {
75+
if (e.key === 'Enter' && e.shiftKey) {
76+
// Handle the "Search with OpenAI" functionality here
77+
// For now, just hide the overlay
78+
document.getElementById('openai-overlay').remove();
79+
}
80+
});
81+
82+
// Close overlay on Esc key press
83+
document.addEventListener('keydown', function(e) {
84+
if (e.key === 'Escape') {
85+
document.getElementById('openai-overlay').remove();
86+
}
87+
});
88+
},
89+
args: [overlayHTML]
90+
});
91+
}
92+
93+
4494

4595
///////////////////////
4696
//////////////////////
@@ -143,6 +193,17 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {
143193
}
144194
});
145195

196+
// Handle the Alt+Shift+K shortcut
197+
chrome.commands.onCommand.addListener(function(command) {
198+
if (command === 'show-overlay') {
199+
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
200+
if (tabs[0]) {
201+
showOverlay(tabs[0].id);
202+
}
203+
});
204+
}
205+
});
206+
146207
// Toggle extension functionality on icon click
147208
chrome.action.onClicked.addListener((tab) => {
148209
if (extensionStatus === 'off') {

manifest.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"author": "Sreecharan S. (sr2echa)",
44
"name": "ThottaThukiduven",
5-
"version": "1.03",
5+
"version": "1.12",
66
"description": "Your ultimate tool for Getting AI response, unblock Copy/Paste and keep the window always active. Yk where you can use...",
77
"background": {
88
"service_worker": "background.js"
@@ -25,5 +25,14 @@
2525
"js": ["data/inject/isolated.js", "data/inject/content.js", "data/inject/main.js"]
2626
}
2727
],
28+
"commands": {
29+
"show-overlay": {
30+
"suggested_key": {
31+
"default": "Alt+Shift+K"
32+
},
33+
"description": "Show OpenAI search overlay"
34+
}
35+
},
36+
2837
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA41rIOYBJkYaRSfAOUOWwgCe0X/0rW+Cn04kAuM1j2i0i461w5IodNoMQMOGixC8vK1hrDnxHVfgTh/NsYVK0Dl9I/BAiSdA8o3JWCMqqLk2ZMy4022lH+apQ0aDSmMJfrdLxS411N0Vyo3QCHisFy7cYfQAjc0z1KcuahkrPa6MoVSlJo6yN5601xR0ezeZiIeiweCqK4YKxziQ8dRSj6X5SQ1DXCDKfC8/1Ssam8cY2vn9GHm6ICL4nkPInZB8MBLdzjiEXxs9ciWrkxUfIOa5ewH1dXBeBSfll8ukM5G+5t3KxJyJM0JZLJZfVHWk5PZZLoa6YCja1YnUhUazXOQIDAQAB"
2938
}

0 commit comments

Comments
 (0)