Skip to content

Commit 0015843

Browse files
committed
ScriptVault v1.7.5: fix Monaco migration — restore toolbar buttons + snippet insert
The Monaco editor migration left many toolbar buttons non-functional because the adapter was missing CodeMirror methods that dashboard.js depends on. Monaco adapter additions: - undo()/redo() — route to Monaco actions - foldAll()/unfoldAll() — route to editor.foldAll/unfoldAll actions - replaceSelection() — insert text at cursor via Monaco executeEdits - getLine()/replaceRange()/listSelections()/operation() — for comment toggle - showHint() — no-op (Monaco handles completions internally) - execCommand('findPersistent'/'replace') — route to Monaco find/replace - getOption('indentWithTabs'/'indentUnit'/'tabSize') — return correct defaults Editor sandbox (Monaco iframe): - Added 'insert-text' message handler for snippet insertion - Added 'action' message handler for undo/redo/fold/find/replace Dashboard fixes: - Fold All/Unfold All use Monaco foldAll()/unfoldAll() instead of CodeMirror loop - Comment toggle uses Monaco's native toggle-comment action - Lint button shows info toast instead of calling missing performLint()
1 parent aefee16 commit 0015843

14 files changed

+98
-30
lines changed

CLAUDE.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Modern userscript manager built with Chrome Manifest V3. Tampermonkey-inspired functionality with cloud sync, auto-updates, a full dashboard, Monaco editor, DevTools panel, and a persistent side panel.
55

66
## Version
7-
v1.7.4
7+
v1.7.5
88

99
## Tech Stack
1010
- Chrome MV3 extension (JavaScript)
@@ -88,8 +88,8 @@ v1.7.4
8888
- `cleanupStaleCaches()` runs on init to prune expired `require_cache_*`, `res_cache_*`, trash entries, and tombstones >30 days
8989
- Lint: `@grant none` + GM API usage shows `warning` severity (upgraded from `info` in v1.7.2). Unknown `@grant` values and invalid `@sandbox` values are `error` severity.
9090
- **Side panel / DevTools must use `action:` key** (not `type:`) for background messages. Background returns `{ scripts: [...] }` — callers need `res?.scripts`. `setScriptSettings` expects `scriptId` not `id`.
91-
- **GM_cookie_set/GM_cookie_delete** require `url` and `name` parameters (validated in v1.7.4)
92-
- **GM_unregisterMenuCommand** handler added in v1.7.4 — previously calls were silently dropped
91+
- **GM_cookie_set/GM_cookie_delete** require `url` and `name` parameters (validated in v1.7.5)
92+
- **GM_unregisterMenuCommand** handler added in v1.7.5 — previously calls were silently dropped
9393
- **XHR local request IDs** use sequential counter `_xhrSeqId++` (not `Math.random`) to prevent collision
9494
- **Notification callbacks** cleaned up on auto-timeout (not all platforms fire `onClosed`)
9595
- **Menu commands** cleaned from session storage when a script is deleted
@@ -163,7 +163,7 @@ v1.7.4
163163
- **Side panel**: responds to `chrome.tabs.onActivated` and `chrome.tabs.onUpdated` to refresh script list on navigation. Uses same `sendToBackground` pattern as popup.
164164
- **DevTools panel**: auto-refreshes every 3s. `getNetworkLog` returns flat array; `getNetworkLogStats` for totals. HAR export uses `URL.createObjectURL` + programmatic `<a>` click.
165165

166-
## v1.7.0 → v1.7.4 Audit (2026-03-24, 4 rounds)
166+
## v1.7.0 → v1.7.5 Audit (2026-03-24, 4 rounds)
167167

168168
### v1.7.0 — Major Feature Release
169169
- DevTools panel, Side panel, Script signing (Ed25519), Monaco editor adapter, Offscreen document
@@ -185,7 +185,7 @@ v1.7.4
185185
- GM_webRequest added to hints + grant values, duplicate hint directives removed
186186
- Dashboard: updated column defaults to desc sort, network log cap 500 -> 2000
187187

188-
### v1.7.4 — Memory Leaks & Validation
188+
### v1.7.5 — Memory Leaks & Validation
189189
- Added missing GM_unregisterMenuCommand handler (calls were silently dropped)
190190
- Menu commands cleaned from session storage on script delete
191191
- Notification callback cleanup on auto-timeout
@@ -232,7 +232,7 @@ v1.7.4
232232
- Fixed: NetworkLog duration calculation used `_netLogEntry.timestamp` which was undefined; replaced with dedicated `_netLogStartTime` variable
233233
- Fixed: `state.folders`, `state._collapsedFolders`, `state._lastCheckedId`, `state._quotaWarned` not initialized in dashboard state object
234234
- Fixed: `switchTab('help')` in command palette failed because help tab is a header icon, not a `.tm-tab`; added special case handling
235-
- Verified: All version strings match (v1.7.4 across manifest, manifest-firefox, content.js, popup.js, dashboard.js)
235+
- Verified: All version strings match (v1.7.5 across manifest, manifest-firefox, content.js, popup.js, dashboard.js)
236236
- Verified: All bg/ modules load before background.core.js in build output
237237
- Verified: `escapeHtml` available in popup.js (shared/utils.js loaded first)
238238
- Verified: Column index mapping still correct after pin button addition (pin is inside actions TD, not a new column)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</p>
1010

1111
<p align="center">
12-
<img src="https://img.shields.io/badge/version-1.7.4-22c55e?style=flat-square" alt="Version">
12+
<img src="https://img.shields.io/badge/version-1.7.5-22c55e?style=flat-square" alt="Version">
1313
<img src="https://img.shields.io/badge/manifest-v3-60a5fa?style=flat-square" alt="Manifest V3">
1414
<img src="https://img.shields.io/badge/license-MIT-orange?style=flat-square" alt="License">
1515
<img src="https://img.shields.io/badge/chrome-120%2B-blue?style=flat-square" alt="Chrome 120+">
@@ -325,6 +325,6 @@ MIT License &mdash; see [LICENSE](LICENSE) for details.
325325
---
326326

327327
<p align="center">
328-
<strong>ScriptVault v1.7.4</strong><br>
328+
<strong>ScriptVault v1.7.5</strong><br>
329329
<em>Your scripts, your rules &mdash; locked down and loaded</em>
330330
</p>

background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ScriptVault v1.7.4 - Background Service Worker
1+
// ScriptVault v1.7.5 - Background Service Worker
22
// Comprehensive userscript manager with cloud sync and auto-updates
33
// NOTE: This file is built from source modules. Edit the individual files in
44
// shared/, modules/, and lib/, then run build-background.sh to regenerate.

content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ScriptVault v1.7.4 - Content Script Bridge
1+
// ScriptVault v1.7.5 - Content Script Bridge
22
// Bridges messages between userscripts (USER_SCRIPT world) and background service worker
33

44
(function() {

manifest-firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "__MSG_extName__",
4-
"version": "1.7.4",
4+
"version": "1.7.5",
55
"description": "__MSG_extDescription__",
66
"default_locale": "en",
77
"homepage_url": "https://github.com/SysAdminDoc/ScriptVault",

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "__MSG_extName__",
4-
"version": "1.7.4",
4+
"version": "1.7.5",
55
"description": "__MSG_extDescription__",
66
"default_locale": "en",
77
"minimum_chrome_version": "120",

offscreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ScriptVault Offscreen Document v1.7.4
1+
// ScriptVault Offscreen Document v1.7.5
22
// Handles CPU-intensive tasks off the service worker:
33
// - AST-based script analysis (via Acorn)
44
// - 3-way text merge for sync conflict resolution

pages/dashboard.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ScriptVault Dashboard v1.7.4 - Full-Featured Controller
1+
// ScriptVault Dashboard v1.7.5 - Full-Featured Controller
22
(function() {
33
'use strict';
44

@@ -3734,17 +3734,25 @@
37343734
elements.tbtnBeautify?.addEventListener('click', beautifyCode);
37353735
elements.tbtnLint?.addEventListener('click', () => {
37363736
if (state.editor) {
3737-
state.editor.performLint();
3738-
showToast('Lint check complete', 'info');
3737+
if (state.editor.isMonaco) {
3738+
showToast('Monaco editor handles diagnostics automatically', 'info');
3739+
} else {
3740+
state.editor.performLint();
3741+
showToast('Lint check complete', 'info');
3742+
}
37393743
}
37403744
});
37413745
elements.tbtnFoldAll?.addEventListener('click', () => {
3742-
if (state.editor) {
3746+
if (state.editor?.isMonaco) {
3747+
state.editor.foldAll();
3748+
} else if (state.editor) {
37433749
for (let i = 0; i < state.editor.lineCount(); i++) state.editor.foldCode(i);
37443750
}
37453751
});
37463752
elements.tbtnUnfoldAll?.addEventListener('click', () => {
3747-
if (state.editor) {
3753+
if (state.editor?.isMonaco) {
3754+
state.editor.unfoldAll();
3755+
} else if (state.editor) {
37483756
for (let i = 0; i < state.editor.lineCount(); i++) {
37493757
try { state.editor.foldCode(i, null, 'unfold'); } catch(e) {}
37503758
}
@@ -3755,26 +3763,28 @@
37553763
// Comment toggle (Ctrl+/)
37563764
document.getElementById('tbtnComment')?.addEventListener('click', () => {
37573765
if (!state.editor) return;
3766+
if (state.editor.isMonaco) {
3767+
state.editor.toggleComment();
3768+
state.unsavedChanges = true;
3769+
return;
3770+
}
37583771
const cm = state.editor;
37593772
const sel = cm.listSelections();
37603773
cm.operation(() => {
37613774
for (const range of sel) {
37623775
const from = Math.min(range.anchor.line, range.head.line);
37633776
const to = Math.max(range.anchor.line, range.head.line);
3764-
// Check if all lines are commented
37653777
let allCommented = true;
37663778
for (let i = from; i <= to; i++) {
37673779
if (!cm.getLine(i).trimStart().startsWith('//')) { allCommented = false; break; }
37683780
}
37693781
for (let i = from; i <= to; i++) {
37703782
const line = cm.getLine(i);
37713783
if (allCommented) {
3772-
// Uncomment
37733784
const idx = line.indexOf('//');
37743785
const after = line[idx + 2] === ' ' ? 3 : 2;
37753786
cm.replaceRange(line.slice(0, idx) + line.slice(idx + after), {line: i, ch: 0}, {line: i, ch: line.length});
37763787
} else {
3777-
// Comment
37783788
cm.replaceRange('// ' + line, {line: i, ch: 0}, {line: i, ch: line.length});
37793789
}
37803790
}

pages/devtools-panel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ScriptVault DevTools Panel v1.7.4
1+
// ScriptVault DevTools Panel v1.7.5
22
// Network inspection, execution profiling, and console capture
33

44
(function () {
@@ -232,7 +232,7 @@
232232
comment: e.scriptName || ''
233233
}));
234234

235-
const har = { log: { version: '1.2', creator: { name: 'ScriptVault', version: '1.7.4' }, entries } };
235+
const har = { log: { version: '1.2', creator: { name: 'ScriptVault', version: '1.7.5' }, entries } };
236236
const blob = new Blob([JSON.stringify(har, null, 2)], { type: 'application/json' });
237237
const url = URL.createObjectURL(blob);
238238
const a = document.createElement('a');

pages/editor-sandbox.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@
221221
case 'set-font-size':
222222
if (editor) editor.updateOptions({ fontSize: msg.size || 13 });
223223
break;
224+
case 'insert-text':
225+
if (editor) {
226+
editor.focus();
227+
const sel = editor.getSelection();
228+
editor.executeEdits('snippet', [{ range: sel, text: msg.text || '', forceMoveMarkers: true }]);
229+
}
230+
break;
231+
case 'action':
232+
if (editor && msg.id) {
233+
const act = editor.getAction(msg.id);
234+
if (act) act.run();
235+
else editor.trigger('adapter', msg.id, null);
236+
}
237+
break;
224238
}
225239
});
226240

0 commit comments

Comments
 (0)