Skip to content

[BUG] GM_addElement加载外部脚本失败 #728

@n1nja88888

Description

@n1nja88888

问题描述

我的脚本需要引入一个外部js资源,所以用的GM_addElement API来做,之前在Violent Monkey插件中是可以正常运行的,但是在Script Cat就不行了。感觉应该是二者对这个API实现不同是吗?

具体报错如下:
[GM_addElement](content.js:1 Refused to load the script 'https://g.alicdn.com/AWSC/AWSC/awsc.js' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' chrome-extension://ba9dd7ac-6bbe-473c-a0bf-34f42c0d1a73/". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.)

引入的资源是https://g.alicdn.com/AWSC/AWSC/awsc.js,不知道是不是这个js代码中还会通过创建script标签来继续引入js资源导致报错,但是之前在Violent Monkey是没有这个问题的。

重现步骤

脚本中添加如下代码:

GM_addElement('script', { src: 'https://g.alicdn.com/AWSC/AWSC/awsc.js' })

脚本猫版本

1.1.1

操作系统以及浏览器信息

Windows 11 Version 140.0.7339.81 (Official Build) (64-bit)

补充信息 (选填)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions