Tutorials > Remote control with the job queue > The plugin THE PLUGIN (2/3) CrossPoint.registerPlugin((container, api) => { const b64 = (t) => { let s = ''; for (const c of new TextEncoder().encode(t)) s += String.fromCharCode(c); return btoa(s); }; const INBOX = '/Books/Inbox'; // A visible card on /plugins with a manual form, nice for testing. container.innerHTML = `

Send to Reader

Book URL

`; async function save(args) { const url = String(args.url || ''); if (!/^https?:\/\//.test(url)) throw new Error('url must start with http(s)://'); // Name: explicit, or the last URL segment, made safe for FAT. let name = String(args.name || decodeURIComponent(new URL(url).pathname.split('/').pop() || 'book')); name = name.replace(/[\\/:*?"<>|]+/g, '_').slice(0, 80); if (!/\.(epub|txt|md|xtc|pdf)$/i.test(name)) name += '.epub'; const dest = `${INBOX}/${name}`; const res = await api.fetchToSd(url, dest); // follows redirects, resumes, creates /Books/Inbox await api.writeFile(dest + '.meta.json', // sidecar: remember where it came from b64(JSON.stringify({ sendtoreader_source: url.slice(0, 500) }))); Next: 03 The plugin (3/3)