Add optional script version metadata

This commit is contained in:
2026-09-11 14:50:53 -07:00
parent a74a8f60d8
commit fc941ad9d2
4 changed files with 14 additions and 3 deletions

View File

@@ -23,6 +23,7 @@ test('parseMeta extracts only OpenScript metadata', () => {
assert.deepEqual(meta, {
name: 'Test Script',
version: '2.1.0',
description: 'Sample description',
matches: ['https://example.com/*'],
runAt: 'document_start',
@@ -33,6 +34,7 @@ test('parseMeta extracts only OpenScript metadata', () => {
test('parseMeta falls back to defaults when fields are missing', () => {
const meta = parseMeta('// ==UserScript==\n// ==/UserScript==');
assert.equal(meta.name, 'Untitled Script');
assert.equal(meta.version, '');
assert.equal(meta.description, '');
assert.deepEqual(meta.matches, ['*://*/*']);
assert.equal(meta.runAt, 'document_idle');
@@ -137,6 +139,7 @@ test('getBoilerplate is wrapper-free and minimalist', () => {
const template = getBoilerplate('My Script');
assert.ok(template.includes('// @name My Script'));
assert.ok(template.includes("console.log('Running on', location.hostname);"));
for (const legacy of ['@namespace', '@grant', '@version', '@author', '(function'])
for (const legacy of ['@namespace', '@grant', '@author', '(function'])
assert.ok(!template.includes(legacy));
assert.ok(!template.includes('@version'));
});