@@ -137,12 +137,9 @@ export default class GMApi {
137137 let flag = false ;
138138 if ( request . script . metadata . connect ) {
139139 const { connect } = request . script . metadata ;
140- for ( let i = 0 ; i < connect . length ; i += 1 ) {
141- if ( url . hostname . endsWith ( connect [ i ] ) ) {
142- flag = true ;
143- break ;
144- }
145- }
140+ flag =
141+ connect . indexOf ( "*" ) !== - 1 ||
142+ connect . findIndex ( ( connectHostName ) => url . hostname . endsWith ( connectHostName ) ) !== - 1 ;
146143 }
147144 if ( ! flag ) {
148145 return Promise . reject ( new Error ( "hostname must be in the definition of connect" ) ) ;
@@ -177,6 +174,13 @@ export default class GMApi {
177174 if ( ! detail . url && ! detail . domain ) {
178175 throw new Error ( "there must be one of url or domain" ) ;
179176 }
177+ if ( typeof detail . partitionKey !== "object" || detail . partitionKey == null ) {
178+ detail . partitionKey = { } ;
179+ }
180+ if ( typeof detail . partitionKey . topLevelSite !== "string" ) {
181+ // string | undefined
182+ detail . partitionKey . topLevelSite = undefined ;
183+ }
180184 // 处理tab的storeid
181185 let tabId = sender . getExtMessageSender ( ) . tabId ;
182186 let storeId : string | undefined ;
@@ -189,15 +193,17 @@ export default class GMApi {
189193 }
190194 switch ( param [ 0 ] ) {
191195 case "list" : {
192- return chrome . cookies . getAll ( {
196+ let cookies = await chrome . cookies . getAll ( {
193197 domain : detail . domain ,
194198 name : detail . name ,
195199 path : detail . path ,
196200 secure : detail . secure ,
197201 session : detail . session ,
198202 url : detail . url ,
199203 storeId : storeId ,
204+ partitionKey : detail . partitionKey ,
200205 } ) ;
206+ return cookies ;
201207 }
202208 case "delete" : {
203209 if ( ! detail . url || ! detail . name ) {
@@ -207,6 +213,7 @@ export default class GMApi {
207213 name : detail . name ,
208214 url : detail . url ,
209215 storeId : storeId ,
216+ partitionKey : detail . partitionKey ,
210217 } ) ;
211218 break ;
212219 }
@@ -224,6 +231,7 @@ export default class GMApi {
224231 httpOnly : detail . httpOnly ,
225232 secure : detail . secure ,
226233 storeId : storeId ,
234+ partitionKey : detail . partitionKey ,
227235 } ) ;
228236 break ;
229237 }
0 commit comments