/** * Standalone shim. * * The only thing this adds over the original plugin: a clearer message when * the browser refuses the File System Access API. Opening this page straight * off disk (file://) gives it an opaque origin in Chrome, and the folder * picker used for *writing* metadata rejects opaque origins with a * SecurityError. Reading, playback, CSV and PDF are unaffected — only the * "Edit Metadata in a Folder…" path needs the page served over http(s), * which locally means something like `python3 -m http.server` in this file's * folder and then visiting http://localhost:8000/. * * The app's own catch block runs before this one resolves its message, so * the warning is written on the next tick to make sure it lands last. */ ( function () { "use strict"; if ( typeof window.showDirectoryPicker !== "function" ) { return; } var original = window.showDirectoryPicker.bind( window ); window.showDirectoryPicker = function ( options ) { return original( options ).catch( function ( err ) { if ( err && ( err.name === "SecurityError" || err.name === "NotAllowedError" ) && window.location.protocol === "file:" ) { window.setTimeout( function () { var warning = document.querySelector( "[data-bwfa-fs-warning]" ); if ( warning ) { warning.style.display = "block"; } var status = document.querySelector( "[data-bwfa-status]" ); if ( status ) { status.textContent = ""; } }, 0 ); } throw err; } ); }; }() );