 {
      window.optInPromiseResolve(false);
      return;
    }

    await sendMessageToAddon("optIn");

    window.doingOptIn = true;
    const s = document.createElement("script");
    s.src = originalUrl;
    s.onerror = () => window.optInPromiseResolve("error");
    document.head.appendChild(s);
  }

  window[`${shimId}Promise`] = new Promise(resolve => {
    sendMessageToAddon("getOptions").then(options => {
      if (document.readyState !== "loading") {
        resolve(go(options));
      } else {
        window.addEventListener("DOMContentLoaded", () => {
          resolve(go(options));
        });
      }
    });
  });
}
PK