Skip to content

[Feature] ScriptCat 应能注入 <script type="module">#1487

Draft
cyfung1031 wants to merge 1 commit into
release/v1.4from
feat/script-module
Draft

[Feature] ScriptCat 应能注入 <script type="module">#1487
cyfung1031 wants to merge 1 commit into
release/v1.4from
feat/script-module

Conversation

@cyfung1031
Copy link
Copy Markdown
Collaborator

@cyfung1031 cyfung1031 commented Jun 1, 2026


Close #1486

限制1:预设使用 GM.*。其他自行 const { GM_XXXX } = globalThis
限制2:不能使用 @inject-into content
限制3:CSP 保护的页面不能注入

未确定:restoreJSCodeFromCompiledResource, @unwrap@early-start 的处理

// ==UserScript==
// @name         New Userscript JJMB-1
// @namespace    https://docs.scriptcat.org/
// @version      0.1.0
// @description  try to take over the world!
// @author       You
// @match        https://*/*
// @grant        GM.getValue
// @grant        GM.setValue
// @noframes
// @script-module
// ==/UserScript==

import { chunk } from "https://cdn.jsdelivr.net/npm/lodash-es/+esm";

console.log(chunk(["a", "b", "c", "d"], 2));
// [["a", "b"], ["c", "d"]]

console.log("testing", GM, window === unsafeWindow, GM.getValue, this);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant