// Hymns tab — plays a saved YouTube link inline; right rail lists titles from settings. // "Ad-free" works via the browser's Google session: sign into the saved account once // (Google blocks programmatic password login), and a Premium account then plays embeds ad-free. function HymnsTab({ hymns, ytAccount }){ const [cur, setCur] = React.useState(null); // index const [session, setSession] = React.useState(()=> localStorage.getItem('cwa-ytsession') || ''); const playable = cur!=null ? window.ytId(hymns[cur] && hymns[cur].url) : null; const hasAccount = !!(ytAccount && ytAccount.user); const signedIn = !!session && session === (ytAccount && ytAccount.user); function signIn(){ const email = (ytAccount && ytAccount.user) || ''; // Open Google's own secure login with the saved email pre-filled (password is entered by the // user on Google's page — it cannot be auto-submitted). Once signed in here, embeds use it. const url = 'https://accounts.google.com/AccountChooser?continue=' + encodeURIComponent('https://www.youtube.com') + (email ? '&Email=' + encodeURIComponent(email) : ''); window.open(url, '_blank', 'noopener'); if(email){ localStorage.setItem('cwa-ytsession', email); setSession(email); } } function signOut(){ localStorage.removeItem('cwa-ytsession'); setSession(''); window.open('https://www.youtube.com/logout', '_blank', 'noopener'); } return (
{cur==null &&
Select a hymn from the list to play its video here.
} {cur!=null && playable && ( )} {cur!=null && !playable && (
{hymns[cur].title}
No YouTube link saved for this hymn yet.
Add one in Settings → Hymns.
)}

Hymns

{signedIn ? Signed in as {session}
Premium account plays ad-free.
: hasAccount ? Account saved ({ytAccount.user})
Sign in once to play ad-free.
: No account set
Add one in Settings \u2014 ads may appear.
}
{hasAccount && (signedIn ? : )}
{hymns.map((h,n)=>(
setCur(n)}> {n+1} {h.title} {window.ytId(h.url) ? (n===cur?'\u25b6':'') : '\u2014'}
))}
); } window.HymnsTab = HymnsTab;