refined-github / refined-github

:octocat: Browser extension that simplifies the GitHub interface and adds useful features
MIT License
24.27k stars 1.47k forks source link

`clean-repo-sidebar` throws an error in attempting to move a nonexistent report link #6648

Closed DanielMiao1 closed 1 year ago

DanielMiao1 commented 1 year ago

Description

In the clean-repo-sidebar feature, the following code (source link) was introduced to the moveReportLink function in #6500 to select the "Report repository" button, which is used afterwards to move it to the bottom of the sidebar:

const reportLink = select('.Layout-sidebar a[href^="/contact/report-content"]')!.parentElement!;

However, the code throws an error due to the non-null assertion operator when the select function above returns an null value in repositories owned by the user (see figures below) where report link does not exist.

How to replicate the issue + URL

  1. Navigate to the home page of a repository that you have ownership or collaborator access on, such as https://github.com/fregante/GhostText
  2. The error occurs  

Figure 1 The error occurs in a repository home page where the report button does not exist

Screenshot 2023-05-11 at 9 13 46 AM

  Figure 2 The same issue, on Firefox

Screenshot 2023-05-11 at 12 28 04 PM

Extension version

23.5.10

Browser(s) used

all supported browsers

fregante commented 1 year ago

Thank you for the detailed report! Tracked in

fregante commented 1 year ago

Actually it's not quite the same reason, so I'll reopen this and send a PR