zotero-translators/CourtListener.js
Marielle Volz ba1faad434 Update translators 7837c42670
Squashed commit of the following:

commit 7837c4267095812c345c4ea86a3691b10ba07063
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Sun Feb 18 13:27:27 2024 -0500

    Fix CambridgeCore RIS regex. asyncify (#3257)

commit c07d2dfb97a7c5df134310e4a611d2fe85d2982a
Author: Franklin Pezzuti Dyer <46753556+franklindyer@users.noreply.github.com>
Date:   Sat Feb 17 21:01:23 2024 -0700

    Adding Harvard Caselaw Access Project translator (#3230)

    Fixes zotero/translators#3225

commit ee832ffcdad168871a3ea6b0bacce41da72211d2
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Sat Feb 17 22:56:56 2024 -0500

    Fix ORCID ID links appearing in ProQuest author list (#3256)

    https://forums.zotero.org/discussion/111918/link-to-external-site-problem#latest

commit edf44a19431210e4105028d0108cdc55a47038b8
Author: Abe Jellinek <jellinek@berkeley.edu>
Date:   Thu Feb 8 13:05:33 2024 -0500

    ScienceDirect: Capture italics in titles, update tests (#3246)

commit 12021cddbb4b9142c6eb882cc77ef0c88d02e192
Author: Abe Jellinek <jellinek@berkeley.edu>
Date:   Mon Feb 5 13:28:34 2024 -0500

    YouTube: Grab correct creator name on desktop

    https://forums.zotero.org/discussion/111148/saving-youtube-videos-have-the-wrong-director

commit ac6628e8676fff0dfb5372c66e6e6c9a34d3385e
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Sun Feb 4 14:41:35 2024 -0500

    Update EBSCO DL Search (#3248)

    And do a bit more for item type. Reported: https://forums.zotero.org/discussion/111468/zotero-connector-eds-ebsco-discovery-service-not-working-correctly/p1

commit cc94c2f7257b1d157286b6cdaab1074fcb608dcc
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Sun Feb 4 14:39:25 2024 -0500

    Add CourtListener (#3226)

    Closes  #3224

commit d95531014903e2b932834533d19448b3d3355c0e
Author: wolf <owcz@users.noreply.github.com>
Date:   Sat Jan 27 04:17:31 2024 -0500

    Unbreak NYPL translator when annotatedMarc = null (#3237)

    * unbreak when annotatedMarc = null

    * bump timestamp

commit 469b1b0576679e95b9ae065d405490751ca4cb77
Author: Kagami Sascha Rosylight <saschanaz@outlook.com>
Date:   Mon Jan 22 22:51:45 2024 +0100

    Replace newline to space with xargs (#3213)

commit 4a8bd03064a56420dcfa0910791eba1b9447e99a
Author: Kagami Sascha Rosylight <saschanaz@outlook.com>
Date:   Wed Jan 17 18:32:04 2024 +0100

    Wait for `translatorServer.serve()` (#3231)

commit 35fc547908c39f842e09b653f9f51f41b7326798
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Mon Jan 15 23:57:59 2024 -0500

    Fix Retsinformation (#3227)

    after update of internal API.
    Reported: https://forums.zotero.org/discussion/109451/problems-with-translator-retsinformation#latest

commit 564c65cb904ca5a56c94f1332f5551d99b7e08b1
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Mon Jan 15 23:57:13 2024 -0500

    DNB Hotfix (#3228)

    asyncified but left other code like xpaths in place

    reported: https://forums.zotero.org/discussion/110825/translator-deutsche-nationalbibliothek#latest

commit 6b4a4dce60ff4a916da721426a8c54bc76136f0a
Author: Abe Jellinek <jellinek@berkeley.edu>
Date:   Tue Jan 9 20:52:26 2024 -0500

    CI: Use constant extension ID

    Thanks @saschanaz: https://github.com/zotero/translators/pull/3210#issue-2058323242

commit d24b779808c1d14ab8f5815724b09aac9b9d760c
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Mon Jan 8 23:05:06 2024 -0500

    BnF Fix multiples (#3221)

    https://forums.zotero.org/discussion/comment/451953#Comment_451953

commit 8e3f5722e3a0883178dd6f7fe09ef0936b248a71
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Mon Jan 8 23:04:45 2024 -0500

    Fix Rechtspraak.nl (#3220)

    https://forums.zotero.org/discussion/110653/zotero-connector-no-longer-working-rechtspraak-nl/p1

commit c73db0a6b229abae9e4cfac8fe8c12bd35b5f425
Author: Elsa Granger <zeyugao@outlook.com>
Date:   Fri Jan 5 20:41:18 2024 +0800

    Use https when access export.arxiv.org (#3216)

commit 8cc91dcff1c38939b228dbe434d1c96167739eae
Author: Kagami Sascha Rosylight <saschanaz@outlook.com>
Date:   Thu Dec 28 21:05:25 2023 +0100

    Run `npm run lint` only when there's any translator change (#3212)

commit 713999d25c71af0eebdcb54afc61070c9c8b079d
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu Dec 28 06:22:33 2023 -0500

    ScienceDirect: Fix detection on pages with query strings containing "pdf"

    https://forums.zotero.org/discussion/110434/60091619-sciencedirect-author-and-pdf

commit 450efe2d873be12131e33f78e37084264ccf6ed0
Author: Emiliano Heyns <retorquere@users.noreply.github.com>
Date:   Wed Dec 27 11:28:32 2023 +0100

    stock eslint support (#3177)

commit 3ad35cf1e3af379fd13bfdf81be82a2f93202bfb
Author: aborel <alain.borel@epfl.ch>
Date:   Fri Dec 8 10:56:33 2023 +0100

    Zenodo2023 (#3202)

commit 7bf0dfbedea5968bfc10571e99395135f4e43527
Author: jiaojiaodubai <63148861+jiaojiaodubai@users.noreply.github.com>
Date:   Fri Dec 1 17:10:54 2023 +0800

    Adapt to search pages; Update test cases (#3193)

commit db2771d52d89d1480ff98efbd6968565893f2184
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Sun Nov 26 23:23:13 2023 -0500

    EBSCO DL - More URL changes (#3192)

commit eb9fca0787eaa74884bc7f10a1a5186e32ea4b65
Author: l0o0 <linxzh1989@gmail.com>
Date:   Thu Nov 23 15:26:02 2023 +0800

    fix: Update request for exporting CNKI refworks text. Update function to find CNKI database keyword for saving multiple items. Update the matching relationship between dbcode and item type (#3191)

commit 4d6204d400aecb6076da741deb1cd9dfb215f757
Author: zoe-translates <zoe.ma@pm.me>
Date:   Mon Nov 6 23:20:12 2023 +0800

    Update Haaretz (#3176)

commit f4741eca4cb1120a64f4f1b9a5d93d046adae6dc
Author: Peter Coombe <thewub.wiki@googlemail.com>
Date:   Sun Nov 5 21:49:13 2023 +0000

    Hyphenated "access-date" in Wikipedia Citation Templates.js (#3178)

    Wikipedia citation templates have preferred hyphenated "access-date" parameter rather than "accessdate" for many years. See https://en.wikipedia.org/wiki/Help:Citation_Style_1#Access_date

commit fd45efc081bf03bf33af726b46cd83a81770909a
Author: zoe-translates <zoe.ma@pm.me>
Date:   Sat Oct 28 02:36:06 2023 +0800

    Refer/BibIX import: recognize value "Audio" for %0 (type) tag (#3174)

commit 6df218c9b81c2623663408ccca94f3ca677ad206
Author: zoe-translates <zoe.ma@pm.me>
Date:   Sat Oct 28 02:33:06 2023 +0800

    ACS Publications: Fix PDF attachment and supplements; recognize more target pages; efficiency improvements (#3128)

commit 5333a7eb61cd4e11323ebc09fd0fab2affe83e59
Author: Abe Jellinek <jellinek@berkeley.edu>
Date:   Fri Oct 27 12:03:43 2023 -0400

    T&F+NEJM: Support `/doi/10.` pages

    Fixes #3160

commit ccad9be5bdd9dd218f1a578353ae9fda82f7b0e6
Author: zoe-translates <zoe.ma@pm.me>
Date:   Wed Oct 25 01:49:51 2023 +0800

    Cambridge Engage: Fixes for search; minor date normalization (#3166)

commit 0121bf0fce768704fd3de9844d070fc2bce01ef3
Author: zoe-translates <zoe.ma@pm.me>
Date:   Wed Oct 25 01:49:34 2023 +0800

    Cairn.info: Serialize requests; fix PDF attachment URL (#3165)

commit 0fdbcd0fd41c11e4c6de6a48d1bbebfe702d1162
Author: zoe-translates <zoe.ma@pm.me>
Date:   Wed Oct 25 01:48:42 2023 +0800

    Duke Univ. Press: Serialize multiples, add test case (#3167)

commit 5bc9435b63e9135eca8dcc289b35925cc4d854e5
Author: Abe Jellinek <jellinek@berkeley.edu>
Date:   Tue Oct 24 12:13:57 2023 -0400

    CI: Clarify error when run outside a git clone

    find-root's default message is "package.json not found in path", which
    isn't accurate: we look for .git/, not package.json.

commit 9518fb4cddce5f9862a73695a99bc9a5b7f5ff94
Author: vinothk-hw <78914673+vinothk-hw@users.noreply.github.com>
Date:   Thu Oct 19 12:33:40 2023 +0530

    Add translator for AccessScience (#3127)

commit 30dcd15276190aa77a7deecb31e7f26986985269
Author: Lars Willighagen <lars.willighagen@gmail.com>
Date:   Wed Oct 18 16:47:22 2023 +0200

    Add ZOBODAT (#3156)

commit 7c4cc221d9348a2d5ae57615053a1c92f104e30f
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed Oct 18 07:17:53 2023 -0400

    DOI: Serialize DOI Content Negotiation requests

commit 9fd351f0ea2027f608c70c2760493dad8e5658e4
Author: vinothk-hw <78914673+vinothk-hw@users.noreply.github.com>
Date:   Tue Oct 17 02:33:02 2023 +0530

    Update author and multiple scenario (#3125)

commit 606ba8218d7064fc32bad74bec69bcd825343bf8
Author: zoe-translates <zoe.ma@pm.me>
Date:   Wed Sep 27 00:51:27 2023 +0800

    The Atlantic: Remove FW code; update for newer website (#3132)

commit f94af5d875492ccdd7ee3c4fc5bc259c9983fe68
Author: zoe-translates <zoe.ma@pm.me>
Date:   Wed Sep 27 00:18:50 2023 +0800

    ESLint plugin: Allow array (of objects) as search translator input (#3149)

commit 394f5b715d49f3e0b15155b55bb0d907b41d9114
Author: Abe Jellinek <jellinek@berkeley.edu>
Date:   Tue Sep 26 12:11:27 2023 -0400

    CBdL ISBN: Fix error on non-ISBN searches

    Fixes #3147

commit 113b77b14b446f27b04acbfa4ba3d38a99e9c25f
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Sun Sep 24 04:14:34 2023 -0400

    Fix IEEE after site change (#3150)

commit 158299ca47eae90db8c16c52634aeccf2132f233
Author: zoe-translates <zoe.ma@pm.me>
Date:   Sat Sep 23 12:52:37 2023 +0800

    Google Scholar: Add delays between consecutive network requests. (#3043)

    Also:

    * Better emulation of page navigation.
    * Use external services (DOI and ArXiv API) when possible.

commit 7711e87f07452db5dbce144a610d8a3717756263
Author: zoe-translates <zoe.ma@pm.me>
Date:   Fri Sep 22 18:43:39 2023 +0800

    DOI Content Negotiation (search translator): Asyncify, serialize requests (#3148)

    - doSearch() is turned into an async function. Processing of next input
      DOI string only begins after the previous one has been processed. This
      means no more than one request to the CrossRef service is outstanding
      at any time.
    - Add a test case with multiple inputs.

    Cf.
    https://forums.zotero.org/discussion/107976/importing-references-using-doi-failed

commit 8e5c648bb1e2ec58eccbc5b04ab5d1e1e656afdc
Author: aborel <alain.borel@epfl.ch>
Date:   Thu Sep 21 07:41:33 2023 +0200

    New web translator: https://www.e-periodica.ch (#3008)

commit 6a2e0b782580d29fbd1dd57e81984247bc368cf9
Author: Sebastian Karcher <karcher@u.northwestern.edu>
Date:   Wed Sep 20 13:11:32 2023 -0400

    Fix PhilPapers (#3133)

commit f88a29b3f03136d3e42020b8579726dbf9b17652
Author: zoe-translates <zoe.ma@pm.me>
Date:   Mon Sep 18 09:46:48 2023 +0800

    ClinicalTrials.gov: Don't use Array#at(); don't reinvent ZU.strToISO() (#3139)

Bug: T356583
2024-02-20 11:54:54 +00:00

272 行
7.9 KiB
JavaScript

{
"translatorID": "07890a30-866e-452a-ac3e-c19fcb39b597",
"label": "CourtListener",
"creator": "Sebastian Karcher",
"target": "^https?://www\\.courtlistener\\.com",
"minVersion": "5.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2024-02-04 05:00:08"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2024 Sebastian Karcher
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 *****
*/
function detectWeb(doc, url) {
if (url.includes('/opinion/')) {
return 'case';
}
else if (getSearchResults(doc, true)) {
return 'multiple';
}
return false;
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('article > h3 > a');
for (let row of rows) {
let href = row.href;
let title = ZU.trimInternal(row.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;
for (let url of Object.keys(items)) {
await scrape(await requestDocument(url));
}
}
else {
await scrape(doc);
}
}
async function scrape(doc, url = doc.location.href) {
var item = new Zotero.Item('case');
let citeString = text(doc, 'h2');
let title = citeString.match(/^(.+?),\s\d+/);
item.caseName = title ? title[1] : citation;
item.court = text(doc, 'article h3');
item.reporter = text(doc, '.citation .reporter');
item.reporterVolume = text(doc, '.citation .volume');
item.firstPage = text(doc, '.citation .page');
let citation = text(doc, 'center b .citation');
if (!item.reporter && !item.reporterVolume) {
// the reporter elements aren't always tagged. We might have to parse them
// the best version is in the top of the opinion (we always want that for history matching,
// so getting that outside the conditional
// if that's not there, we're parsing from the title of the case
if (!citation) {
citation = citeString.match(/^.+?,\s(\d+.+)/)[1].replace(/\(.+?\)$/, "");
}
let citeExpr = citation.trim().match(/^(\d+)\s((?:[A-Z][a-z]?\.\s?)+(?:[2-3]d)?(?:Supp\.)?)\s(\d{1,4})(,|$)/);
if (citeExpr) {
item.reporterVolume = citeExpr[1];
item.reporter = citeExpr[2];
item.firstPage = citeExpr[3];
}
else {
// if we can't match the reporter elements properly, just write the whole thing to citation.
item.history = citation;
}
}
if (!item.history) {
// if we haven't already written case history, write the part that's not already included in the citation
// there are often stray spaces in either citation, so we need to check for the version without it.
let caseHistory = ZU.xpathText(doc, '//span[@class="meta-data-header" and contains(text(), "Citations:")]/following-sibling::span');
// Z.debug(caseHistory);
if (caseHistory.replace(/\s/g, "").startsWith(citation.replace(/\s/g, ""))
&& !(caseHistory.replace(/\s/g, "") == citation.replace(/\s/g, ""))) {
item.history = caseHistory.trim().replace(/^.+?,/, "");
}
}
// no good selctor for date, author, and docket number, so
let date = ZU.xpathText(doc, '//span[@class="meta-data-header" and contains(text(), "Filed:")]/following-sibling::span');
item.dateDecided = date ? date.trim() : "";
let docket = ZU.xpathText(doc, '//span[@class="meta-data-header" and contains(text(), "Docket Number:")]/following-sibling::span');
item.docketNumber = docket ? docket.trim() : "";
let authors = ZU.xpath(doc, '//span[@class="meta-data-header" and contains(text(), "Author:")]/following-sibling::span');
for (let author of authors) {
item.creators.push(ZU.cleanAuthor(author.textContent.trim(), "author", false));
}
item.url = url.replace(/\/\?.*/, "");
item.attachments.push({ document: doc, title: "Full Text" });
item.extra = "";
item.complete();
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://www.courtlistener.com/opinion/1872757/gibson-v-bossier-city-general-hosp/?type=o&q=testing&type=o&order_by=score%20desc&stat_Precedential=on",
"items": [
{
"itemType": "case",
"caseName": "Gibson v. Bossier City General Hosp.",
"creators": [],
"dateDecided": "November 26th, 1991",
"court": "Louisiana Court of Appeal",
"docketNumber": "22693-CA, 23002-CA",
"firstPage": "1332",
"reporter": "So.2d",
"reporterVolume": "594",
"url": "https://www.courtlistener.com/opinion/1872757/gibson-v-bossier-city-general-hosp",
"attachments": [
{
"title": "Full Text",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.courtlistener.com/opinion/1611405/blackwell-v-power-test-corp/?type=o&type=o&q=testing&order_by=score+desc&stat_Precedential=on&page=3",
"items": [
{
"itemType": "case",
"caseName": "Blackwell v. Power Test Corp.",
"creators": [
{
"firstName": "Henry Curtis",
"lastName": "Meanor",
"creatorType": "author"
}
],
"dateDecided": "August 19th, 1981",
"court": "District Court, D. New Jersey",
"docketNumber": "Civ. A. 80-2227",
"firstPage": "802",
"reporter": "F.Supp.",
"reporterVolume": "540",
"url": "https://www.courtlistener.com/opinion/1611405/blackwell-v-power-test-corp",
"attachments": [
{
"title": "Full Text",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.courtlistener.com/opinion/108284/griggs-v-duke-power-co/?q=testing",
"items": [
{
"itemType": "case",
"caseName": "Griggs v. Duke Power Co.",
"creators": [
{
"firstName": "Warren Earl",
"lastName": "Burger",
"creatorType": "author"
}
],
"dateDecided": "March 8th, 1971",
"court": "Supreme Court of the United States",
"docketNumber": "124",
"firstPage": "424",
"history": "91 S. Ct. 849, 28 L. Ed. 2d 158, 1971 U.S. LEXIS 134",
"reporter": "U.S.",
"reporterVolume": "401",
"url": "https://www.courtlistener.com/opinion/108284/griggs-v-duke-power-co",
"attachments": [
{
"title": "Full Text",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.courtlistener.com/?q=testing",
"items": "multiple"
},
{
"type": "web",
"url": "https://www.courtlistener.com/opinion/3959231/state-v-martin/?q=State%20v.%20Martin&type=o&order_by=score%20desc&stat_Precedential=on",
"items": [
{
"itemType": "case",
"caseName": "State v. Martin",
"creators": [
{
"firstName": "Robert L.",
"lastName": "Black",
"creatorType": "author"
}
],
"dateDecided": "February 9th, 1983",
"court": "Ohio Court of Appeals",
"docketNumber": "C-820238",
"firstPage": "717",
"history": "20 Ohio App. 3d 172",
"reporter": "N.E.2d",
"reporterVolume": "485",
"url": "https://www.courtlistener.com/opinion/3959231/state-v-martin",
"attachments": [
{
"title": "Full Text",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/