Tutorials > A File Manager tool > Files PLUGIN.JS (1/4) CrossPoint.registerPlugin((container, api) => { const $ = (s) => container.querySelector(s); const BOOK = /\.(epub|xtc|txt|md|pdf)$/i; // Never scan plugin folders (their README.md files are not books) or our own output. const SKIP_DIRS = ['/plugins', '/Duplicates', '/System Volume Information']; const fmt = (b) => b > 1048576 ? (b / 1048576).toFixed(1) + ' MB' : Math.ceil(b / 1024) + ' KB'; const esc = (s) => s.replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])); const form = (o) => new URLSearchParams(o); container.innerHTML = `
`; let duplicates = []; // paths to move // One request at a time: the reader's web server is single-threaded. async function listDir(path) { const r = await fetch('/api/files?path=' + encodeURIComponent(path)); if (!r.ok) throw new Error(`list ${path}: HTTP ${r.status}`); return r.json(); } async function scan(root) { const books = []; Next: 04 plugin.js (2/4)