{ async function bookmarkPage(page) { const response = await fetch('{$config['site']}/bookmarks/add/', { method: 'POST', mode: 'cors', cache: 'no-cache', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Bearer {$config['bearer_token']}', }, redirect: 'follow', referrerPolicy: 'no-referrer', body: page }); return response; } bookmarkPage(`url=\${encodeURIComponent(window.location.href)}`) .then(data => { if (data.status === 201) { alert('Page bookmarked'); } else { alert(`Failed with status \${data.status} \${data.statusText}`); } }); })(); EOF_JS; echo $booklet;