Skip to content

Commit 8be61a0

Browse files
committed
Fix linter errors in the editor and improve CSS
1 parent 037ba3f commit 8be61a0

6 files changed

Lines changed: 146 additions & 45 deletions

File tree

.eslintrc.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@
1515
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
1616
},
1717
"globals": {
18-
"chrome": "readonly"
18+
"chrome": "readonly",
19+
"GM_addElement": "readonly",
20+
"GM_addStyle": "readonly",
21+
"GM_setValue": "readonly",
22+
"GM_getValue": "readonly",
23+
"GM_deleteValue": "readonly",
24+
"GM_listValues": "readonly",
25+
"GM_openInTab": "readonly",
26+
"GM_notification": "readonly",
27+
"GM_getResourceText": "readonly",
28+
"GM_getResourceURL": "readonly",
29+
"GM_xmlhttpRequest": "readonly",
30+
"GM_setInnerHTML": "readonly",
31+
"GM_createHTML": "readonly"
1932
}
2033
}

Chrome/editor.html

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,37 @@
6666
<div class="sidebar-icon-bar">
6767
<button class="sidebar-icon-btn active" data-section="info" title="Script Information">
6868
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
69-
<circle cx="12" cy="12" r="3"></circle>
70-
<path d="M12 1v6m0 6v6m11-7h-6m-6 0H1"></path>
69+
<circle cx="12" cy="12" r="10"></circle>
70+
<line x1="12" y1="16" x2="12" y2="12"></line>
71+
<line x1="12" y1="8" x2="12.01" y2="8"></line>
7172
</svg>
7273
</button>
7374
<button class="sidebar-icon-btn" data-section="execution" title="Execution Settings">
7475
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
75-
<polygon points="5 3 19 12 5 21 5 3"></polygon>
76+
<circle cx="12" cy="12" r="10"></circle>
77+
<polyline points="12 6 12 12 16 14"></polyline>
7678
</svg>
7779
</button>
7880
<button class="sidebar-icon-btn" data-section="api" title="GM API Access">
7981
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
80-
<path d="M12 2 L12 22 M2 12 L22 12"></path>
82+
<polyline points="16 18 22 12 16 6"></polyline>
83+
<polyline points="8 6 2 12 8 18"></polyline>
8184
</svg>
8285
<div class="api-count-badge" id="apiCountBadge">0</div>
8386
</button>
8487
<button class="sidebar-icon-btn" data-section="requires" title="Required Scripts">
85-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
86-
<polyline points="12 5 12 19"></polyline>
87-
<polyline points="5 12 19 12"></polyline>
88+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
89+
<polygon points="12 2 2 7 12 12 22 7 12 2"></polygon>
90+
<polyline points="2 12 12 17 22 12"></polyline>
91+
<polyline points="2 17 12 22 22 17"></polyline>
8892
</svg>
8993
</button>
9094
<button class="sidebar-icon-btn" data-section="resources" title="Script Resources">
9195
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
92-
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
93-
<polyline points="7 10 12 15 17 10"></polyline>
94-
<line x1="12" y1="15" x2="12" y2="3"></line>
96+
<ellipse cx="12" cy="5" rx="9" ry="3"></ellipse>
97+
<path d="M3 5v14c0 1.657 4.03 3 9 3s9-1.343 9-3V5"></path>
98+
<path d="M21 8c0 1.657-4.03 3-9 3S3 9.657 3 8"></path>
99+
<path d="M21 12c0 1.657-4.03 3-9 3s-9-1.343-9-3"></path>
95100
</svg>
96101
</button>
97102
</div>

Chrome/editor.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,11 @@ class ScriptEditor {
659659
this.elements.scriptIcon.value = script.icon || "";
660660
this.codeEditorManager.setValue(script.code || "");
661661

662+
// Reset the URL list before adding to avoid duplicates when reloading/editing
663+
if (this.elements.urlList) {
664+
this.elements.urlList.innerHTML = "";
665+
}
666+
662667
script.targetUrls?.forEach((url) => this.ui.addUrlToList(url));
663668

664669
// Set the sidebar checkboxes -> Not clean but its okay

Chrome/styles/e_sidebar.css

Lines changed: 87 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,13 @@
140140
display: flex;
141141
opacity: 1;
142142
transform: translateX(0);
143-
width: 280px;
144-
min-width: 280px;
143+
width: calc(var(--sidebar-width, 328px) - 48px);
144+
min-width: calc(var(--sidebar-width, 328px) - 48px);
145+
/* Compact control density scoped to sidebar */
146+
--form-element-height: 34px;
147+
--form-element-padding: 6px 10px;
148+
--button-height: 30px;
149+
--button-padding: 6px 10px;
145150
}
146151

