Skip to content

修复grant问题#1199

Merged
CodFrm merged 7 commits intorelease/v1.3from
fix/grant-gm
Feb 4, 2026
Merged

修复grant问题#1199
CodFrm merged 7 commits intorelease/v1.3from
fix/grant-gm

Conversation

@CodFrm
Copy link
Member

@CodFrm CodFrm commented Feb 4, 2026

概述 Descriptions

#1169 的 GM_notification 改动有问题,GM.notification与“GM_notification”是不同的

另外新增了异步API的测试,grant授权时 GM.与GM_都会注入

// ==UserScript==
// @name         GM API 完整测试
// @namespace    https://docs.scriptcat.org/
// @version      1.0.0
// @description  全面测试ScriptCat的所有GM API功能
// @author       ScriptCat
// @match        https://content-security-policy.com/
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_deleteValue
// @grant        GM_listValues
// @grant        GM_addValueChangeListener
// @grant        GM_removeValueChangeListener
// @grant        GM_getResourceText
// @grant        GM_getResourceURL
// @grant        GM_addStyle
// @grant        GM_addElement
// @grant        GM_xmlhttpRequest
// @grant        GM_download
// @grant        GM_notification
// @grant        GM_setClipboard
// @grant        GM_info
// @grant        GM_openInTab
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_cookie
// @grant        GM.setValue
// @grant        unsafeWindow
// @run-at       document-start
// ==/UserScript==

console.log(GM, GM.getValue, GM_getValue)

变更内容 Changes

截图 Screenshots

@CodFrm CodFrm changed the base branch from main to release/v1.3 February 4, 2026 09:08
@cyfung1031 cyfung1031 self-requested a review February 4, 2026 09:21
@cyfung1031
Copy link
Collaborator

grant授权时 GM.与GM_都会注入

你不介意这种和 TM 的不一致的话是OK的

@CodFrm
Copy link
Member Author

CodFrm commented Feb 4, 2026

grant授权时 GM.与GM_都会注入

你不介意这种和 TM 的不一致的话是OK的

这是为了和TM一致啊

不过在我印象中,确实TM只根据具体的来,也可能记错成其它管理器了

不过这种更大范围的grant也是可以接受的

@cyfung1031
Copy link
Collaborator

grant授权时 GM.与GM_都会注入

你不介意这种和 TM 的不一致的话是OK的

这是为了和TM一致啊

不过在我印象中,确实TM只根据具体的来,也可能记错成其它管理器了

不过这种更大范围的grant也是可以接受的

TM 是乱来的。不同API对 @grant 的做法也不一样。 有些 GM.@grant 会一整个系列解锁。

for (const grant of scriptGrants) {
// GM. 与 GM_ 都需要注入
__methodInject__(grant);
if (grant.includes("GM.")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以用startWith

@CodFrm CodFrm merged commit b06cf81 into release/v1.3 Feb 4, 2026
1 of 2 checks passed
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.

2 participants