33 "label" : "Dagstuhl Research Online Publication Server" ,
44 "creator" : "Philipp Zumstein" ,
55 "target" : "^https?://(www\\.)?drops\\.dagstuhl\\.de/" ,
6- "minVersion" : "3 .0" ,
6+ "minVersion" : "6 .0" ,
77 "maxVersion" : "" ,
88 "priority" : 100 ,
99 "inRepository" : true ,
1010 "translatorType" : 4 ,
1111 "browserSupport" : "gcsibv" ,
12- "lastUpdated" : "2024-11-30 08:38:44 "
12+ "lastUpdated" : "2025-07-19 19:20:18 "
1313}
1414
1515/*
1616 ***** BEGIN LICENSE BLOCK *****
1717
18- Copyright © 2016 Philipp Zumstein
18+ Copyright © 2016-2025 Philipp Zumstein and Zotero contributors
1919
2020 This file is part of Zotero.
2121
3737
3838function detectWeb ( doc , url ) {
3939 if ( url . includes ( '/entities/document/' ) ) {
40- var bibtexEntry = ZU . xpathText ( doc , "//pre[contains(@class, ' bibtex')]" ) ;
40+ let bibtexEntry = text ( doc , 'pre. bibtex') ;
4141 if ( bibtexEntry . includes ( "@InCollection" ) ) {
4242 return "bookSection" ;
4343 }
@@ -56,10 +56,10 @@ function detectWeb(doc, url) {
5656function getSearchResults ( doc , checkOnly ) {
5757 var items = { } ;
5858 var found = false ;
59- var rows = ZU . xpath ( doc , "//a[contains(@ href, ' /entities/document/')]" ) ; //
60- for ( var i = 0 ; i < rows . length ; i ++ ) {
61- var href = rows [ i ] . href ;
62- var title = ZU . trimInternal ( rows [ i ] . textContent ) ;
59+ var rows = doc . querySelectorAll ( 'a[ href*=" /entities/document/"]' ) ;
60+ for ( let row of rows ) {
61+ let href = row . href ;
62+ let title = ZU . trimInternal ( row . textContent ) ;
6363 if ( ! href || ! title ) continue ;
6464 if ( checkOnly ) return true ;
6565 found = true ;
@@ -68,36 +68,34 @@ function getSearchResults(doc, checkOnly) {
6868 return found ? items : false ;
6969}
7070
71-
72- function doWeb ( doc , url ) {
71+ async function doWeb ( doc , url ) {
7372 if ( detectWeb ( doc , url ) == "multiple" ) {
74- Zotero . selectItems ( getSearchResults ( doc , false ) , function ( items ) {
75- if ( ! items ) {
76- return ;
77- }
78- var articles = [ ] ;
79- for ( var i in items ) {
80- articles . push ( i ) ;
81- }
82- ZU . processDocuments ( articles , scrape ) ;
83- } ) ;
73+ let items = await Zotero . selectItems ( getSearchResults ( doc , false ) ) ;
74+ if ( ! items ) return ;
75+ for ( let url of Object . keys ( items ) ) {
76+ await scrape ( await requestDocument ( url ) ) ;
77+ }
8478 }
8579 else {
86- scrape ( doc , url ) ;
80+ await scrape ( doc , url ) ;
8781 }
8882}
8983
90- function scrape ( doc , _ ) {
91- var bibtexEntry = ZU . xpathText ( doc , "//pre[contains(@class, 'bibtex')]" ) ;
92- //Z.debug(bibtexEntry);
93- var pdfurl = ZU . xpathText ( doc , "//section[contains(@class, 'files')]//a[contains(@href, 'pdf')]/@href" ) ;
84+ async function scrape ( doc , _url = doc . location . href ) {
85+ let bibtexEntry = text ( doc , 'pre.bibtex' ) ;
86+ let pdfUrl = attr ( doc , 'meta[name="citation_pdf_url"]' , 'content' ) ;
87+ // One more try in case the meta tag didn't work, there are other tags with the PDF link
88+ if ( ! pdfUrl ) {
89+ Z . debug ( "PDF URL extraction from the meta tag failed, trying other sources." ) ;
90+ pdfUrl = attr ( doc , 'section.files a[href$=".pdf"]' , 'href' ) ;
91+ }
9492
9593 var translator = Zotero . loadTranslator ( "import" ) ;
9694 translator . setTranslator ( "9cb70025-a888-4a29-a210-93ec52da40d4" ) ;
9795 translator . setString ( bibtexEntry ) ;
9896 translator . setHandler ( "itemDone" , function ( obj , item ) {
99- //if a note is just a list of keywords, then save them as tags
100- //and delete this note
97+ // If a note is just a list of keywords, then save them as tags
98+ // and delete this note
10199 for ( var i = 0 ; i < item . notes . length ; i ++ ) {
102100 var note = item . notes [ i ] . note ;
103101 if ( note . includes ( 'Keywords:' ) ) {
@@ -115,17 +113,17 @@ function scrape(doc, _) {
115113 document : doc
116114 } ) ;
117115
118- if ( pdfurl ) {
116+ if ( pdfUrl ) {
119117 item . attachments . push ( {
120- url : pdfurl ,
118+ url : pdfUrl ,
121119 title : "Full Text PDF" ,
122120 mimeType : "application/pdf"
123121 } ) ;
124122 }
125123
126124 item . complete ( ) ;
127125 } ) ;
128- translator . translate ( ) ;
126+ await translator . translate ( ) ;
129127}
130128
131129/** BEGIN TEST CASES **/
0 commit comments