Skip to content

Commit

Permalink
feat(toolbar): Show warning sign in ACMS websites
Browse files Browse the repository at this point in the history
  • Loading branch information
ERosendo committed Sep 27, 2023
1 parent 6a7b497 commit 0b9196e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 49 deletions.
98 changes: 51 additions & 47 deletions src/pacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ let PACER = {
return null;
},

isACMSWebsite: function(url){
return url.toLowerCase().includes('azurewebsites.us');
},

// Returns true if the URL is for the login page
isLoginPage: function(url) {
return this.getCourtFromUrl(url) === 'login';
Expand Down Expand Up @@ -149,7 +153,7 @@ let PACER = {
//
// Into:
//
// 1201032
// 1201032

if (!docket_number){
return "";
Expand All @@ -161,7 +165,7 @@ let PACER = {
if (district_m){
return `${district_m[1]}${district_m[2].padStart(5,0)}`;
}

bankr_m = docket_number.match(/(\d\d)-(\d+)/);
if (bankr_m){
//Pad to six characters because some courts have a LOT of bankruptcies
Expand All @@ -170,16 +174,16 @@ let PACER = {

return "";
},

// Returns true if the URL is for docket query page.
isDocketQueryUrl: function (url) {
// There are two pages that use the DktRpt.pl url that we want to match:
// - The docket query page: /DktRpt.pl?115206
// - The docket report page: /DktRpt.pl?caseNumber=1:17-cv-10577&caseId=0
//
//
// And one page that uses DktRpt.pl that we don't want to match:
// - The docket page itself: /DktRpt.pl?591030040473392-L_1_0-1
//
//
// Thus, this regex matches URLs that have a query string with only digits
// or that has one or multiple parameters separated by the ampersand ("&").
//
Expand All @@ -203,9 +207,9 @@ let PACER = {

// Returns true if the URL is for the iquery summary page.
isIQuerySummaryURL: function(url){
// The URL for the iquery summary page shows a list of possibles reports related
// to a case in CM/ECF and has the word "iquery.pl" in it, also has a query string
// with numbers, a letter and hyphens, so this method will return true when the url
// The URL for the iquery summary page shows a list of possibles reports related
// to a case in CM/ECF and has the word "iquery.pl" in it, also has a query string
// with numbers, a letter and hyphens, so this method will return true when the url
// is similar to the following one:
//
// https://ecf.mied.uscourts.gov/cgi-bin/iquery.pl?135881001931855-L_1_0-1
Expand All @@ -225,15 +229,15 @@ let PACER = {
//
// https://ecf.mied.uscourts.gov/cgi-bin/iquery.pl
//
// and the URL for list of possibles reports related to a case that is found with
// and the URL for list of possibles reports related to a case that is found with
// the query form is:
//
// https://ecf.mied.uscourts.gov/cgi-bin/iquery.pl?900473201618068-L_1_0-1
//
// This function checks if the URL has a query string and is related to the iQuery form.
//
// This function checks if the URL has a query string and is related to the iQuery form.
// It will return true only when the url match the format of the first example and it will
// exclude pages that include the iquery word but has a query string like the last example.

return /iquery.pl/.test(url) && !/[?&]/.test(url)
},

Expand All @@ -246,11 +250,11 @@ let PACER = {
areTransactionReceiptsDisabled: function(cookie){
return cookie && cookie.value.match(/receipt=N/)
},

// Returns true if the description in the Transaction Receipt table is 'Search'
isSearchPage: function(){
return this.hasTransactionReceipt && !!$('td>font:contains(Search)').length;
},
},

// Returns true if the user reaches the 'Select a Person' page
isSelectAPersonPage: function(){
Expand All @@ -260,15 +264,15 @@ let PACER = {
//
// This function checks the description in the transaction receipt and the title of the page to
// to identify the 'select a person' page.

let title = document.querySelector('#cmecfMainContent>h2');
return this.isSearchPage() && /Select a Person/i.test(title.innerHTML);
},

// Returns true if the user reaches the 'Case selection' page.
isCaseQueryAdvance: function(){
// In district court PACER, the users usually reach the case selection page directly if they avoid
// using the first/middle/last name fields in the iquery form, they reach the select a person page
// In district court PACER, the users usually reach the case selection page directly if they avoid
// using the first/middle/last name fields in the iquery form, they reach the select a person page
// otherwise.
//
// In bankruptcy court PACER, the users always reach this page after they submit the iquery form.
Expand All @@ -289,16 +293,16 @@ let PACER = {
//
// https://ecf.dcd.uscourts.gov/cgi-bin/DktRpt.pl?178502
//
// The case id is found after the start of the query string (after the '?') in
// The case id is found after the start of the query string (after the '?') in
// the previous URL, but the URL for the docket report accessed through the reports
// menu doesn’t have a query string so one example of that URL is:
//
// https://ecf.dcd.uscourts.gov/cgi-bin/DktRpt.pl
//
// This function checks if the URL has a query string and is related to the docket
//
// This function checks if the URL has a query string and is related to the docket
// report. if the URL has the same format as the first example, the function will return
// the same URL but, for those URL like the last example, it will append the query string
// separator and the case id to make sure every URL has the format expected by the
// the same URL but, for those URL like the last example, it will append the query string
// separator and the case id to make sure every URL has the format expected by the
// ContentDelegate class
if (!/DktRpt.pl/.test(url)){ return url }

Expand Down Expand Up @@ -332,7 +336,7 @@ let PACER = {
let paragraphs = mainContent.getElementsByTagName("p");
let topNote = paragraphs.length ? paragraphs[0].textContent.includes('Document Selection Menu') : false
let bottomNote = mainContent.lastChild.textContent.includes('view each document individually');
let pageCheck = PACER.isDocumentUrl(url) && (
let pageCheck = PACER.isDocumentUrl(url) && (
!!buttonText || !!bigFile || !!topNote || !!bottomNote);
return !!pageCheck;
},
Expand All @@ -347,7 +351,7 @@ let PACER = {
inputs[inputs.length-1].value === "Download Documents"
return !!pageCheck
},

// Returns true if this is a combined PDF page (confirmation of
// pricing for all documents to receive a combined PDF file with
// all of them)
Expand All @@ -367,7 +371,7 @@ let PACER = {

return !!pageCheck;
},

// Claims Register Page includes an h2 tag with the court and words "Claims Register"
// exampleUrl: https://ecf.nyeb.uscourts.gov/cgi-bin/SearchClaims.pl?610550152546515-L_1_0-1
// exampleHeader: <h2>Eastern District of New York<br>Claims Register </h2>
Expand Down Expand Up @@ -428,13 +432,13 @@ let PACER = {
// End this function early if there are no anchor tags
if (!anchors.length){ return null; }
let lastAnchor = anchors[anchors.length-1]
// the next sequence of statements will match the digits at the end of the href.
// the next sequence of statements will match the digits at the end of the href.
// The href attribute of the anchor tags in the table has the following format:
//
// https://ecf.mied.uscourts.gov/cgi-bin/qryDocument.pl?360406
//
// We can grab the pacer case ID from this url if we get all the digits after the ?.

let queryString = lastAnchor.href.match(/[\d]+/g);
return queryString[queryString.length-1]
},
Expand Down Expand Up @@ -582,7 +586,7 @@ let PACER = {
[, params.doc_id, params.case_id] = doDocPost;
}else{
[, params.doc_id] = doDocPostAttachment;
params.case_id = null
params.case_id = null
}
return params;
},
Expand Down Expand Up @@ -614,15 +618,15 @@ let PACER = {
let banners = document.querySelectorAll('.recap-banner')
banners.forEach(banner => { banner.remove() });
},

// returns data from receipt table as an object
parseDataFromReceipt: () => {
// this method uses regex expressions to match that the docket number, document number and the attachment
// this method uses regex expressions to match that the docket number, document number and the attachment
// number from the receipt table and returns an object with the following attributes:
// - docket_number
// - doc_number
// - att_number

let audio_string = $('td:contains(AUDIO)').text();
let image_string = $('td:contains(Image)').text();
let transcript_string = $('td:contains(TRANSCRIPT)').text();
Expand All @@ -642,7 +646,7 @@ let PACER = {

// returns HTML to create a full page iframe that loads the url passed as an argument
makeFullPageIFrame: (url) => {
return `<style>body { margin: 0; padding: 0; height: 100%; overflow: hidden; } iframe { border: none; }</style>
return `<style>body { margin: 0; padding: 0; height: 100%; overflow: hidden; } iframe { border: none; }</style>
<div class='full-page-iframe'>
<iframe src="${url}" width="100%" height="100%" frameborder="0"></iframe>
</div>`;
Expand All @@ -651,9 +655,9 @@ let PACER = {
// removes whitespace and returns a number
cleanDocLinkNumber: (number) => {
// Converts links numbers like:
// - 89
// - 89
// - &nbsp;89&nbsp;
// - &nbsp; 89 &nbsp;
// - &nbsp; 89 &nbsp;
//
// into:
//
Expand All @@ -666,23 +670,23 @@ let PACER = {
return match[1];
},

// return the document number of a document link
// return the document number of a document link
getDocNumberFromAnchor: function (anchor) {
// Document links from the full docket report and the general docket
// report take the following shape (most of the time):
//
// Document links from the full docket report and the general docket
// report take the following shape (most of the time):
//
// <a
// href="https://ecf.cafc.uscourts.gov/docs1/01301646325"
// onclick="return doDocPostURL('01301646325','16239');"
// title="Open Document"
// >
// &nbsp;1&nbsp;
// </a>
//
//
// This method returns the number inside the anchor tag without whitespace

if (anchor.childElementCount) {
// Pacer pages that have docket entry number turned off show an
// Pacer pages that have docket entry number turned off show an
// image inside the anchor element. We want to avoid these cases.
return null;
}
Expand All @@ -693,28 +697,28 @@ let PACER = {
// returns the attachment number of a document link
getAttachmentNumberFromAnchor: function (anchor) {
// The attachment number is not inside the anchor tag that has the document link as in
// the docket report, but We can get this number if we access the row that contains the
// the docket report, but We can get this number if we access the row that contains the
// link. Each row of the attachment menu has the following information:
//
//
// - A checkbox (optional, not all attachment tables has this checkbox)
// - The Attachment number
// - The Attachment number
// - The document Link
// - A description
// - A description
// - The number of pages
//
// Each row of the docket report has the following information:
//
// - filed date
// - docket entry number
// - A description
//
//
// We can use the number of elements per row to group the possible cases:
//
// - Rows with 3 or less elements belong to a docket report.
// - Rows with 3 or less elements belong to a docket report.
// - Rows with four or five elements belong to an attachment menu.
//
// This method accesses the tr element that contains the document link, checks the number
// of elements inside this tag (we want to exclude rows from docket reports) and returns the
// of elements inside this tag (we want to exclude rows from docket reports) and returns the
// attachment number of the document.

let row = anchor.parentNode.parentNode;
Expand Down
10 changes: 8 additions & 2 deletions src/toolbar_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,19 @@ function updateToolbarButton(tab) {
'38': 'assets/images/disabled-38.png'
});
} else {
// Is it a PACER URL?
let court = PACER.getCourtFromUrl(tab.url);
if (!court) {
// Not a PACER URL. Show gray.
setTitleIcon('Not at a PACER site', {
'19': 'assets/images/grey-19.png',
'38': 'assets/images/grey-38.png'
});
} else if (PACER.isACMSWebsite(tab.url)) {
// ACMS website. Show warning.
setTitleIcon('ACMS is not supported', {
'19': 'assets/images/warning-19.png',
'38': 'assets/images/warning-38.png'
});
} else {
// It's a valid PACER URL. Therefore either show the nice blue icon or
// show the blue icon with a warning, if receipts are disabled.
Expand All @@ -72,7 +77,8 @@ function updateToolbarButton(tab) {
'19': 'assets/images/warning-19.png',
'38': 'assets/images/warning-38.png'
});
} else {
}
else {
// At PACER, and things look good!
setTitleIcon('Logged in to PACER. RECAP is active.', {
'19': 'assets/images/icon-19.png',
Expand Down

0 comments on commit 0b9196e

Please sign in to comment.