Release OpenScript 1.0.3

This commit is contained in:
2026-09-12 22:14:22 -07:00
parent 3697048c6e
commit 1cd7b693ab
10 changed files with 155 additions and 13 deletions

View File

@@ -2,6 +2,13 @@
const SINGLE_KEYS = new Set(['name', 'version', 'description', 'run-at']);
const MULTI_KEYS = new Set(['match', 'require']);
const RUN_AT_OPTIONS = new Set(['document_start', 'document_end', 'document_idle']);
export const getMetaRunAt = code => {
const block = code.match(/\/\/ ==UserScript==([\s\S]*?)\/\/ ==\/UserScript==/)?.[1] || '';
const val = block.match(/\/\/\s*@run-at\s+([\w-]+)/i)?.[1]?.toLowerCase().replace('-', '_');
return RUN_AT_OPTIONS.has(val) ? val : null;
};
export const parseMeta = code => {
const block = code.match(/\/\/ ==UserScript==([\s\S]*?)\/\/ ==\/UserScript==/)?.[1] || '';