147152
/* Hide content area when no panel is active */
@@ -167,14 +172,14 @@
167172
}
168173

169174
.panel-header {
170-
padding: var(--space-lg) var(--space-md) var(--space-md);
175+
padding: var(--space-md) var(--space-sm) var(--space-sm);
171176
background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(99, 102, 241, 0.02) 100%);
172177
border-bottom: 1px solid var(--border-primary);
173178
border-left: 3px solid var(--primary);
174179
}
175180

176181
.panel-title {
177-
font-size: var(--text-base);
182+
font-size: var(--text-sm);
178183
font-weight: var(--font-medium);
179184
color: var(--text-primary);
180185
margin: 0 0 var(--space-xs) 0;
@@ -190,7 +195,7 @@
190195
.panel-content {
191196
flex: 1;
192197
overflow-y: auto;
193-
padding: var(--space-md);
198+
padding: var(--space-sm);
194199
scrollbar-width: thin;
195200
scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
196201
}
@@ -212,17 +217,52 @@
212217
background: var(--scrollbar-thumb-hover);
213218
}
214219

220+
/* Execution panel-specific spacing improvements */
221+
#execution-panel .panel-content {
222+
padding: var(--space-md);
223+
}
224+
225+
#execution-panel .form-group {
226+
margin-bottom: var(--space-md);
227+
}
228+
229+
#execution-panel .url-input-group {
230+
margin-bottom: var(--space-md);
231+
}
232+
233+
#execution-panel .pattern-builder {
234+
gap: var(--space-md);
235+
}
236+
237+
#execution-panel .generated-pattern-group {
238+
margin-top: var(--space-md);
239+
gap: var(--space-md);
240+
}
241+
242+
/* Script Information panel-specific spacing improvements */
243+
#info-panel .panel-content {
244+
padding: var(--space-md);
245+
}
246+
247+
#info-panel .form-group {
248+
margin-bottom: var(--space-md);
249+
}
250+
251+
#info-panel .form-row {
252+
gap: var(--space-sm);
253+
}
254+
215255
/* Form Layout Improvements */
216256
.form-grid {
217257
display: flex;
218258
flex-direction: column;
219-
gap: var(--space-md);
259+
gap: var(--space-sm);
220260
}
221261

222262
.form-row {
223263
display: grid;
224264
grid-template-columns: 1fr 1fr;
225-
gap: var(--space-sm);
265+
gap: var(--space-xs);
226266
}
227267

228268
.form-group {
@@ -292,7 +332,7 @@
292332

293333
.form-textarea {
294334
resize: vertical;
295-
min-height: 80px;
335+
min-height: 64px;
296336
font-family: var(--font-mono);
297337
font-size: var(--text-xs);
298338
}
@@ -301,7 +341,7 @@
301341
.api-categories {
302342
display: flex;
303343
flex-direction: column;
304-
gap: var(--space-md);
344+
gap: var(--space-sm);
305345
}
306346

307347
.api-category {
@@ -313,7 +353,7 @@
313353

314354
.category-title {
315355
margin: 0;
316-
padding: var(--space-md);
356+
padding: var(--space-sm);
317357
background: var(--bg-tertiary);
318358
border-bottom: 1px solid var(--border-primary);
319359
font-size: var(--text-xs);
@@ -325,11 +365,11 @@
325365

326366
.api-list {
327367
display: grid;
328-
grid-template-columns: 1fr 1fr;
329-
gap: 0;
368+
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
369+
gap: var(--space-xs);
330370
padding: var(--space-sm);
331-
max-height: 200px;
332-
overflow-y: auto;
371+
max-height: none;
372+
overflow-y: visible;
333373
scrollbar-width: thin;
334374
scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
335375
}
@@ -355,7 +395,7 @@
355395
display: flex;
356396
align-items: center;
357397
margin: 0;
358-
padding: var(--space-sm);
398+
padding: var(--space-xs);
359399
cursor: pointer;
360400
border-radius: var(--radius-sm);
361401
transition: var(--transition-colors);
@@ -417,7 +457,7 @@
417457
.url-input-group,
418458
.resource-input-group {
419459
display: flex;
420-
gap: var(--space-sm);
460+
gap: var(--space-xs);
421461
margin-bottom: var(--space-sm);
422462
align-items: flex-end;
423463
}
@@ -428,10 +468,13 @@
428468
}
429469

430470
.resource-input-group {
431-
display: grid;
432-
grid-template-columns: 1fr 1fr auto;
433-
gap: var(--space-sm);
434-
align-items: end;
471+
flex-direction: column;
472+
align-items: stretch;
473+
gap: var(--space-xs);
474+
}
475+
476+
.resource-input-group .add-btn {
477+
width: 100%;
435478
}
436479

437480
/* Enhanced Lists with Better Visual Hierarchy */
@@ -440,8 +483,8 @@
440483
display: flex;
441484
flex-direction: column;
442485
gap: var(--space-sm);
443-
max-height: 120px;
444-
overflow-y: auto;
486+
max-height: none;
487+
overflow-y: visible;
445488
scrollbar-width: thin;
446489
scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
447490
}
@@ -472,7 +515,7 @@
472515
display: flex;
473516
align-items: center;
474517
justify-content: space-between;
475-
padding: var(--space-md);
518+
padding: var(--space-sm);
476519
background: var(--bg-tertiary);
477520
border: 1px solid var(--border-primary);
478521
border-radius: var(--radius-md);
@@ -517,6 +560,27 @@
517560
background: var(--error-light);
518561
}
519562

