File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 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
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;" ) ;
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
160161 } , 2000 ) ;
161162
162163 // 先设置初始值,然后再添加监听器
163- GM_setValue ( "test_listener" , "initial" ) ;
164+ await GM . setValue ( "test_listener" , "initial" ) ;
164165 console . log ( "已设置初始值: initial" ) ;
165166
166167 // 使用 setTimeout 确保初始值已完全设置
You can’t perform that action at this time.
0 commit comments