File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 "inRepository" : true ,
1010 "translatorType" : 4 ,
1111 "browserSupport" : "gcsibv" ,
12- "lastUpdated" : "2024-02-04 04:24:48 "
12+ "lastUpdated" : "2025-12-22 18:11:41 "
1313}
1414
1515/*
@@ -117,9 +117,20 @@ async function scrape(doc, url = doc.location.href) {
117117 let risURL = `/linkprocessor/v2-ris?recordId=${ recordId } &opid=${ opid } &lang=en` ;
118118 // Z.debug(risURL)
119119
120- // this won't work always
121- let pdfURL = `/linkprocessor/v2-pdf?recordId=${ recordId } &sourceRecordId=${ recordId } &profileIdentifier=${ opid } &intent=download&lang=en` ;
122-
120+ let pdfURL ;
121+ try {
122+ let [ { result } ] = await requestJSON ( `/api/viewer/v6/htmlfulltext/${ recordId } ?opid=${ opid } ` ) ;
123+ let { links } = result ;
124+ Z . debug ( 'Links:' ) ;
125+ Z . debug ( links ) ;
126+ let downloadLink = links [ 'v2-downloadLinks' ] ?. find ( link => link . type === 'pdf' ) ;
127+ if ( ! downloadLink ) downloadLink = links . downloadLinks . find ( link => link . type === 'pdf' ) ;
128+ pdfURL = downloadLink . url ;
129+ }
130+ catch ( e ) {
131+ Zotero . debug ( 'Error while locating PDF download link: ' + e ) ;
132+ pdfURL = `/linkprocessor/v2-pdf?recordId=${ recordId } &sourceRecordId=${ recordId } &profileIdentifier=${ opid } &intent=download&lang=en`
133+ }
123134
124135 let risText = await requestText ( risURL ) ;
125136 // Z.debug(risText)
@@ -143,5 +154,6 @@ async function scrape(doc, url = doc.location.href) {
143154}
144155
145156/** BEGIN TEST CASES **/
146-
157+ var testCases = [
158+ ]
147159/** END TEST CASES **/
You can’t perform that action at this time.
0 commit comments