@@ -270,55 +270,23 @@ async function getSnapshotItem(
270270 return undefined ;
271271}
272272
273- // Update addtional information to the item.
274- // Citations from CNKI, Use keyword: CNKICite
275- async function updateItem (
276- item : Zotero . Item | null ,
277- searchResult : ScrapeSearchResult ,
278- ) : Promise < Zotero . Item | null > {
279- if ( item ) {
280- if ( searchResult . citation ) {
281- ztoolkit . ExtraField . setExtraField (
282- item ,
283- "CNKICite" ,
284- `${ searchResult . citation } ` ,
285- ) ;
286- }
287-
288- if ( searchResult . netFirst ) {
289- ztoolkit . ExtraField . setExtraField (
290- item ,
291- "Status" ,
292- "advance online publication" ,
293- ) ;
294- }
295-
296- // Remove unmatched Zotero fields note.
297- if ( item . getNotes ( ) . length > 0 ) {
298- item . getNotes ( ) . forEach ( async ( nid ) => {
299- const nItem = Zotero . Items . get ( nid ) ;
300- await nItem . eraseTx ( ) ;
301- } ) ;
302- }
303-
304- if ( ! item . getField ( "date" ) && searchResult . date ) {
305- item . setField ( "date" , searchResult . date ) ;
306- }
307- }
308- return item ;
309- }
310-
311273export class CNKI implements ScrapeService {
312274 async search (
313275 searchOption : SearchOption ,
314276 ) : Promise < ScrapeSearchResult [ ] | null > {
315277 ztoolkit . log ( "serch options: " , searchOption ) ;
316278 const postOption = createSearchPostOptions ( searchOption ) ;
317279 let responseText : string ;
280+ const cookieBox = await addon . data . myCookieSandbox . getCNKIHomeCookieBox ( ) ;
281+ ztoolkit . log ( "Cookies in sandbox: " , cookieBox . _cookies ) ;
282+ ztoolkit . log ( addon . taskRunner . runningTask ) ;
283+ addon . taskRunner . runningTask ?. addMsg (
284+ `CNKI site info: ${ Object . keys ( cookieBox . _cookies ) . length } ` ,
285+ ) ;
318286 const resp = await Zotero . HTTP . request ( "POST" , postOption . url , {
319287 headers : postOption . headers ,
320288 body : postOption . data ,
321- cookieSandbox : await addon . data . myCookieSandbox . getCNKIHomeCookieBox ( ) ,
289+ cookieSandbox : cookieBox ,
322290 timeout : 10000 ,
323291 successCodes : [ 200 , 403 ] ,
324292 } ) ;
0 commit comments