File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -343,10 +343,16 @@ export default class GMApi extends GM_Base {
343343 details : GMTypes . CookieDetails ,
344344 done : ( cookie : GMTypes . Cookie [ ] | any , error : any | undefined ) => void
345345 ) {
346- // 如果没有url ,自动填充当前url
347- if ( ! details . url ) {
346+ // 如果url和域名都没有 ,自动填充当前url
347+ if ( ! details . url && ! details . domain ) {
348348 details . url = window . location . href ;
349349 }
350+ // 如果是set、delete操作,自动填充当前url
351+ if ( action === "set" || action === "delete" ) {
352+ if ( ! details . url ) {
353+ details . url = window . location . href ;
354+ }
355+ }
350356 a . sendMessage ( "GM_cookie" , [ action , details ] )
351357 . then ( ( resp : any ) => {
352358 done && done ( resp , undefined ) ;
Original file line number Diff line number Diff line change @@ -167,8 +167,8 @@ export default class GMApi {
167167 return true ;
168168 }
169169 const detail = < GMTypes . CookieDetails > request . params [ 1 ] ;
170- if ( ! detail . url ) {
171- throw new Error ( "there must be one of url" ) ;
170+ if ( ! detail . url && ! detail . domain ) {
171+ throw new Error ( "there must be one of url or domain " ) ;
172172 }
173173 let url : URL = < URL > { } ;
174174 if ( detail . url ) {
@@ -214,8 +214,8 @@ export default class GMApi {
214214 if ( detail . domain ) {
215215 detail . domain = detail . domain . trim ( ) ;
216216 }
217- if ( ! detail . url ) {
218- throw new Error ( "there must be one of url" ) ;
217+ if ( ! detail . url && ! detail . domain ) {
218+ throw new Error ( "there must be one of url or domain " ) ;
219219 }
220220 if ( typeof detail . partitionKey !== "object" || detail . partitionKey == null ) {
221221 detail . partitionKey = { } ;
You can’t perform that action at this time.
0 commit comments