-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.html
472 lines (405 loc) · 13.1 KB
/
popup.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
<!DOCTYPE html>
<html class="dark">
<head>
<title>AI Post Assistant</title>
<meta charset='utf-8'>
<style>
:root {
--primary: #1D9BF0;
--primary-hover: #1A8CD8;
--bg-dark: #15202B;
--bg-darker: #192734;
--text: #E7E9EA;
--text-secondary: #8B98A5;
--border: #38444D;
--success: #00BA7C;
--error: #F4212E;
--input-bg: #273340;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
html, body {
width: 450px;
min-height: 850px;
max-height: 950px;
overflow-y: auto;
background: var(--bg-dark);
color: var(--text);
margin: 0;
overflow-x: hidden; /* Prevent horizontal scroll */
}
.container {
width: 100%;
height: 100%;
padding: 16px;
display: flex;
flex-direction: column;
box-sizing: border-box;
overflow-x: hidden; /* Prevent horizontal scroll */
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
max-width: 100%; /* Ensure no element exceeds container width */
}
.header {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 20px;
padding-bottom: 12px;
border-bottom: 1px solid var(--border);
}
.header img {
width: 48px;
height: 48px;
}
.header h1 {
font-size: 20px;
font-weight: 700;
color: var(--text);
}
.mode-selector {
display: flex;
gap: 8px;
margin-bottom: 16px;
padding: 4px;
background: var(--bg-darker);
border-radius: 20px;
}
.mode-btn {
flex: 1;
padding: 8px 16px;
border: none;
border-radius: 16px;
background: transparent;
color: var(--text-secondary);
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
}
.mode-btn.active {
background: var(--primary);
color: white;
}
.mode-btn:hover:not(.active) {
background: rgba(29, 155, 240, 0.1);
color: var(--primary);
}
.input-group {
margin-bottom: 16px;
}
.input-label {
display: block;
margin-bottom: 8px;
color: var(--text-secondary);
font-size: 14px;
}
textarea {
width: 100%;
min-height: 120px;
max-height: 300px;
padding: 12px;
background: var(--input-bg);
border: 1px solid var(--border);
border-radius: 12px;
color: var(--text);
font-size: 15px;
resize: vertical; /* Only allow vertical resizing */
box-sizing: border-box;
overflow-x: hidden; /* Prevent horizontal scroll in textarea */
}
#generated-content {
flex-grow: 1; /* Allow this section to grow */
display: flex;
flex-direction: column;
}
#generated-text {
flex-grow: 1; /* Allow textarea to grow within its container */
min-height: 150px; /* Increased minimum height */
}
.debug-log {
margin-top: 15px;
max-height: 120px; /* Increased from 100px */
overflow-y: auto;
background: var(--bg-darker);
padding: 12px;
border-radius: 8px;
font-family: monospace;
font-size: 12px;
}
/* Custom scrollbar for textareas and debug log */
textarea::-webkit-scrollbar,
.debug-log::-webkit-scrollbar {
width: 8px;
height: 8px;
}
textarea::-webkit-scrollbar-track,
.debug-log::-webkit-scrollbar-track {
background: var(--bg-darker);
border-radius: 4px;
}
textarea::-webkit-scrollbar-thumb,
.debug-log::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 4px;
}
textarea::-webkit-scrollbar-thumb:hover,
.debug-log::-webkit-scrollbar-thumb:hover {
background: var(--text-secondary);
}
/* Add character count */
.character-count {
text-align: right;
color: var(--text-secondary);
font-size: 12px;
margin-top: 4px;
}
.original-post {
margin: 12px 0;
padding: 12px;
background: var(--bg-darker);
border-radius: 12px;
border: 1px solid var(--border);
font-size: 14px;
}
.original-post-header {
color: var(--text-secondary);
margin-bottom: 8px;
font-size: 12px;
}
.original-post-content {
color: var(--text);
line-height: 1.4;
}
textarea:focus {
outline: none;
border-color: var(--primary);
}
.button {
width: 100%;
padding: 12px;
border: none;
border-radius: 24px;
background: var(--primary);
color: white;
font-size: 15px;
font-weight: 600;
cursor: pointer;
transition: background 0.2s;
}
.button:hover {
background: var(--primary-hover);
}
.button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.button-group {
width: 100%;
display: flex;
gap: 8px;
margin-bottom: 16px;
flex-wrap: wrap;
box-sizing: border-box;
}
.button.secondary {
background: var(--bg-darker);
border: 1px solid var(--border);
color: var(--text);
}
.button.secondary:hover {
background: var(--input-bg);
}
.status {
margin-top: 12px;
padding: 12px;
border-radius: 12px;
font-size: 14px;
display: none;
}
.status.success {
background: rgba(0, 186, 124, 0.1);
color: var(--success);
}
.status.error {
background: rgba(244, 33, 46, 0.1);
color: var(--error);
}
.status.info {
background: rgba(29, 155, 240, 0.1);
color: var(--primary);
}
.settings {
margin-top: 20px;
padding-top: 16px;
border-top: 1px solid var(--border);
}
.settings h3 {
margin-bottom: 12px;
color: var(--text);
font-size: 16px;
}
.setting-group {
margin-bottom: 16px;
}
.select-input {
width: 100%;
padding: 12px;
background: var(--input-bg);
border: 1px solid var(--border);
border-radius: 12px;
color: var(--text);
font-size: 14px;
margin-bottom: 12px;
cursor: pointer;
}
.select-input option {
background: var(--bg-dark);
color: var(--text);
padding: 8px;
}
.setting-group .input-label {
margin-bottom: 8px;
display: block;
}
.api-key-input {
width: 100%;
padding: 12px;
background: var(--input-bg);
border: 1px solid var(--border);
border-radius: 12px;
color: var(--text);
font-size: 14px;
margin-bottom: 12px;
}
.api-key-input:focus {
outline: none;
border-color: var(--primary);
}
.debug-section {
margin-top: 20px;
}
.debug-log {
padding: 12px;
background: var(--bg-darker);
border-radius: 12px;
font-family: monospace;
font-size: 12px;
max-height: 150px;
overflow-y: auto;
}
.debug-log strong {
color: var(--primary);
}
/* Scrollbar styling */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--text-secondary);
}
/* Animations */
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.fade-in {
animation: fadeIn 0.3s ease-in-out;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<img src="icons/icon48.png" alt="AI Post Assistant">
<h1>AI Post Assistant</h1>
</div>
<div class="mode-selector">
<button class="mode-btn active" data-mode="newPost">New Post</button>
<button class="mode-btn" data-mode="reply">Reply</button>
</div>
<div id="original-post" class="original-post" style="display: none;">
<div class="original-post-header">Replying to:</div>
<div id="original-post-content" class="original-post-content"></div>
</div>
<div class="input-group">
<label class="input-label" for="content-input">What would you like to post about?</label>
<textarea id="content-input" placeholder="Enter your topic or idea..."></textarea>
</div>
<div id="generated-content" class="input-group" style="display: none;">
<label class="input-label" for="generated-text">Generated Content (edit if needed)</label>
<textarea id="generated-text" placeholder="Generated content will appear here..."></textarea>
</div>
<div class="button-group">
<button id="generate-btn" class="button">Generate Content</button>
<button id="post-btn" class="button" style="display: none;">Post to X</button>
<button id="clear-state" class="button secondary" style="display: none;">Clear Draft</button>
</div>
<div id="draft-indicator" class="draft-indicator" style="display: none;">
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
<path d="M12 2v10m0 0v10m0-10h10m-10 0H2" stroke-width="2" stroke-linecap="round"/>
</svg>
<span>Draft saved</span>
</div>
<div id="status" class="status"></div>
<!-- Add character count -->
<div class="character-count">
<span id="char-count">0</span>/280
</div>
<div class="settings">
<h3>Settings</h3>
<div class="setting-group">
<label class="input-label">AI Provider</label>
<select id="ai-provider" class="select-input">
<option value="openai">OpenAI</option>
<option value="xai">XAI</option>
</select>
</div>
<div class="setting-group" id="openai-settings">
<label class="input-label">OpenAI Model</label>
<select id="openai-model" class="select-input">
<option value="gpt-4o">GPT-4o</option>
<option value="gpt-4o-mini">GPT-4o-mini</option>
</select>
<input type="password"
class="api-key-input"
id="openai-key"
placeholder="Enter your OpenAI API key">
</div>
<div class="setting-group" id="xai-settings" style="display: none;">
<label class="input-label">XAI Model</label>
<select id="xai-model" class="select-input">
<option value="grok-2-1212">Grok-2</option>
<option value="grok-2-vision-1212">Grok-2 Vision</option>
</select>
<input type="password"
class="api-key-input"
id="xai-key"
placeholder="Enter your XAI API key">
</div>
<button id="save-api-key" class="button">Save Settings</button>
</div>
<div class="debug-section">
<div class="debug-log">
<strong>Debug Log:</strong>
<pre id="log-content"></pre>
</div>
</div>
</div>
<script src="popup.js"></script>
</body>
</html>