Tutorials > Remote control with the job queue WHOLE CHAPTER IN ONE FILE INTRODUCTION > INTRODUCTION You'll build: a Send to Reader plugin plus a shell script. From any computer on your network, ./send-to-reader.sh https://example.com/book.epub makes the reader download the book, and the script reports the result. You'll learn: api.registerAction, /api/plugin-jobs, /plugins-run, keeping results under 192 bytes, writing a sidecar from JS. THE PLUGIN > THE PLUGIN (1/3) /plugins/send-to-reader/ +-- manifest.json +-- plugin.js manifest.json { "name": "send-to-reader", "title": "Send to Reader", "version": "0.1.0", "description": "Download URLs to the reader from scripts." } plugin.js 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 = `
`; 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) }))); THE PLUGIN > THE PLUGIN (3/3) return { dest, bytes: res.bytes }; // small: must stay < 192 bytes of JSON } // The job-queue entry point. api.registerAction('save', save); // The manual button uses the same code path. container.querySelector('button').onclick = async () => { const out = container.querySelector('[data-out]'); out.textContent = 'Downloading...'; try { const r = await save({ url: container.querySelector('[data-url]').value.trim() }); out.textContent = `Saved ${r.dest} (${r.bytes} bytes)`; } catch (e) { out.textContent = 'Error: ' + e.message; } }; }); A dest path can be at most ~170 characters to keep the result under 192 bytes. That's why the name is cut to 80 characters. Return ids or short paths, never content. THE SCRIPT > THE SCRIPT send-to-reader.sh #!/bin/sh # usage: send-to-reader.sh URL [name] # needs: curl, python3 (only for JSON parsing). Set READER=http://