message: Ensure single initialization
diff: @@ -453,6 +453,18 @@ function addTitleToEmojis() {
  }
  }
  +function init() {
  + if (select.exists('html.refined-github')) {
  + console.count('Refined GitHub was loaded multiple times: https://github.com/sindresorhus/refined-github/issues/479');
  + return;
  + }
  +
  + document.documentElement.classList.add('refined-github');
  +
  + if (!pageDetect.isGist()) {
  + addTrendingMenuItem();
  + }
  +
  // Support indent with tab key in comments
  $(document).on('keydown', '.js-comment-field', event => {
  if (event.which === 9 && !event.shiftKey) {
  @@ -492,7 +504,13 @@ $(document).on('pjax:end', () => {
  $(document).on('copy', '.markdown-body', copyMarkdown);
  -function init(options) {
  + onDomReady();
  +}
  +
  +async function onDomReady() {
  + const options = await new OptionsSync().getAll();
  + await domLoaded;
  +
  const username = getUsername();
  markUnread.setup();
  @@ -607,9 +625,4 @@ function init(options) {
  }
  }
  -if (!pageDetect.isGist()) {
  - addTrendingMenuItem();
  -}
  -
  -const options = new OptionsSync().getAll();
  -domLoaded.then(() => options).then(init);
  +init();
  