Skip to content

Commit a697a0e

Browse files
committed
Better icon handeling
1 parent eb7a550 commit a697a0e

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,23 @@ node build.js
5656
### Security & Permissions
5757

5858
* [ ] Add new security settings
59-
60-
* [ ] Allow scripts to load external resources
61-
* [ ] Enable loading of third-party libraries and external scripts
62-
* [ ] Ask for confirmation when a script runs on a website for the first time
59+
* [ ] Allow scripts to load external resources
60+
* [ ] Enable loading of third-party libraries and external scripts
61+
* [ ] Ask for confirmation when a script runs on a website for the first time
6362
* [ ] Centralize script access permission checks
63+
* [ ] Add better trusted type managment
6464

6565
### Core Improvements
6666

6767
* [ ] Fix version checking logic
68+
* [ ] Add script version checking
69+
* [ ] Add script update functionality
6870
* [ ] Improve `ExternalScriptLoader`
6971
* [ ] Refine `getScriptDescription` function
7072
* [ ] Deduplicate logic between `background.js`, `inject.js`, and `GM_core.js`
7173
* [ ] Unify or reuse declarations between `GM_core` and `inject`
7274

73-
### Editor & UI
75+
### Editor
7476

7577
* [ ] Reduce editor bundle size (~1.4 MB currently)
7678
* [ ] Split large editor manager files into smaller modules
@@ -80,10 +82,17 @@ node build.js
8082
* [ ] Modularize script import logic
8183
* [ ] Add option to toggle execution in main world or isolated world
8284
* [ ] Display execution world and run-at time in editor/dashboard
85+
* [ ] Log script errors and display in editor
86+
* [ ] Add a cap to how long text can be in the editor
87+
88+
### UI
89+
8390
* [ ] Improve URL display formatting
8491
* [ ] Refine CSS for menu commands and import UI
85-
* [ ] Log script errors and display in editor
8692
* [ ] Add iframe preview with live refresh
93+
* [ ] Fix editor optimizations
94+
* [ ] Add a cap to how long text can be in the dashboard
95+
8796

8897

8998
### Debugging & Notifications

src/editor/editor.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ <h3 class="panel-title">Script Information</h3>
110110
</div>
111111
<div class="form-group">
112112
<label for="scriptIcon" class="form-label">Icon URL</label>
113-
<input type="url" id="scriptIcon" class="form-input" placeholder="https://example.com/icon.png">
113+
<input type="url" id="scriptIcon" class="form-input" placeholder="https://... or data:image/png;base64,...">
114+
<div class="form-hint">Supports http://, https://, or data:image/ URLs</div>
114115
</div>
115116
</div>
116117
</div>

src/editor/editor_managers.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,15 +1123,27 @@ export class FormValidator {
11231123
validateIconUrl() {
11241124
const icon = this.elements.scriptIcon?.value?.trim();
11251125
if (!icon) return { isValid: true };
1126+
1127+
// Allow data URLs (starts with data:image/)
1128+
if (icon.startsWith('data:image/')) {
1129+
// Basic validation for data URL format
1130+
if (!/^data:image\/[a-z+]+;base64,/.test(icon)) {
1131+
this.showValidationError("Invalid data URL format for icon. Must be a valid base64-encoded image.");
1132+
return { isValid: false };
1133+
}
1134+
return { isValid: true };
1135+
}
1136+
1137+
// Otherwise validate as regular HTTP/HTTPS URL
11261138
try {
11271139
const u = new URL(icon);
11281140
if (u.protocol !== "http:" && u.protocol !== "https:") {
1129-
this.showValidationError("Icon URL must start with http:// or https://");
1141+
this.showValidationError("Icon URL must be a valid http:// or https:// URL, or a data:image/ URL");
11301142
return { isValid: false };
11311143
}
11321144
return { isValid: true };
11331145
} catch {
1134-
this.showValidationError("Icon URL is not a valid URL.");
1146+
this.showValidationError("Invalid icon URL. Must be a valid http://, https://, or data:image/ URL");
11351147
return { isValid: false };
11361148
}
11371149
}

0 commit comments

Comments
 (0)