freelawproject / recap

This repository is for filing issues on any RECAP-related effort.
https://free.law/recap/
12 stars 4 forks source link

The extension inserts a duplicate recap banner and button to create an alert #318

Closed ERosendo closed 1 year ago

ERosendo commented 1 year ago

The extension inserts the banner and the button to create an alert even when those elements are already created on the docket query page. Here's a picture of the bug:

image

Problem

The issue appears to be related to the PACER.handleDocketQueryUrl() method. This method is called from content_delegate.js and inserts the elements after the request to get docket availability (getAvailabilityForDocket) is completed but there's no logic to check if the elements are already on the page, so if this method is called twice or more times it will keep inserting new banners to the body of the page.

Possible Solution

We could insert logic to check if the banners exist on the page and then remove the old ones to let the extension inserts the new ones. The logic should be something like this:

// get the banner on the page
let banners = document.querySelectorAll('.recap-banner')
// Remove all HTML elements that the extension inserted 
banners.forEach(banner => { banner.remove(); });
mlissner commented 1 year ago

Solution sounds good, thanks Eduardo.