userscripts icon indicating copy to clipboard operation
userscripts copied to clipboard

Proposal: new and better `UserScript` metadata block

Open ACTCD opened this issue 8 months ago • 2 comments

  • https://github.com/quoid/userscripts/issues/821

Once I have the above issue, I have to think, why can't we do the same thing in UserScript?

I think this makes a lot of things easier, especially as a JS developer, writing them is definitely easier and natural.

And parsing object literal strings is much easier than custom format, which JSON5 natively supports it.

Not to mention the benefits of natively adapting to various toolchains such as code highlighting, formatting, linting, etc.

It should also not affect JS runs by default (just an unused variable) and will also be stripped by the manager.

// ==UserScript==
// @name               DEMO.Alert-URL
// @description        Demo user script alert URL.
// @author             Userscripts
// @version            1.0.0
// @match              *://*/*
// @grant              none
// @inject-into        content
// @run-at             document-start
// ==/UserScript==

export const UserScriptMetadata = {
"name":        "DEMO.Alert-URL",
"description": "Demo user script alert URL.",
"author":      "Userscripts",
"version":     "1.0.0",
"match":       "*://*/*",
"grant":       "none",
"injectInto":  "content",
"runAt":       "document-start",
};

export const UserScriptMetadata = {
	name: "DEMO.Alert-URL",
	description: "Demo user script alert URL.",
	author: "Userscripts",
	version: "1.0.0",
	match: "*://*/*",
	grant: "none",
	injectInto: "content",
	runAt: "document-start",
};

(function () {
	"use strict";
	alert("DEBUG.Alert-URL:\n\n" + location);
})();

ACTCD avatar Jun 23 '25 02:06 ACTCD

Reserved

ACTCD avatar Jun 23 '25 02:06 ACTCD

Reserved

ACTCD avatar Jun 23 '25 02:06 ACTCD