563+
/* Generic remove button styling (used in lists) */
564+
.remove-btn {
565+
display: flex;
566+
align-items: center;
567+
justify-content: center;
568+
width: 20px;
569+
height: 20px;
570+
background: none;
571+
border: none;
572+
color: var(--text-muted);
573+
cursor: pointer;
574+
transition: var(--transition-all);
575+
padding: 0;
576+
border-radius: var(--radius-sm);
577+
}
578+
579+
.remove-btn:hover {
580+
color: var(--error);
581+
background: var(--error-light);
582+
}
583+
520584
/* Enhanced API Search */
521585
.api-search {
522586
background: var(--bg-primary);

Chrome/utils/editor_managers.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,15 @@ export class URLManager extends BaseUIComponent {
567567
}
568568

569569
addUrlToList(url) {
570-
// Note: We don't need to validate URL here since it's already validated in addCurrentUrl
571-
// This prevents duplicate error messages
570+
// Prevent duplicates
571+
if (this.elements.urlList) {
572+
const existing = Array.from(this.elements.urlList.querySelectorAll('.url-item'))
573+
.some(item => item.dataset.url === url);
574+
if (existing) {
575+
return false;
576+
}
577+
}
578+
572579
try {
573580
const urlItem = document.createElement('div');
574581
urlItem.className = 'url-item';
@@ -722,8 +729,9 @@ export class ResourceManager extends BaseUIComponent {
722729
});
723730

724731
this.addEventListener(this.elements.resourceList, 'click', (e) => {
725-
if (e.target.classList.contains('remove-resource-btn')) {
726-
this.removeResource(e.target.closest('.resource-item'));
732+
const btn = e.target.closest('.remove-resource-btn, .remove-resource');
733+
if (btn) {
734+
this.removeResource(btn.closest('.resource-item'));
727735
}
728736
});
729737

Chrome/utils/editor_settings.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,20 @@ export class CodeEditorManager {
388388
}
389389

390390
//lint options
391-
getLintOptions(enable) {
391+
getLintOptions(enable, enabledApiNames = []) {
392392
// Skip linting entirely for large files to avoid freezes
393393
if (this.largeFileOptimized || !enable || typeof window.JSHINT === "undefined") return false;
394394

395+
// Build globals map including enabled GM_* APIs
396+
const globals = {
397+
chrome: false,
398+
CodeMirror: false,
399+
GM: false,
400+
};
401+
enabledApiNames.forEach((name) => {
402+
globals[name] = false; // treat as read-only globals
403+
});
404+
395405
return {
396406
getAnnotations: (text) => {
397407
const errors = [];
@@ -411,11 +421,7 @@ export class CodeEditorManager {
411421
sub: true,
412422
shadow: false,
413423
strict: true,
414-
globals: {
415-
chrome: false,
416-
CodeMirror: false,
417-
GM: false,
418-
},
424+
globals,
419425
})
420426
) {
421427
const jshintErrors = window.JSHINT.errors;
@@ -440,7 +446,7 @@ export class CodeEditorManager {
440446

441447
toggleLinting(enabled) {
442448
this.state.lintingEnabled = enabled !== undefined ? enabled : !this.state.lintingEnabled;
443-
const lintOptions = this.getLintOptions(this.state.lintingEnabled);
449+
const lintOptions = this.getLintOptions(this.state.lintingEnabled, this.getEnabledGmApis());
444450
this.codeEditor.setOption("lint", lintOptions);
445451

446452
// Force a re-lint when enabling

0 commit comments

Comments
 (0)