Skip to content

[v1.3] feat: 支持 @unwrap#1213

Open
cyfung1031 wants to merge 6 commits intoscriptscat:release/v1.3from
cyfung1031:pr-unwrap-001
Open

[v1.3] feat: 支持 @unwrap#1213
cyfung1031 wants to merge 6 commits intoscriptscat:release/v1.3from
cyfung1031:pr-unwrap-001

Conversation

@cyfung1031
Copy link
Collaborator

@cyfung1031 cyfung1031 commented Feb 7, 2026

文档说明

VM

https://violentmonkey.github.io/api/metadata-block/#unwrap

TM

https://www.tampermonkey.net/documentation.php?locale=en#meta:unwrap

相关历史

简单说明

直接注入,不封装。不使用沙盒。不使用 GM 和 GM API
单纯是利用 脚本管理器 把一些JS代码注入到页面
(注:不跑脚本管理器流程。直接注入即执行。在 @run-at document-start 的设定下会比 @early-start 更优先。这也是其中一个 @unwrap 的价值)

Monaco Editor hint

Screenshot 2026-02-07 at 14 53 50

测试用代码

// ==UserScript==
// @name         A Scriptlet for @unwrap test
// @namespace    none
// @version      2026-02-07
// @description  try to take over the world!
// @author       You
// @match        https://*/*?test_unwrap
// @grant        GM_setValue
// @require      https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js#sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK
// @unwrap
// ==/UserScript==

var test_global_injection = "success"; 
// User can access the variable "test_global_injection" directly in DevTools

(function () {
    const results = {
        GM: {
            expected: "undefined",
            actual: typeof GM,
        },
        GM_setValue: {
            expected: "undefined",
            actual: typeof GM_setValue,
        },
        jQuery: {
            expected: "function",
            actual: typeof jQuery,
        },
    };

    console.group(
        "%c@unwrap Test",
        "color:#0aa;font-weight:bold"
    );

    const table = {};
    let allPass = true;

    for (const key in results) {
        const { expected, actual } = results[key];
        const pass = expected === actual;
        allPass &&= pass;

        table[key] = {
            Expected: expected,
            Actual: actual,
            Result: pass ? "✅ PASS" : "❌ FAIL",
        };
    }

    console.table(table);

    console.log(
        allPass
            ? "%cAll tests passed ✔"
            : "%cSome tests failed ✘",
        `font-weight:bold;color:${allPass ? "green" : "red"}`
    );

    console.groupEnd();
})();

Screenshot 2026-02-07 at 15 16 26

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