MCPcopy Index your code
hub / github.com/violentmonkey/violentmonkey / newScript

Function newScript

src/background/utils/script.js:155–177  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

153}
154
155export function newScript(data) {
156 const state = {
157 url: GLOB_ALL,
158 name: '',
159 ...data,
160 };
161 const code = (getOption(kScriptTemplate) || defaults[kScriptTemplate])
162 .replace(/{{(\w+)(?::(.+?))?}}/g, (str, name, format) => state[name] ?? (
163 name !== 'date' ? str
164 : format ? formatDate(format)
165 : new Date().toLocaleString()
166 ));
167 const script = {
168 custom: getDefaultCustom(),
169 config: {
170 enabled: 1,
171 shouldUpdate: 1,
172 },
173 meta: parseMeta(code, { retDefault: true }),
174 props: {},
175 };
176 return { script, code };
177}
178
179export function getNameURI(script) {
180 const ns = script.meta.namespace || '';

Callers 2

parseScriptFunction · 0.90
NewScriptFunction · 0.85

Calls 4

getOptionFunction · 0.90
formatDateFunction · 0.90
getDefaultCustomFunction · 0.85
parseMetaFunction · 0.85

Tested by

no test coverage detected