Skip to content

Commit a12fe98

Browse files
authored
Add USENIX translator (#3477)
1 parent e0398e9 commit a12fe98

1 file changed

Lines changed: 151 additions & 0 deletions

File tree

USENIX.js

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{
2+
"translatorID": "b97462fa-f20b-4a1e-8a73-3a434a81518b",
3+
"label": "USENIX",
4+
"creator": "Tim Leonhard Storm",
5+
"target": "^https://www\\.usenix\\.org/conference/.*/presentation",
6+
"minVersion": "5.0",
7+
"maxVersion": "",
8+
"priority": 100,
9+
"inRepository": true,
10+
"translatorType": 4,
11+
"browserSupport": "gcsibv",
12+
"lastUpdated": "2025-07-29 16:45:18"
13+
}
14+
15+
/*
16+
***** BEGIN LICENSE BLOCK *****
17+
18+
Copyright © 2025 Tim Leonhard Storm
19+
20+
This file is part of Zotero.
21+
22+
Zotero is free software: you can redistribute it and/or modify
23+
it under the terms of the GNU Affero General Public License as published by
24+
the Free Software Foundation, either version 3 of the License, or
25+
(at your option) any later version.
26+
27+
Zotero is distributed in the hope that it will be useful,
28+
but WITHOUT ANY WARRANTY; without even the implied warranty of
29+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30+
GNU Affero General Public License for more details.
31+
32+
You should have received a copy of the GNU Affero General Public License
33+
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
34+
35+
***** END LICENSE BLOCK *****
36+
*/
37+
/* Remove pairs of unescaped braces (note that braces in title are quite unlikely anyway) */
38+
39+
function stripAllUnescapedBraces(s) {
40+
let prev;
41+
do {
42+
prev = s;
43+
s = s.replace(/(^|[^\\])(\{(.*?)\})/g, (_, before, full, content) => before + content);
44+
} while (s !== prev);
45+
// Unescape \{ and \} to { and }
46+
return s.replace(/\\([{}])/g, '$1');
47+
}
48+
49+
50+
async function scrape(doc) {
51+
let translator = Zotero.loadTranslator('web');
52+
// Embedded Metadata
53+
translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');
54+
translator.setDocument(doc);
55+
translator.setHandler('itemDone', (_obj, item) => {
56+
item.title = stripAllUnescapedBraces(item.title);
57+
item.complete();
58+
});
59+
translator.translate();
60+
}
61+
62+
function detectWeb(doc, url) {
63+
if (url.includes('/presentation/')) {
64+
return 'conferencePaper';
65+
}
66+
return false;
67+
}
68+
69+
async function doWeb(doc, url) {
70+
await scrape(await requestDocument(url));
71+
}
72+
73+
/** BEGIN TEST CASES **/
74+
var testCases = [
75+
{
76+
"type": "web",
77+
"url": "https://www.usenix.org/conference/pepr25/presentation/sharma",
78+
"detectedItemType": "conferencePaper",
79+
"items": [
80+
{
81+
"itemType": "journalArticle",
82+
"title": "Verifying Humanness: Personhood Credentials for the Digital Identity Crisis",
83+
"creators": [
84+
{
85+
"firstName": "Tanusree",
86+
"lastName": "Sharma",
87+
"creatorType": "author"
88+
}
89+
],
90+
"date": "2025",
91+
"language": "en",
92+
"libraryCatalog": "www.usenix.org",
93+
"shortTitle": "Verifying Humanness",
94+
"url": "https://www.usenix.org/conference/pepr25/presentation/sharma",
95+
"attachments": [
96+
{
97+
"title": "Snapshot",
98+
"mimeType": "text/html"
99+
}
100+
],
101+
"tags": [],
102+
"notes": [],
103+
"seeAlso": []
104+
}
105+
]
106+
},
107+
{
108+
"type": "web",
109+
"url": "https://www.usenix.org/conference/usenixsecurity18/presentation/bock",
110+
"items": [
111+
{
112+
"itemType": "conferencePaper",
113+
"title": "Return Of Bleichenbacher’s Oracle Threat (ROBOT)",
114+
"creators": [
115+
{
116+
"firstName": "Hanno",
117+
"lastName": "Böck",
118+
"creatorType": "author"
119+
},
120+
{
121+
"firstName": "Juraj",
122+
"lastName": "Somorovsky",
123+
"creatorType": "author"
124+
},
125+
{
126+
"firstName": "Craig",
127+
"lastName": "Young",
128+
"creatorType": "author"
129+
}
130+
],
131+
"date": "2018",
132+
"ISBN": "9781939133045",
133+
"conferenceName": "27th USENIX Security Symposium (USENIX Security 18)",
134+
"language": "en",
135+
"libraryCatalog": "www.usenix.org",
136+
"pages": "817-849",
137+
"url": "https://www.usenix.org/conference/usenixsecurity18/presentation/bock",
138+
"attachments": [
139+
{
140+
"title": "Full Text PDF",
141+
"mimeType": "application/pdf"
142+
}
143+
],
144+
"tags": [],
145+
"notes": [],
146+
"seeAlso": []
147+
}
148+
]
149+
}
150+
]
151+
/** END TEST CASES **/

0 commit comments

Comments
 (0)