Skip to content

Commit

Permalink
fix(district): Attaches pacer_case_id to entry links
Browse files Browse the repository at this point in the history
Adds the `pacer_case_id` as a query parameter to entry links, allowing it to be easily accessible from the URL even if it's not present in the subsequent page's DOM. This will simplify the process of navigating between pages while retaining important case information.
  • Loading branch information
ERosendo committed Sep 18, 2024
1 parent 009217f commit d275956
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Changes:

Fixes:
- Corrected typo in build script, ensuring correct favicon path for Firefox releases([379](https://github.com/freelawproject/recap/issues/379), [397](https://github.com/freelawproject/recap-chrome/pull/397))
- Attaches the pacer_case_id as a query parameter to entry links in District Courts Reports ([369](https://github.com/freelawproject/recap/issues/369), [398](https://github.com/freelawproject/recap-chrome/pull/398)).

For developers:
- Nothing yet
Expand Down
22 changes: 19 additions & 3 deletions src/content_delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,17 +605,33 @@ ContentDelegate.prototype.attachRecapLinkToEligibleDocs = async function () {
if (!result) continue;

let href = `https://storage.courtlistener.com/${result.filepath_local}`;
let recap_link = $('<a/>', {
let recapLink = $('<a/>', {
class: 'recap-inline',
title: 'Available for free from the RECAP Archive.',
href: href,
});
recap_link.append(
recapLink.append(
$('<img/>').attr({
src: chrome.runtime.getURL('assets/images/icon-16.png'),
})
);
recap_link.insertAfter(this.links[i]);
recapLink.insertAfter(this.links[i]);

// Attaches the case ID to the entry link as a query parameter. This allows
// us to access it from the URL, even if it's not available in the
// subsequent page's DOM.
entryLink = this.links[i];
let url = new URL(entryLink.href);
url.searchParams.set('caseId', this.pacer_case_id);
entryLink.setAttribute('href', url.toString());

entryLink.removeAttribute('onclick');
entryLink.setAttribute('target', '_self');
entryLink.dataset.recap =
'Modified by RECAP Extension to add caseId' + 'attribute.';
// clone and replace anchor elements to remove all listeners
let clonedNode = entryLink.cloneNode(true);
entryLink.replaceWith(clonedNode);
}
let spinner = document.getElementById('recap-button-spinner');
if (spinner) {
Expand Down

0 comments on commit d275956

Please sign in to comment.