File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ export default class Runtime extends Manager {
187187 tabMap . set ( request . scriptId , menuArr ) ;
188188 }
189189 // 查询菜单是否已经存在
190- for ( let i = 0 ; menuArr . length ; i += 1 ) {
190+ for ( let i = 0 ; i < menuArr . length ; i += 1 ) {
191191 // id 相等 跳过,选第一个,并close链接
192192 if ( menuArr [ i ] . request . params [ 0 ] === request . params [ 0 ] ) {
193193 channel . disChannel ( ) ;
Original file line number Diff line number Diff line change @@ -81,6 +81,24 @@ export function createContext(
8181 if ( val . startsWith ( "GM." ) ) {
8282 const [ , t ] = val . split ( "." ) ;
8383 ( < { [ 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" ) ;
84102 } else {
85103 context [ val ] = api . api . bind ( context ) ;
86104 }
Original file line number Diff line number Diff line change @@ -492,6 +492,18 @@ describe("GM cookie", () => {
492492 }
493493 ) ;
494494 } ) ;
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+ } ) ;
495507 // 在@connect中,但被拒绝
496508 const hookFn = ( createProperties : chrome . tabs . CreateProperties ) => {
497509 // 模拟确认
You can’t perform that action at this time.
0 commit comments