message: Fix `releases-tab` highlighting
diff: import React from 'dom-chef';
  import cache from 'webext-storage-cache';
  import select from 'select-dom';
  +import {observe} from 'selector-observer';
  import {TagIcon} from '@primer/octicons-react';
  import elementReady from 'element-ready';
  import * as pageDetect from 'github-url-detection';
  @@ -42,6 +43,23 @@ const getReleaseCount = cache.function(async () => pageDetect.isRepoRoot() ? par
  cacheKey: getCacheKey,
  });
  +const deinit: VoidFunction[] = [];
  +
  +async function updateReleasesTabHighlighting(): Promise<void> {
  + const selectorObserver = observe('.UnderlineNav-item.selected:not(.rgh-releases-tab)', {
  + add(selected) {
  + selected.classList.remove('selected');
  + selected.removeAttribute('aria-current');
  + selectorObserver.abort();
  + },
  + });
  + deinit.push(selectorObserver.abort);
  +
  + const releasesTab = await elementReady('.rgh-releases-tab', {stopOnDomReady: false, timeout: 10_000});
  + releasesTab!.classList.add('selected');
  + releasesTab!.setAttribute('aria-current', 'page');
  +}
  +
  async function init(): Promise<false | void> {
  // Always prefer the information in the DOM
  if (pageDetect.isRepoRoot()) {
  @@ -59,7 +77,7 @@ async function init(): Promise<false | void> {
  <li className="d-flex">
  <a
  href={buildRepoURL('releases')}
  - className="js-selected-navigation-item UnderlineNav-item hx_underlinenav-item no-wrap js-responsive-underlinenav-item"
  + className="js-selected-navigation-item UnderlineNav-item hx_underlinenav-item no-wrap js-responsive-underlinenav-item rgh-releases-tab"
  data-hotkey="g r"
  data-selected-links="repo_releases"
  data-tab-item="rgh-releases-item"
  @@ -75,18 +93,6 @@ async function init(): Promise<false | void> {
  // This re-triggers the overflow listener forcing it to also hide this tab if necessary #3347
  repoNavigationBar.replaceWith(repoNavigationBar);
  - // Update "selected" tab mark
  - if (pageDetect.isReleasesOrTags()) {
  - const selected = select('.UnderlineNav-item.selected');
  - if (selected) {
  - selected.classList.remove('selected');
  - selected.removeAttribute('aria-current');
  - }
  -
  - releasesTab.firstElementChild!.classList.add('selected');
  - releasesTab.firstElementChild!.setAttribute('aria-current', 'page');
  - }
  -
  appendBefore(
  select('.js-responsive-underlinenav .dropdown-menu ul')!,
  '.dropdown-divider', // Won't exist if `more-dropdown` is disabled
  @@ -105,4 +111,12 @@ void features.add(__filebasename, {
  ],
  awaitDomReady: false,
  init,
  +}, {
  + include: [
  + pageDetect.isReleasesOrTags,
  + ],
  + awaitDomReady: false,
  + deduplicate: false,
  + init: updateReleasesTabHighlighting,
  + deinit,
  });
  