Skip to content

Commit 6a8e03a

Browse files
committed
Better error handeling of unchecked GM api's
1 parent bcffd25 commit 6a8e03a

File tree

5 files changed

+3
-37
lines changed

5 files changed

+3
-37
lines changed

README.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ node build.js
5151

5252
* [ ] `GM_download`
5353
* [ ] `GM_confirm`
54-
* [ ] `GM_unregisterMenuCommand`
5554
* [ ] Additional APIs as needed
5655

5756
### Security & Permissions
@@ -62,15 +61,8 @@ node build.js
6261
* [ ] Add better trusted type managment
6362

6463
### Core Improvements
65-
66-
* [ ] Fix version checking logic
67-
* [ ] Add script version checking
68-
* [ ] Add script update functionality
69-
* [ ] Improve `ExternalScriptLoader`
70-
* [ ] Refine `getScriptDescription` function
7164
* [ ] Deduplicate logic between `background.js`, `inject.js`, and `GM_core.js`
7265
* [ ] Unify or reuse declarations between `GM_core` and `inject`
73-
* [ ] Make menu commands reactive
7466

7567
### Editor
7668

@@ -79,29 +71,18 @@ node build.js
7971
* [ ] Enhance extension management for CodeMirror
8072
* [ ] Link CodeMirror minimap toggle
8173
* [ ] Move helper functions (`exportScript`, `generateTamperMonkeyHeader`) to separate files
82-
* [ ] Modularize script import logic
8374
* [ ] Add option to toggle execution in main world or isolated world
8475
* [ ] 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
8776

8877
### UI
8978
* [ ] Add iframe preview with live refresh
9079
* [ ] Fix editor optimizations
91-
* [ ] Add a cap to how long text can be in the dashboard
92-
93-
94-
95-
### Debugging & Notifications
96-
97-
* [ ] Display script errors directly on page (without console)
98-
* [ ] Add "Debug Mode" to enable in-page error display
99-
* [ ] Separate script notification logic into its own file
10080

10181
### Communication & Helpers
10282

10383
* [ ] Simplify or centralize communication between content scripts and background scripts
10484
* [ ] Optional Trusted Types helpers
85+
* [ ] Fix script loading other scripts against CORS
10586

10687
---
10788

src/editor/editor.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ <h3 class="panel-title">Script Information</h3>
115115
<div class="form-group">
116116
<label for="scriptIcon" class="form-label">Icon URL</label>
117117
<input type="url" id="scriptIcon" class="form-input" placeholder="https://... or data:image/png;base64,...">
118-
<div class="form-hint">Supports http://, https://, or data:image/ URLs</div>
119118
</div>
120119
</div>
121120
</div>

src/editor/editor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ class ScriptEditor {
865865
scriptData.gmAddStyle = this.elements.gmAddStyle?.checked || false;
866866
scriptData.gmAddElement = this.elements.gmAddElement?.checked || false;
867867
scriptData.gmRegisterMenuCommand = this.elements.gmRegisterMenuCommand?.checked || false;
868+
scriptData.gmUnregisterMenuCommand = this.elements.gmUnregisterMenuCommand?.checked || false;
868869
scriptData.gmXmlhttpRequest = this.elements.gmXmlhttpRequest?.checked || false;
869870
scriptData.unsafeWindow = this.elements.unsafeWindow?.checked || false;
870871

src/editor/editor_managers.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,6 @@ export class FormValidator {
10761076
const validations = [
10771077
// Name is optional (auto-generated on save if empty)
10781078
this.validateTargetUrls(),
1079-
this.validateVersion(),
10801079
this.validateRunAt(),
10811080
this.validateIconUrl(),
10821081
this.validateRequireUrls(),
@@ -1108,20 +1107,6 @@ export class FormValidator {
11081107
return { isValid: true };
11091108
}
11101109

1111-
validateVersion() {
1112-
const versionEl = this.elements.scriptVersion;
1113-
const version = (versionEl?.value || "").trim();
1114-
if (!version) return { isValid: true };
1115-
1116-
// Accept X.Y or X.Y.Z (with numeric parts). Allow additional patch labels like -beta.1? Keep it simple: X.Y.Z
1117-
const semverLike = /^\d+\.\d+\.\d+$/;
1118-
if (!semverLike.test(version)) {
1119-
this.showValidationError("Version must be in the format X.Y.Z (e.g., 1.0.0).");
1120-
return { isValid: false };
1121-
}
1122-
return { isValid: true };
1123-
}
1124-
11251110
validateRunAt() {
11261111
const allowed = new Set(["document_start", "document_end", "document_idle"]);
11271112
const runAt = this.elements.runAt?.value;

src/popup/popup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ document.addEventListener("DOMContentLoaded", async () => {
233233
try {
234234
command.onClick();
235235
} catch (error) {
236-
console.error("Menu command error:", error);
236+
console.error("CodeTweak: Menu command failed. Please ensure the menu command API is enabled in the editor settings.", error);
237237
}
238238
}
239239
},

0 commit comments

Comments
 (0)