Skip to content

Commit

Permalink
Revert merge #36.
Browse files Browse the repository at this point in the history
Unfortunately necessary to get a the fundraiser version out the door.
  • Loading branch information
mlissner committed Dec 21, 2017
1 parent ec02883 commit 892634c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 121 deletions.
2 changes: 1 addition & 1 deletion content.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ if (PACER.hasPacerCookie(document.cookie)) {
// available. If there is, put a link with a RECAP icon.
content_delegate.attachRecapLinkToEligibleDocs();
} else {
console.info(`RECAP: Taking no actions because not logged in: `+url);
console.info(`RECAP: Taking no actions because not logged in.`);
}
50 changes: 7 additions & 43 deletions content_delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,9 @@ ContentDelegate.prototype.findAndStorePacerDocIds = function() {

let onclick = link.getAttribute('onclick');
let goDLS = PACER.parseGoDLSFunction(onclick);

// In Appellate NextGen, we have a similiar pattern:
// <a
// href="https://ecf.ca1.uscourts.gov/docs1/00107150550"
// onclick="return doDocPostURL('00107150550','41182');"
// title="Open Document">
// <img src="TransportRoom?servlet=document.gif" alt="Open Document" width="13" border="1" height="15">
// </a>
// and defined as (in TransportRoom?servlet=ShowPagePublic):
// function doDocPostURL(dls, caseIdStr){
// aWin = window.open("TransportRoom?servlet=ShowDoc&dls_id="+dls+
// "&caseId="+caseIdStr+"&dktType=dktPublic",
// "_blank","location=no,resizable,toolbar,status,scrollbars",false);
// return false;
// }

// xxx use array destructuring
let goDPU = onclick.match(/doDocPostURL\('([^']*)','([^]*)'\)/);

if (goDLS.de_caseid) {
docsToCases[pacer_doc_id] = goDLS.de_caseid;
debug(3, 'Y doc ' + pacer_doc_id + ' to ' + goDLS.de_caseid);
// for now, better to keep CL caseid = ECF docketid, not internal caseid.
// } else if (goDPU && goDPU[2]) {
// docsToCases[pacer_doc_id] = goDPU[2];
// debug(4, 'A doc ' + pacer_doc_id + ' to ' + goDLS[2]);
} else if (page_pacer_case_id) {
docsToCases[pacer_doc_id] = page_pacer_case_id;
debug(3,'X doc ' + pacer_doc_id + ' to '
Expand Down Expand Up @@ -146,7 +123,6 @@ ContentDelegate.prototype.handleDocketDisplayPage = function() {
// If it's not a docket display URL or a docket history URL, punt.
return;
}
let isAppellate = PACER.isAppellateCourt(this.court);
if (!this.pacer_case_id) {
// If we don't have the pacer_case_id, punt.
return;
Expand All @@ -165,8 +141,7 @@ ContentDelegate.prototype.handleDocketDisplayPage = function() {
}, this);
if (isDocketDisplayUrl){
this.recap.uploadDocket(this.court, this.pacer_case_id,
document.documentElement.innerHTML,
(isAppellate?'APPELLATE_DOCKET':'DOCKET'),
document.documentElement.innerHTML, 'DOCKET',
callback);
} else if (isDocketHistoryDisplayUrl) {
this.recap.uploadDocket(this.court, this.pacer_case_id,
Expand Down Expand Up @@ -255,18 +230,12 @@ ContentDelegate.prototype.onDocumentViewSubmit = function (event) {
document.forms[0].setAttribute('onsubmit', originalSubmit);

// Grab the document number, attachment number, and docket number
let document_number, attachment_number, docket_number;

if (!PACER.isAppellateCourt(this.court)) {
let image_string = $('td:contains(Image)').text();
let regex = /(\d+)-(\d+)/;
let matches = regex.exec(image_string);
document_number = matches[1];
attachment_number = matches[2];
docket_number = $.trim($('tr:contains(Case Number) td:nth(1)').text());
} else { // Appellate
debug(4,"Appellate parsing not yet implemented");
}
let image_string = $('td:contains(Image)').text();
let regex = /(\d+)-(\d+)/;
let matches = regex.exec(image_string);
let document_number = matches[1];
let attachment_number = matches[2];
let docket_number = $.trim($('tr:contains(Case Number) td:nth(1)').text())

// Now do the form request to get to the view page. Some PACER sites will
// return an HTML page containing an <iframe> that loads the PDF document;
Expand Down Expand Up @@ -424,11 +393,6 @@ ContentDelegate.prototype.handleSingleDocumentPageView = function() {
return;
}

if (PACER.isAppellateCourt(this.court)) {
debug(4,"No interposition for appellate downloads yet");
return;
}

// Monkey-patch the <form> prototype so that its submit() method sends a
// message to this content script instead of submitting the form. To do this
// in the page context instead of this script's, we inject a <script> element.
Expand Down
77 changes: 7 additions & 70 deletions pacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,10 @@ let PACER = {
},

// Returns true if the given URL looks like a link to a PACER document.
// For CMECF District:
// https://ecf.dcd.uscourts.gov/doc1/04503837920
// For CMECF Appellate:
// https://ecf.ca2.uscourts.gov/docs1/00205695758
isDocumentUrl: function (url) {
if (
url.match(/\/(?:doc1|docs1)\/\d+/) ||
url.match(/\/cgi-bin\/show_doc/) ||
url.match(/servlet=ShowDoc/)
url.match(/\/doc1\/\d+/) ||
url.match(/\/cgi-bin\/show_doc/)
) {
if (PACER.getCourtFromUrl(url)) {
return true;
Expand All @@ -76,45 +71,7 @@ let PACER = {
// after submitting the "Docket Sheet" query page).
isDocketDisplayUrl: function (url) {
// The part after the "?" has hyphens in it.
// https://ecf.dcd.uscourts.gov/cgi-bin/DktRpt.pl?591030040473392-L_1_0-1
// Appellate:
// https://ecf.ca1.uscourts.gov/n/beam/servlet/TransportRoom?servlet=CaseSummary.jsp&caseNum=16-1567&incOrigDkt=Y&incDktEntries=Y
if (url.match(/\/DktRpt\.pl\?\w+-[\w-]+$/)) { return true; }
let match;
//
if (match = url.match(/servlet\/TransportRoom(?:\?servlet=([^?&]+)(?:[\/&#;].*)?)?$/)) {
let servlet = match[1];
debug(4, `Identified appellate servlet ${servlet} at ${url}`);

switch(servlet) {
case 'CaseSummary.jsp':
case 'ShowPage': // what is this?
case undefined:
return true;
break;

default:
debug(4, `Assuming servlet ${servlet} is not a docket.`);
case 'CaseSearch.jsp':
case 'ShowDoc':
case 'ShowDocMulti':
case 'CaseSelectionTable':
case 'CourtInfo.jsp':
case 'DocketReportFilter.jsp':
case 'InvalidUserLogin.jsp':
case 'OrderJudgment.jsp':
case 'PACERCalendar.jsp':
case 'PacerHelp.jsp':
case 'PACEROpinion.jsp':
case 'Login':
case 'k2aframe.jsp': // attorney/java?
case 'k2ajnlp.jsp':
case 'RSSGenerator': // maybe we should upload rss?
case 'PaymentHistory':
case 'ChangeClient.jsp':
return false;
}
}
return !!url.match(/\/DktRpt\.pl\?\w+-[\w-]+$/);
},

// Returns true if the given URL is for a docket history display page.
Expand All @@ -133,23 +90,17 @@ let PACER = {
},

// Returns true if this is a page for downloading a single document.
// district:
// https://ecf.dcd.uscourts.gov/doc1/04503837920
// appellate:
// https://ecf.ca1.uscourts.gov/n/beam/servlet/TransportRoom?servlet=ShowDoc&dls_id=00107215565&caseId=41182&dktType=dktPublic
isSingleDocumentPage: function (url, document) {
let inputs = document.getElementsByTagName('input');
let lastInput = inputs.length && inputs[inputs.length - 1].value;
let pageCheck = (PACER.isDocumentUrl(url) &&
(lastInput === 'View Document') ||
(lastInput === 'Accept Charges and Retrieve'));
debug(4," lastInput "+lastInput);
let pageCheck = PACER.isDocumentUrl(url) &&
inputs.length &&
inputs[inputs.length - 1].value === 'View Document';
return !!pageCheck;
},

// Returns the document ID for a document view page or single-document page.
getDocumentIdFromUrl: function (url) {
let match = (url || '').match(/\/(?:doc1|docs1)\/(\d+)/);
let match = (url || '').match(/\/doc1\/(\d+)/);
if (match) {
// PACER sites use the fourth digit of the pacer_doc_id to flag whether
// the user has been shown a receipt page. We don't care about that, so
Expand Down Expand Up @@ -185,9 +136,6 @@ let PACER = {
// JS is trash. It lacks a way of getting the TLD, so we use endsWith.
if (hostname.endsWith('uscourts.gov')) {
for (let re of [
// Appellate CMECF sends us some odd URLs, be aware:
// https://ecf.mad.uscourts.gov/cgi-bin/DktRpt.pl?caseNumber=1:17-cv-11842-PBS&caseId=0
// https://ecf.mad.uscourts.gov/cgi-bin/DktRpt.pl?caseNumber=1:17-cv-11842-PBS&caseId=1:17-cv-11842-PBS
/[?&]caseid=(\d+)/i, // match on caseid GET param
/\?(\d+)(?:&.*)?$/, // match on DktRpt.pl?178502&blah urls
]){
Expand All @@ -202,17 +150,6 @@ let PACER = {
return match[1];
}
}
// xxx does not match style above.
let match;
if (match = url.match(/[?&]caseNum=([-\d]+)/)) {
// Appellate. Actually this is a docket number. Uhoh? xxx
debug(3, "Found caseNum via: " + match[0]);
return match[1];
} else if (match = url.match(/[?&]caseId=([-\d]+)/)) {
debug(3, "Found caseId via: " + match[0]);
// Also seen in appellate. Note upppercase 'I' and hyphens. Actual caseID. xxx
return match[1];
}
}
}
},
Expand Down
12 changes: 5 additions & 7 deletions recap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ function Recap() {
var DEBUG=false, // When true, don't publish what's sent to the archive.
SERVER_ROOT = 'https://www.courtlistener.com/api/rest/v3/',
UPLOAD_TYPES = {
'DOCKET': 1,
'ATTACHMENT_PAGE': 2,
'PDF': 3,
'DOCKET_HISTORY_REPORT': 4,
'APPELLATE_DOCKET': 5,
'APPELLATE_ATTACHMENT_PAGE': 6,
};
'DOCKET': 1,
'ATTACHMENT_PAGE': 2,
'PDF': 3,
'DOCKET_HISTORY_REPORT': 4
};

return {
//Given a pacer_doc_id, return the pacer_case_id that it is associated with
Expand Down

0 comments on commit 892634c

Please sign in to comment.