Skip to content

Commit f2c0d1f

Browse files
committed
Update AI Inspector UI styles and add right click context menu for deactivation
1 parent 5747ee1 commit f2c0d1f

1 file changed

Lines changed: 31 additions & 7 deletions

File tree

Apps/Web/aiplugin/content.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function injectInspectorUI() {
4545
.ai-fab {
4646
width: 56px;
4747
height: 56px;
48-
background: #1500ffff;
48+
background: #d3a8ffff;
4949
border-radius: 50%;
5050
border: 2px solid #fff;
5151
display: flex;
@@ -54,12 +54,18 @@ function injectInspectorUI() {
5454
font-size: 28px;
5555
color: white;
5656
transition: all 0.2s ease;
57+
cursor: pointer;
58+
}
59+
60+
.ai-fab img {
61+
pointer-events: none;
5762
}
5863
5964
/* Active State */
6065
.ai-fab.active {
61-
background: #ff0000ff;
66+
background: #ff8d8dff;
6267
animation: pulse 2s infinite;
68+
cursor: default;
6369
}
6470
6571
/* Hover Effect */
@@ -108,8 +114,10 @@ function injectInspectorUI() {
108114
const btn = document.createElement('div');
109115
btn.className = 'ai-fab';
110116
const btnImg = document.createElement('img');
111-
btnImg.src = 'zeuz.png'
112-
btn.innerHTML = btnImg;
117+
btnImg.src = chrome.runtime.getURL('zeuz.png');
118+
btnImg.style.width = '32px';
119+
btnImg.style.height = '32px';
120+
btn.appendChild(btnImg);
113121

114122
// close btn
115123
const closeBtn = document.createElement('div');
@@ -128,9 +136,12 @@ function injectInspectorUI() {
128136
// drag
129137
let isDragging = false;
130138
let hasMoved = false;
131-
let startX, startY, initialRight, initialBottom;
139+
let startX, startY;
132140

133141
const onMouseDown = (e) => {
142+
// don't drag if inspector is active
143+
if (btn.classList.contains('active')) return;
144+
134145
isDragging = true;
135146
hasMoved = false;
136147

@@ -143,6 +154,8 @@ function injectInspectorUI() {
143154

144155
startX = e.clientX;
145156
startY = e.clientY;
157+
158+
e.preventDefault();
146159
};
147160

148161
const onMouseMove = (e) => {
@@ -171,17 +184,28 @@ function injectInspectorUI() {
171184
window.addEventListener('mousemove', onMouseMove);
172185
window.addEventListener('mouseup', onMouseUp);
173186

174-
btn.addEventListener('click', () => {
175-
if (!hasMoved) {
187+
btn.addEventListener('click', (e) => {
188+
if (!hasMoved && !btn.classList.contains('active')) {
189+
chrome.runtime.sendMessage({ action: 'toggle_from_content_script' });
190+
}
191+
hasMoved = false; // Reset after click
192+
});
193+
194+
// right-click context menu for deactivation when inspector is active
195+
btn.addEventListener('contextmenu', (e) => {
196+
e.preventDefault();
197+
if (btn.classList.contains('active')) {
176198
chrome.runtime.sendMessage({ action: 'toggle_from_content_script' });
177199
}
178200
});
179201

180202
chrome.runtime.onMessage.addListener((request) => {
181203
if (request.action === 'activate') {
182204
btn.classList.add('active');
205+
btnImg.src = chrome.runtime.getURL('zeuz-active.png');
183206
} else if (request.action === 'deactivate') {
184207
btn.classList.remove('active');
208+
btnImg.src = chrome.runtime.getURL('zeuz.png');
185209
}
186210
});
187211
}

0 commit comments

Comments
 (0)