File tree 3 files changed +31
-1
lines changed
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ export default class Runtime extends Manager {
187
187
tabMap . set ( request . scriptId , menuArr ) ;
188
188
}
189
189
// 查询菜单是否已经存在
190
- for ( let i = 0 ; menuArr . length ; i += 1 ) {
190
+ for ( let i = 0 ; i < menuArr . length ; i += 1 ) {
191
191
// id 相等 跳过,选第一个,并close链接
192
192
if ( menuArr [ i ] . request . params [ 0 ] === request . params [ 0 ] ) {
193
193
channel . disChannel ( ) ;
Original file line number Diff line number Diff line change @@ -81,6 +81,24 @@ export function createContext(
81
81
if ( val . startsWith ( "GM." ) ) {
82
82
const [ , t ] = val . split ( "." ) ;
83
83
( < { [ key : string ] : any } > context . GM ) [ t ] = api . api . bind ( context ) ;
84
+ } else if ( val === "GM_cookie" ) {
85
+ // 特殊处理GM_cookie.list之类
86
+ context [ val ] = api . api . bind ( context ) ;
87
+ // eslint-disable-next-line func-names, camelcase
88
+ const GM_cookie = function ( action : string ) {
89
+ return (
90
+ details : GMTypes . CookieDetails ,
91
+ done : (
92
+ cookie : GMTypes . Cookie [ ] | any ,
93
+ error : any | undefined
94
+ ) => void
95
+ ) => {
96
+ return context [ val ] ( action , details , done ) ;
97
+ } ;
98
+ } ;
99
+ context [ val ] . list = GM_cookie ( "list" ) ;
100
+ context [ val ] . delete = GM_cookie ( "delete" ) ;
101
+ context [ val ] . set = GM_cookie ( "set" ) ;
84
102
} else {
85
103
context [ val ] = api . api . bind ( context ) ;
86
104
}
Original file line number Diff line number Diff line change @@ -492,6 +492,18 @@ describe("GM cookie", () => {
492
492
}
493
493
) ;
494
494
} ) ;
495
+ // 测试GM_cookie.list
496
+ await new Promise < void > ( ( resolve ) => {
497
+ // @ts -ignore
498
+ contentApi . GM_cookie . list (
499
+ { url : "https://scriptcat.org" } ,
500
+ // @ts -ignore
501
+ ( value , err ) => {
502
+ expect ( err ) . toEqual ( "hostname must be in the definition of connect" ) ;
503
+ resolve ( ) ;
504
+ }
505
+ ) ;
506
+ } ) ;
495
507
// 在@connect中,但被拒绝
496
508
const hookFn = ( createProperties : chrome . tabs . CreateProperties ) => {
497
509
// 模拟确认
You can’t perform that action at this time.
0 commit comments