Libbyv1

<script>
const LIBBY_URL =
  'https://sentry.libbyapp.com/auth/link/900741?ils=queerliblib&continuation=https%3A%2F%2Flibbyapp.com%2Finterview%2Fauthenticate%2Fcard%3Fkey%3Dqueerliblib%26origination%3Dlibrary%252Fqueerliblib';

function isLibbyWebView() {
  const ua = navigator.userAgent || navigator.vendor || window.opera;
  return (
    /Libby|OverDrive/i.test(ua) ||
    /wv/.test(ua) ||
    document.referrer.includes('libbyapp.com') ||
    document.referrer.includes('overdrive.com') ||
    (/iPhone|iPad|iPod/.test(ua) && !/Safari/.test(ua)) ||
    (/Android/.test(ua) && /wv/.test(ua))
  );
}

function getLibbyReturnParams() {
  const params = new URLSearchParams(window.location.search);
  const libbyIndicators = ['continuation', 'libby', 'ils', 'key', 'origination', 'auth'];
  return libbyIndicators.some(p => params.has(p));
}

function openInExternalBrowser(url) {
  const a = document.createElement('a');
  a.href = url;
  a.target = '_blank';
  a.rel = 'noopener noreferrer';
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
}

function copyToClipboard(text, button) {
  navigator.clipboard.writeText(text).then(() => {
    button.textContent = 'Copied!';
    setTimeout(() => {
      button.textContent = 'Copy Link';
    }, 2000);
  });
}

document.addEventListener('DOMContentLoaded', () => {
  if (getLibbyReturnParams()) {
    console.log('User returning from Libby, skipping auth init');
    return;
  }

  if (isLibbyWebView()) {
    const warningDiv = document.createElement('div');
    warningDiv.style.cssText = 'padding: 20px; background: #fff3cd; border: 1px solid #ffc107; border-radius: 8px; margin: 20px; text-align: center;';
    warningDiv.innerHTML = `
      <p style="margin: 0 0 10px 0; font-weight: bold;">For the best experience:</p>
      <p style="margin: 0 0 15px 0;">Please open this page in Safari or Chrome to sign up.</p>
      <div style="display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;">
        <button id="open-browser-btn" style="padding: 10px 20px; background: #1e1e1e; color: #fff; border: none; border-radius: 6px; cursor: pointer;">
          Open in Browser
        </button>
        <button id="copy-link-btn" style="padding: 10px 20px; background: #6c757d; color: #fff; border: none; border-radius: 6px; cursor: pointer;">
          Copy Link
        </button>
      </div>
      <p style="margin: 15px 0 0 0; font-size: 12px; color: #666;">If "Open in Browser" doesn't work, copy the link and paste it in Safari/Chrome.</p>
    `;
    document.body.prepend(warningDiv);

    document.getElementById('open-browser-btn').addEventListener('click', () => {
      openInExternalBrowser(window.location.href);
    });

    document.getElementById('copy-link-btn').addEventListener('click', (e) => {
      copyToClipboard(window.location.href, e.target);
    });
  }
});
</script>

 

Buy me a coffee