Skip to content

Commit 78eefef

Browse files
committed
✅ 调整测试示例
1 parent bfec9c4 commit 78eefef

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

example/tests/gm_api_test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// @grant GM_registerMenuCommand
2525
// @grant GM_unregisterMenuCommand
2626
// @grant GM_cookie
27+
// @grant GM.setValue
2728
// @grant unsafeWindow
2829
// @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js#sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK
2930
// @resource testCSS https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css#sha256=62f74b1cf824a89f03554c638e719594c309b4d8a627a758928c0516fa7890ab
@@ -32,7 +33,7 @@
3233
// @run-at document-start
3334
// ==/UserScript==
3435

35-
(function () {
36+
(async function () {
3637
"use strict";
3738

3839
console.log("%c=== ScriptCat GM API 测试开始 ===", "color: blue; font-size: 16px; font-weight: bold;");
@@ -145,9 +146,9 @@
145146
});
146147

147148
// ============ GM_addValueChangeListener 测试 ============
148-
(async () => {
149+
await (async () => {
149150
await testAsync("GM_addValueChangeListener", () => {
150-
return new Promise((resolve, reject) => {
151+
return new Promise(async (resolve, reject) => {
151152
let listenerId = null;
152153
let timeoutId = null;
153154

@@ -160,7 +161,7 @@
160161
}, 2000);
161162

162163
// 先设置初始值,然后再添加监听器
163-
GM_setValue("test_listener", "initial");
164+
await GM.setValue("test_listener", "initial");
164165
console.log("已设置初始值: initial");
165166

166167
// 使用 setTimeout 确保初始值已完全设置

0 commit comments

Comments
 (0)