Skip to content

Commit 751a581

Browse files
committed
Quality of life changes
1 parent 8901488 commit 751a581

File tree

16 files changed

+226
-79
lines changed

16 files changed

+226
-79
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,11 @@ npm build.js
5252
* [ ] Enhance extension management for CodeMirror
5353
* [ ] Link CodeMirror minimap toggle
5454
* [ ] Move helper functions (`exportScript`, `generateTamperMonkeyHeader`) to separate files
55-
* [ ] Add option to toggle execution in main world or isolated world
56-
* [ ] Display execution world and run-at time in editor/dashboard
5755

5856
### UI
59-
* [ ] Make it so you choose where the modifcation goes on pages with mutiple scripts running
60-
* [ ] Change highlight theme color
6157
* [ ] Fix editor optimizations
6258
* [ ] Can you make it so if you have mutiple scripts running at once on the same page the notifications will expand verticlly and not all overlap
6359

64-
### Helpers
65-
* [ ] Fix regrex
6660
---
6761

6862
## Acknowledgments

src/GM/gm_core.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@
223223
const stack = event.error?.stack || event.reason?.stack || '';
224224
const message = event.error?.message || event.reason?.message || event.message || 'Unknown error';
225225

226-
console.error(`CodeTweak: Error in script ${scriptId}:`, message, stack);
226+
console.error(`CodeTweak: Error in user script (ID: ${scriptId}). This is likely an issue with the script itself, not CodeTweak.`, `
227+
Message: ${message}`, `
228+
Stack: ${stack}`);
227229
// Send to editor
228230
try {
229231
window.postMessage({
@@ -245,7 +247,9 @@
245247
const message = event.reason?.message || String(event.reason) || 'Unhandled promise rejection';
246248
const stack = event.reason?.stack || '';
247249

248-
console.error(`CodeTweak: Unhandled promise rejection in script ${scriptId}:`, message, stack);
250+
console.error(`CodeTweak: Unhandled promise rejection in user script (ID: ${scriptId}). This is likely an issue with the script itself, not CodeTweak.`, `
251+
Message: ${message}`, `
252+
Stack: ${stack}`);
249253
try {
250254
window.postMessage({
251255
type: 'SCRIPT_ERROR',
@@ -286,6 +290,7 @@
286290

287291
scriptEl.textContent = trustedCode;
288292
(document.head || document.documentElement || document.body).appendChild(scriptEl);
293+
scriptEl.remove();
289294

290295
} catch (err) {
291296
console.error(`CodeTweak: Error executing user script ${scriptId}:`, err);
@@ -305,6 +310,10 @@
305310
} catch (e) {
306311
console.error('Failed to report script execution error:', e);
307312
}
313+
} finally {
314+
// Clean up the event listeners
315+
window.removeEventListener('error', errorHandler);
316+
window.removeEventListener('unhandledrejection', rejectionHandler);
308317
}
309318
}
310319

src/assets/styles/d_script_list.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@
5555
.script-name-col {
5656
min-width: 0;
5757
overflow: hidden;
58+
display: flex;
59+
align-items: center;
60+
gap: var(--space-sm);
61+
}
62+
63+
.script-icon {
64+
width: 32px;
65+
height: 32px;
66+
border-radius: var(--radius-sm);
67+
object-fit: cover;
68+
flex-shrink: 0;
5869
}
5970

6071
.script-name {

src/assets/styles/dashboard.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ body {
7777
.tab-content {
7878
display: none;
7979
flex-direction: column;
80-
height: 100%;
81-
overflow: hidden;
80+
flex: 1;
81+
overflow: auto;
8282
}
8383

8484
.tab-content.active {

src/assets/styles/e_sidebar.css

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@
195195

196196
/* Forms */
197197
.form-grid { display: flex; flex-direction: column; gap: var(--space-sm); }
198-
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xs); }
199-
#info-panel .form-row { gap: var(--space-sm); }
200198
.form-group { margin-bottom: 0; position: relative; }
201199

202200
.form-label {
@@ -210,14 +208,6 @@
210208
text-transform: uppercase;
211209
letter-spacing: 0.025em;
212210
}
213-
.label-required { color: var(--error); font-size: 10px; }
214-
.form-help {
215-
display: block;
216-
margin-top: var(--space-xs);
217-
font-size: 10px;
218-
color: var(--text-muted);
219-
font-style: italic;
220-
}
221211

222212
.form-input,
223213
.form-textarea,
@@ -709,4 +699,20 @@
709699
padding-bottom: 0;
710700
border-width: 0;
711701
}
702+
}
703+
704+
.icon-input-wrapper {
705+
display: flex;
706+
align-items: center;
707+
gap: var(--space-sm);
708+
}
709+
710+
.icon-preview {
711+
width: 32px;
712+
height: 32px;
713+
border-radius: var(--radius-sm);
714+
object-fit: cover;
715+
flex-shrink: 0;
716+
background-color: var(--bg-tertiary);
717+
border: 1px solid var(--border-primary);
712718
}

src/assets/styles/global_theme.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
:root {
2-
--primary: #61afef;
3-
--primary-hover: #528bff;
2+
--accent-color: #61afef;
3+
--primary: var(--accent-color);
4+
--primary-hover: var(--accent-color);
45
--primary-light: rgba(97, 175, 239, 0.15);
56
--secondary: #c678dd;
67
--accent: #56b6c2;

src/background/background.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ function normalizeStackTrace(stack) {
307307
// Needs a rework
308308
async function storeScriptError(scriptId, error) {
309309
try {
310+
const { settings = {} } = await chrome.storage.local.get("settings");
311+
if (!settings.enhancedDebugging) {
312+
return;
313+
}
314+
310315
const storageKey = `scriptErrors_${scriptId}`;
311316
const { [storageKey]: existingErrors = [] } = await chrome.storage.local.get(storageKey);
312317
const normalizedNewStack = normalizeStackTrace(error.stack);

src/dashboard/dashboard-logic.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ async function loadSettings(settingsElements) {
117117
const defaultSettings = {
118118
enableAllScripts: true,
119119
showNotifications: true,
120+
enhancedDebugging: false,
120121
confirmBeforeRunning: false,
121122
allowExternalResources: true,
122123
confirmFirstRun: false,
124+
accentColor: "#61afef",
123125
};
124126

125127
// Apply defaults and update storage if needed
@@ -131,16 +133,24 @@ async function loadSettings(settingsElements) {
131133
settings[key] = defaultValue;
132134
shouldSaveDefaults = true;
133135
}
134-
element.checked = settings[key];
136+
if (element.type === 'color') {
137+
element.value = settings[key];
138+
} else {
139+
element.checked = settings[key];
140+
}
135141
}
136142
});
137143

138144
// Save defaults to storage if any were missing
139145
if (shouldSaveDefaults) {
140146
await chrome.storage.local.set({ settings });
141147
}
142-
143148

149+
// Apply theme
150+
if (settings.accentColor) {
151+
document.documentElement.style.setProperty('--accent-color', settings.accentColor);
152+
}
153+
144154
} catch (error) {
145155
console.error("Error loading settings:", error);
146156
showNotification("Error loading settings", "error");
@@ -155,14 +165,22 @@ async function saveSettings(settingsElements) {
155165
Object.keys(settingsElements).forEach((key) => {
156166
const element = settingsElements[key];
157167
if (element) {
158-
settings[key] = element.checked;
168+
if (element.type === 'color') {
169+
settings[key] = element.value;
170+
} else {
171+
settings[key] = element.checked;
172+
}
159173
}
160174
});
161175

162176
await chrome.storage.local.set({ settings });
163177
showNotification("Settings saved successfully", "success");
164178
chrome.runtime.sendMessage({ action: "settingsUpdated" });
165179

180+
// Apply theme
181+
if (settings.accentColor) {
182+
document.documentElement.style.setProperty('--accent-color', settings.accentColor);
183+
}
166184

167185
} catch (error) {
168186
console.error("Error saving settings:", error);

src/dashboard/dashboard-ui.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ function createScriptListItem(script) {
118118
const nameCol = document.createElement("div");
119119
nameCol.className = "script-name-col";
120120

121+
if (script.icon) {
122+
const icon = document.createElement("img");
123+
icon.src = script.icon;
124+
icon.className = "script-icon";
125+
nameCol.appendChild(icon);
126+
}
127+
128+
const nameAndDesc = document.createElement("div");
121129
const name = document.createElement("h3");
122130
name.className = "script-name";
123131
name.textContent = script.name;
@@ -126,7 +134,8 @@ function createScriptListItem(script) {
126134
description.className = "script-description";
127135
description.textContent = script.description || "No description provided.";
128136

129-
nameCol.append(name, description);
137+
nameAndDesc.append(name, description);
138+
nameCol.append(nameAndDesc);
130139

131140
// Version column
132141
const versionCol = document.createElement("div");

src/dashboard/dashboard.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ <h3>General</h3>
115115
<small>Display notifications when scripts run</small>
116116
</span>
117117
</label>
118+
<label class="setting-item">
119+
<input type="checkbox" id="enhancedDebugging">
120+
<span class="setting-label">
121+
<strong>Enhanced Debugging</strong>
122+
<small>Log detailed script information to the console</small>
123+
</span>
124+
</label>
118125
</div>
119126
<div class="settings-group">
120127
<h3>Security</h3>
@@ -133,6 +140,16 @@ <h3>Security</h3>
133140
</span>
134141
</label>
135142
</div>
143+
<div class="settings-group">
144+
<h3>Theme</h3>
145+
<label class="setting-item">
146+
<span class="setting-label">
147+
<strong>Accent Color</strong>
148+
<small>Choose the accent color for the UI</small>
149+
</span>
150+
<input type="color" id="accentColor" value="#61afef">
151+
</label>
152+
</div>
136153
<div class="settings-actions">
137154
<button type="submit" class="btn-primary">Save Settings</button>
138155
<button type="reset" class="btn-secondary">Reset Defaults</button>

0 commit comments

Comments
 (0)