Skip to content

[Compatibility] Async Module Import - Base Path Difference #1708

Description

@cyfung1031

提交前检查

  • 我已经搜索过现有 issues,并确认问题与某个用户脚本或 userscript API 有关

用户脚本链接

触发问题的目标网站

问题表现与对比

Tampermonkey: true + true
ScriptCat: false + false

// ==UserScript==
// @name         Async Module Import Test
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  try to take over the world!
// @author       You
// @match        https://*/*
// @grant        GM_setValue
// ==/UserScript==

// example: https://github.com/scriptscat/
(async function () {
    'use strict';

    let err = "";
    try {
        await import('/js/services/test.js');
    } catch (e) {
        err = `${e?.message || e}`;
    }

    console.log("Async Module Import Test (Absolute Path)", err.includes(new URL('/js/services/test.js', location.href)));
    // example: https://github.com/scriptscat/js/services/test.js

})();

(async function () {
    'use strict';

    let err = "";
    try {
        await import('./js/services/test.js');
    } catch (e) {
        err = `${e?.message || e}`;
    }

    console.log("Async Module Import Test (Relative Path)", err.includes(new URL('./js/services/test.js', location.href)));
    // example: https://github.com/js/services/test.js

})();

用户脚本 metadata

-

ScriptCat 版本

v1.5.0-beta.2

系统 / 浏览器及版本

Helium latest

最小复现脚本 / 日志 / 截图

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    compatibility其它管理器可以运行,脚本猫不能运行userscriptIssues related to userscripts and userscript compatibility

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions