getSchemeAndHttpHost(), '/'); if ($appUrl === '') { $appUrl = rtrim((string) Config::get('app.url', ''), '/'); } $bookmarkletScript = <<<'BOOKMARKLET' (function(){ var APP_URL = '__APP_URL__'; if(!location.hostname.includes('songselect.ccli.com')){ alert('Bitte öffne dieses Lesezeichen auf einer SongSelect Liedseite (songselect.ccli.com).'); return; } function send(text){ var ccliMatch = (text || '').match(/CCLI[\s#-]*(\d+)/i); var payload = { title: '', author: '', ccliId: ccliMatch ? ccliMatch[1] : '', sourceUrl: location.href, rawText: text || '' }; var encoded = btoa(unescape(encodeURIComponent(JSON.stringify(payload)))); window.open(APP_URL + '/songs/import-from-ccli-paste?prefill=' + encoded, '_blank'); } var btn = document.querySelector('#generalCopyLyricsButton'); if(!btn){ alert('Kopier-Symbol nicht gefunden. Bitte öffne die Liedtext-Ansicht auf SongSelect und versuche es erneut.'); return; } var captured = null; function onCopy(e){ try { captured = e.clipboardData.getData('text/plain'); } catch(err) {} } document.addEventListener('copy', onCopy, true); btn.click(); setTimeout(function(){ document.removeEventListener('copy', onCopy, true); if(captured && captured.trim()){ send(captured); return; } if(navigator.clipboard && navigator.clipboard.readText){ navigator.clipboard.readText().then(function(text){ send(text); }) .catch(function(){ alert('Liedtext konnte nicht aus der Zwischenablage gelesen werden. Bitte kopiere ihn manuell und nutze „Aus CCLI importieren".'); }); } else { alert('Liedtext konnte nicht gelesen werden. Bitte kopiere ihn manuell und nutze „Aus CCLI importieren".'); } }, 250); })(); BOOKMARKLET; $bookmarkletScript = str_replace('__APP_URL__', $appUrl, $bookmarkletScript); $singleLine = 'javascript:'.preg_replace('/\s+/', ' ', $bookmarkletScript); return response($singleLine, 200, [ 'Content-Type' => 'text/javascript; charset=utf-8', 'Cache-Control' => 'public, max-age=3600', ]); } }