Proceed directly to the steps#
First, open the following page in the personal center:
Move the people you want to keep following to a separate group:
| Follow List | Move to Group | 
|---|---|
Then select the default group on the left, which is where the people you don't want to follow are.
Jump to the last page first:
Right-click on the page and select the last item (Inspect):
Then, in the page that pops up on the right, select the Console and paste the code I provide below, then press Enter.
function clearPage() {
  var interval = 250;
  var count = 0;
  var unsubcribeButton = $(".be-dropdown-item:contains('取消关注')");
  tt = setInterval(
    function () {
      if (0 <= count && count < unsubcribeButton.length) {
        unsubcribeButton[count].click();
        console.log(count + "/" + unsubcribeButton.length);
      } else {
        clearInterval(tt);
        $(".be-pager-prev").click();
        setTimeout(() => {
          clearPage();
        }, 200);
      }
      count += 1;
    },
    interval + count * 10,
  );
}
clearPage();
Then the entire page will automatically start unfollowing -> click on the previous page -> unfollow.
If you unfollow too many people, the access to the interface may be banned by the Bilibili official. Just wait a while and then execute the script again.