message: Add `useful-forks` to archived repos
diff: @@ -6,6 +6,14 @@ import {RepoForkedIcon} from '@primer/octicons-react';
  import features from '.';
  import {getRepo} from '../github-helpers';
  import looseParseInt from '../helpers/loose-parse-int';
  +import isArchivedRepo from '../helpers/is-archived-repo';
  +import attachElement from '../helpers/attach-element';
  +
  +function getUrl(): string {
  + const url = new URL('https://useful-forks.github.io');
  + url.searchParams.set('repo', getRepo()!.nameWithOwner);
  + return url.href;
  +}
  async function init(): Promise<void | false> {
  // TODO [2022-06-01]: Remove `.social-count` (GHE)
  @@ -14,19 +22,31 @@ async function init(): Promise<void | false> {
  return false;
  }
  - const downloadUrl = new URL('https://useful-forks.github.io');
  - downloadUrl.searchParams.set('repo', getRepo()!.nameWithOwner);
  -
  const selector = pageDetect.isRepoForksList() ? '#network' : '#repo-content-pjax-container h2';
  const container = await elementReady(selector, {waitForChildren: false});
  container!.prepend(
  - <a className="btn mb-2 float-right" href={downloadUrl.href}>
  + <a className="btn mb-2 float-right" href={getUrl()} target="_blank" rel="noreferrer">
  <RepoForkedIcon className="mr-2"/>
  Find useful forks
  </a>,
  );
  }
  +function createBannerLink(): JSX.Element {
  + // It must return an element for `attachElement`. It includes a space
  + return (
  + <span> You can find <a href={getUrl()} target="_blank" rel="noreferrer">useful-forks.github.io</a></span>
  + );
  +}
  +
  +function initArchivedRepoBanner(): void {
  + attachElement({
  + anchor: '.flash-full',
  + position: 'append',
  + getNewElement: createBannerLink,
  + });
  +}
  +
  void features.add(import.meta.url, {
  include: [
  pageDetect.isRepoForksList,
  @@ -37,4 +57,9 @@ void features.add(import.meta.url, {
  ],
  awaitDomReady: false,
  init,
  +}, {
  + include: [
  + isArchivedRepo,
  + ],
  + init: initArchivedRepoBanner,
  });
  