forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 4
/
APA PsycNET.js
705 lines (669 loc) · 22.3 KB
/
APA PsycNET.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
{
"translatorID": "1e1e35be-6264-45a0-ad2e-7212040eb984",
"label": "APA PsycNet",
"creator": "Philipp Zumstein",
"target": "^https?://(psycnet|doi)\\.apa\\.org/",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2022-11-02 16:50:48"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2017-2021 Philipp Zumstein
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
// Some test cases are only working in the browser with some AJAX loading:
// 1) http://psycnet.apa.org/PsycBOOKS/toc/10023
// 2) follow a link in a search
// 3) search page
// 4) journal page
//
// Moreover, after three test cases you have to load an psycnet url in the browser
// to avoid some automatic download detection.
function detectWeb(doc, url) {
if (url.includes('/search/display?')
|| url.includes('/record/')
|| url.includes('/fulltext/')
|| url.includes('/buy/')
|| url.includes('/doiLanding?doi=')) {
if (doc.getElementById('bookchapterstoc')) {
return "book";
}
else if (attr(doc, 'meta[property="og:type"]', 'content') == 'Chapter') {
return "bookSection";
}
else {
return "journalArticle";
}
}
if (url.includes('/search/results?') || url.includes('/journal/')) { // && getSearchResults(doc, true)) {
return "multiple";
}
return false;
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('a.article-title');
for (var i = 0; i < rows.length; i++) {
var href = rows[i].href;
var title = ZU.trimInternal(rows[i].textContent);
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
items[href] = title;
}
return found ? items : false;
}
async function doWeb(doc, url) {
if (detectWeb(doc, url) == "multiple") {
let items = await Zotero.selectItems(getSearchResults(doc, false));
if (!items) {
return;
}
await Promise.all(
Object.keys(items).map(async url => scrape(await requestDocument(url), url))
);
}
else {
await scrape(doc, url);
}
}
async function scrape(doc, url) {
var uid = await getIds(doc, url.replace(/#.*$/, ''));
if (!uid) {
throw new Error("ID not found");
}
var productCode;
var db = doc.getElementById('database') || doc.querySelector('doi-landing .meta span');
if (db) {
db = db.parentNode.textContent.toLowerCase();
if (db.includes('psycarticles')) {
productCode = 'PA';
}
else if (db.includes('psycbooks')) {
productCode = 'PB';
}
else if (db.includes('psycinfo')) {
productCode = 'PI';
}
else if (db.includes('psycextra')) {
productCode = 'PE';
}
}
else {
// default, e.g. if page is not completely loaded
productCode = 'PI';
}
var postData = JSON.stringify({
api: "record.exportRISFile",
params: {
UIDList: [{UID: uid, ProductCode: productCode}],
exportType: "zotero"
}
});
var headers = {
'Content-Type': 'application/json',
Referer: url
};
let apiReturnData = await requestJSON('/api/request/record.exportRISFile', {
method: 'POST',
headers: headers,
body: postData,
});
if (apiReturnData && apiReturnData.isRisExportCreated) {
// 2. Download the requested data (after step 1)
let data = await requestText('/ris/download');
if (data.includes('Content: application/x-research-info-systems')) {
processRIS(data, doc);
}
else {
// sometimes (e.g. during testing) the data is not loaded
// but a meta redirect to a captcha page mentioning
Z.debug("The APA anomaly detection think we are doing "
+ "something unusual (sigh). Please reload any APA page e.g. "
+ "http://psycnet.apa.org/ in your browser and try again.");
Z.debug(data);
}
}
}
function processRIS(text, doc) {
var translator = Zotero.loadTranslator("import");
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
translator.setString(text);
translator.setHandler("itemDone", function (obj, item) {
item.title = cleanTitle(item.title);
if (item.publication) item.publication = cleanTitle(item.publication);
if (item.bookTitle) item.bookTitle = cleanTitle(item.bookTitle);
if (item.series) item.series = cleanTitle(item.series);
if (item.place) item.place = item.place.replace(/\s+/g, ' ');
if (item.ISSN) item.ISSN = ZU.cleanISSN(item.ISSN);
for (var i = 0; i < item.tags.length; i++) {
item.tags[i] = item.tags[i].replace(/^\*/, '');
}
var pdfURL = attr(doc, 'a[href*="/fulltext"]', 'href');
if (pdfURL) {
item.attachments.push({
url: pdfURL,
title: "Full Text PDF",
mimeType: "application/pdf"
});
}
item.attachments.push({
title: "Snapshot",
document: doc
});
item.complete();
});
translator.translate();
}
// try to figure out ids that we can use for fetching RIS
async function getIds(doc, url) {
Z.debug('Finding IDs in ' + url)
// try to extract uid from the table
var uid = text(doc, '#uid + dd') || text(doc, '#bookUID');
if (uid) {
return uid;
}
// try to extract uid from the url
if (url.includes('/record/')) {
let m = url.match(/\/record\/([\d-]*)/);
if (m && m[1]) {
return m[1];
}
}
// DOI landing pages include a link to the /record/ page
if (url.includes('/doiLanding') && doc.querySelector('.title > a')) {
let m = attr(doc, '.title > a', 'href').match(/\/record\/([\d-]*)/);
if (m && m[1]) {
return m[1];
}
}
/** on the book pages, we can find the UID in
* the Front matter and Back matter links
*/
if (url.includes('/PsycBOOKS/')) {
var link = attr(doc, '.bookMatterLinks a', 'href');
if (link) {
let m = link.match(/\/fulltext\/([^&]+?)-(?:FRM|BKM)/i);
if (m && m[1]) {
return m[1];
}
}
}
/** for pages with buy.optionToBuy
* we can fetch the id from the url
* alternatively, the id is in a javascript section (this is messy)
*/
if (url.includes('/buy/')) {
let m = url.match(/\/buy\/([\d-]*)/);
if (m) {
return m[1];
}
m = doc.documentElement.textContent.match(/\bitemUID\s*=\s*(['"])(.*?)\1/);
if (m && m[2]) {
return m[2];
}
}
/** check for a purchase link
*/
var purchaseLink = attr(doc, 'a.purchase[href*="/buy/"]', 'href');
if (purchaseLink) {
let m = purchaseLink.match(/\/buy\/([\d-]*)/);
return m[1];
}
// Worst-case fallback if we're on a search result page: make some requests
if (url.includes('/search/display?')) {
let searchParams = new URL(url).searchParams;
let id = searchParams.get('id');
if (id) {
let searchObj = await requestJSON('/api/request/recentSearch.get', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
api: 'recentSearch.get',
params: {
id
}
})
});
let recordId = parseInt(searchParams.get('recordId'));
let recordWithCount = await requestJSON('/api/request/search.recordWithCount', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
api: 'search.recordWithCount',
params: {
...searchObj,
responseParameters: {
...searchObj.responseParameters,
start: recordId - 1,
rows: 1
}
}
})
});
return recordWithCount.results.result.doc[0].UID;
}
}
return false;
}
function cleanTitle(title) {
// delete point at the end of a title,
// except it looks like an abbreviation
if (/\b\w\.$/.test(title)) {
return title;
}
else {
return title.replace(/\.$/, '');
}
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "http://psycnet.apa.org/record/2004-16644-010",
"items": [
{
"itemType": "journalArticle",
"title": "Neuropsychology of Adults With Attention-Deficit/Hyperactivity Disorder: A Meta-Analytic Review",
"creators": [
{
"lastName": "Hervey",
"firstName": "Aaron S.",
"creatorType": "author"
},
{
"lastName": "Epstein",
"firstName": "Jeffery N.",
"creatorType": "author"
},
{
"lastName": "Curry",
"firstName": "John F.",
"creatorType": "author"
}
],
"date": "2004",
"DOI": "10.1037/0894-4105.18.3.485",
"ISSN": "1931-1559(Electronic),0894-4105(Print)",
"abstractNote": "A comprehensive, empirically based review of the published studies addressing neuropsychological performance in adults diagnosed with attention-deficit/hyperactivity disorder (ADHD) was conducted to identify patterns of performance deficits. Findings from 33 published studies were submitted to a meta-analytic procedure producing sample-size-weighted mean effect sizes across test measures. Results suggest that neuropsychological deficits are expressed in adults with ADHD across multiple domains of functioning, with notable impairments in attention, behavioral inhibition, and memory, whereas normal performance is noted in simple reaction time. Theoretical and developmental considerations are discussed, including the role of behavioral inhibition and working memory impairment. Future directions for research based on these findings are highlighted, including further exploration of specific impairments and an emphasis on particular tests and testing conditions. (PsycINFO Database Record (c) 2016 APA, all rights reserved)",
"issue": "3",
"libraryCatalog": "APA PsycNET",
"pages": "485-503",
"publicationTitle": "Neuropsychology",
"shortTitle": "Neuropsychology of Adults With Attention-Deficit/Hyperactivity Disorder",
"volume": "18",
"attachments": [
{
"title": "Snapshot"
}
],
"tags": [
{
"tag": "Attention Deficit Disorder with Hyperactivity"
},
{
"tag": "Behavioral Inhibition"
},
{
"tag": "Empirical Methods"
},
{
"tag": "Experimentation"
},
{
"tag": "Hyperkinesis"
},
{
"tag": "Inhibition (Personality)"
},
{
"tag": "Neuropsychological Assessment"
},
{
"tag": "Neuropsychology"
},
{
"tag": "Reaction Time"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://psycnet.apa.org/record/1956-05944-001",
"items": [
{
"itemType": "journalArticle",
"title": "Factor analysis of meaning",
"creators": [
{
"lastName": "Osgood",
"firstName": "Charles E.",
"creatorType": "author"
},
{
"lastName": "Suci",
"firstName": "George J.",
"creatorType": "author"
}
],
"date": "1955",
"DOI": "10.1037/h0043965",
"ISSN": "0022-1015(Print)",
"abstractNote": "Two factor analytic studies of meaningful judgments based upon the same sample of 50 bipolar descriptive scales are reported. Both analyses reveal three major connotative factors: evaluation, potency, and activity. These factors appear to be independent dimensions of the semantic space within which the meanings of concepts may be specified. (PsycINFO Database Record (c) 2016 APA, all rights reserved)",
"issue": "5",
"libraryCatalog": "APA PsycNET",
"pages": "325-338",
"publicationTitle": "Journal of Experimental Psychology",
"volume": "50",
"attachments": [
{
"title": "Snapshot"
}
],
"tags": [
{
"tag": "Factor Analysis"
},
{
"tag": "Factor Structure"
},
{
"tag": "Judgment"
},
{
"tag": "Meaning"
},
{
"tag": "Semantics"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://psycnet.apa.org/record/1992-98221-010",
"items": [
{
"itemType": "bookSection",
"title": "Catatonia: Tonic immobility: Evolutionary underpinnings of human catalepsy and catatonia",
"creators": [
{
"lastName": "Gallup Jr.",
"firstName": "Gordon G.",
"creatorType": "author"
},
{
"lastName": "Maser",
"firstName": "Jack D.",
"creatorType": "author"
}
],
"date": "1977",
"ISBN": "9780716703686 9780716703679",
"abstractNote": "tonic immobility [animal hypnosis] might be a useful laboratory analog or research model for catatonia / we have been collaborating on an interdisciplinary program of research in an effort to pinpoint the behavioral antecedents and biological bases for tonic immobility / attempt to briefly summarize our findings, and . . . discuss the implications of these data in terms of the model characteristics of tonic immobility / hypnosis / catatonia, catalepsy, and cataplexy / tonic immobility as a model for catatonia / fear potentiation / fear alleviation / fear or arousal / learned helplessness / neurological correlates / pharmacology and neurochemistry / genetic underpinnings / evolutionary considerations / implications for human psychopathology (PsycINFO Database Record (c) 2016 APA, all rights reserved)",
"bookTitle": "Psychopathology: Experimental models",
"libraryCatalog": "APA PsycNET",
"pages": "334-357",
"place": "New York, NY, US",
"publisher": "W H Freeman/Times Books/ Henry Holt & Co",
"series": "A series of books in psychology",
"shortTitle": "Catatonia",
"attachments": [
{
"title": "Snapshot"
}
],
"tags": [
{
"tag": "Animal Models"
},
{
"tag": "Catalepsy"
},
{
"tag": "Catatonia"
},
{
"tag": "Fear"
},
{
"tag": "Genetics"
},
{
"tag": "Neurology"
},
{
"tag": "Pharmacology"
},
{
"tag": "Tonic Immobility"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://psycnet.apa.org/record/2004-16329-000?doi=1",
"items": [
{
"itemType": "book",
"title": "The abnormal personality: A textbook",
"creators": [
{
"lastName": "White",
"firstName": "Robert W.",
"creatorType": "author"
}
],
"date": "1948",
"abstractNote": "The author's intent is to write about abnormal people in a way that will be valuable and interesting to students new to the subject. A first course in abnormal psychology is not intended to train specialists. Its goal is more general: it should provide the student with the opportunity to whet his interest, expand his horizons, register a certain body of new facts, and relate this to the rest of his knowledge about mankind. I have tried to present the subject in such a way as to emphasize its usefulness to all students of human nature. I have tried the experiment of writing two introductory chapters, one historical and the other clinical. This reflects my desire to set the subject-matter in a broad perspective and at the same time to anchor it in concrete fact. Next comes a block of six chapters designed to set forth the topics of maladjustment and neurosis. The two chapters on psychotherapy complete the more purely psychological or developmental part of the work. In the final chapter the problem of disordered personalities is allowed to expand to its full social dimensions. Treatment, care, and prevention call for social effort and social organization. I have sought to show some of the lines, both professional and nonprofessional, along which this effort can be expended. (PsycINFO Database Record (c) 2016 APA, all rights reserved)",
"extra": "DOI: 10.1037/10023-000",
"libraryCatalog": "APA PsycNET",
"numPages": "x, 617",
"place": "New York, NY, US",
"publisher": "Ronald Press Company",
"series": "The abnormal personality: A textbook",
"shortTitle": "The abnormal personality",
"attachments": [
{
"title": "Snapshot"
}
],
"tags": [
{
"tag": "Abnormal Psychology"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://psycnet.apa.org/buy/2004-16329-002",
"items": [
{
"itemType": "bookSection",
"title": "Clinical introduction: Examples of disordered personalities",
"creators": [
{
"lastName": "White",
"firstName": "Robert W.",
"creatorType": "author"
}
],
"date": "1948",
"abstractNote": "This chapter examines some representative examples of disordered personalities. The reader should be forewarned that the five cases described here will be frequently referred to in later chapters of the book. They display to advantage many of the problems and principles that will occupy us when we undertake to build up a systematic account of abnormal psychology. It will be assumed that the cases given in this chapter are well remembered, and with this in mind the reader should not only go through them but study and compare them rather carefully. The main varieties of disordered personalities and student attitudes toward abnormality are discussed before the case histories are presented. (PsycINFO Database Record (c) 2016 APA, all rights reserved)",
"bookTitle": "The abnormal personality: A textbook",
"extra": "DOI: 10.1037/10023-002",
"libraryCatalog": "APA PsycNET",
"pages": "54-101",
"place": "New York, NY, US",
"publisher": "Ronald Press Company",
"shortTitle": "Clinical introduction",
"attachments": [
{
"title": "Snapshot"
}
],
"tags": [
{
"tag": "Abnormal Psychology"
},
{
"tag": "Personality Disorders"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://psycnet.apa.org/buy/2010-19350-001",
"items": [
{
"itemType": "journalArticle",
"title": "Predicting behavior in economic games by looking through the eyes of the players",
"creators": [
{
"lastName": "Mellers",
"firstName": "Barbara A.",
"creatorType": "author"
},
{
"lastName": "Haselhuhn",
"firstName": "Michael P.",
"creatorType": "author"
},
{
"lastName": "Tetlock",
"firstName": "Philip E.",
"creatorType": "author"
},
{
"lastName": "Silva",
"firstName": "José C.",
"creatorType": "author"
},
{
"lastName": "Isen",
"firstName": "Alice M.",
"creatorType": "author"
}
],
"date": "2010",
"DOI": "10.1037/a0020280",
"ISSN": "1939-2222(Electronic),0096-3445(Print)",
"abstractNote": "Social scientists often rely on economic experiments such as ultimatum and dictator games to understand human cooperation. Systematic deviations from economic predictions have inspired broader conceptions of self-interest that incorporate concerns for fairness. Yet no framework can describe all of the major results. We take a different approach by asking players directly about their self-interest—defined as what they want to do (pleasure-maximizing options). We also ask players directly about their sense of fairness—defined as what they think they ought to do (fairness-maximizing options). Player-defined measures of self-interest and fairness predict (a) the majority of ultimatum-game and dictator-game offers, (b) ultimatum-game rejections, (c) exiting behavior (i.e., escaping social expectations to cooperate) in the dictator game, and (d) who cooperates more after a positive mood induction. Adopting the players' perspectives of self-interest and fairness permits better predictions about who cooperates, why they cooperate, and when they punish noncooperators. (PsycINFO Database Record (c) 2016 APA, all rights reserved)",
"issue": "4",
"libraryCatalog": "APA PsycNET",
"pages": "743-755",
"publicationTitle": "Journal of Experimental Psychology: General",
"volume": "139",
"attachments": [
{
"title": "Snapshot"
}
],
"tags": [
{
"tag": "Behavior"
},
{
"tag": "Cooperation"
},
{
"tag": "Economics"
},
{
"tag": "Emotional States"
},
{
"tag": "Games"
},
{
"tag": "Prediction"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://psycnet.apa.org/record/2010-09295-002",
"items": [
{
"itemType": "bookSection",
"title": "The self in vocational psychology: Object, subject, and project",
"creators": [
{
"lastName": "Savickas",
"firstName": "Mark L.",
"creatorType": "author"
}
],
"date": "2011",
"ISBN": "9781433808616 9781433808623",
"abstractNote": "In this chapter, I seek to redress vocational psychology’s inattention to the self and address the ambiguity of the meaning of self. To begin, I offer a chronological survey of vocational psychology’s three main views of human singularity. During succeeding historical eras, different aspects of human singularity interested vocational psychologists, so they developed a new set of terms and concepts to deal with shifts in the meaning of individuality. Over time, vocational psychology developed what Kuhn (2000) referred to as language communities, each with its own paradigm for understanding the self and vocational behavior. Because the self is fundamentally ambiguous, adherents to each paradigm describe it with an agreed on language and metaphors. Thus, each paradigm has a textual tradition, or way of talking about the self. As readers shall see, when they talk about individuals, differentialists use the language of personality, developmentalists use the language of personhood, and constructionists use the language of identity. (PsycINFO Database Record (c) 2017 APA, all rights reserved)",
"bookTitle": "Developing self in work and career: Concepts, cases, and contexts",
"extra": "DOI: 10.1037/12348-002",
"libraryCatalog": "APA PsycNET",
"pages": "17-33",
"place": "Washington, DC, US",
"publisher": "American Psychological Association",
"shortTitle": "The self in vocational psychology",
"attachments": [
{
"title": "Snapshot"
}
],
"tags": [
{
"tag": "Occupational Guidance"
},
{
"tag": "Personality"
},
{
"tag": "Self-Concept"
}
],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/