Created
October 13, 2025 04:34
-
-
Save galtenberg/c7bdc5a066c12f8c39a992cdd400e514 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <meta charset="utf-8"> | |
| <title>FS Access probe</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <style> | |
| :root { font: 15px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif } | |
| body { margin: 1rem } | |
| button { padding:.5rem .8rem; border:1px solid #aaa; border-radius:8px; background:#f8f8f8 } | |
| pre { background:#fafafa; border:1px dashed #ccc; padding:.6rem; border-radius:8px; white-space:pre-wrap } | |
| </style> | |
| <h1>File System Access API probe</h1> | |
| <p><button id="probeBtn" type="button">Probe + try open picker</button></p> | |
| <pre id="out"></pre> | |
| <script> | |
| (() => { | |
| const $ = s => document.querySelector(s) | |
| const out = $('#out') | |
| const report = (k, v) => out.textContent += `${k}: ${v}\n` | |
| const probe = () => { | |
| out.textContent = '' | |
| report('userAgent', navigator.userAgent) | |
| report('platform', navigator.platform) | |
| report('protocol', location.protocol) | |
| report('isSecureContext', String(isSecureContext)) | |
| report('has showOpenFilePicker', String(!!window.showOpenFilePicker)) | |
| report('has showSaveFilePicker', String(!!window.showSaveFilePicker)) | |
| report('has showDirectoryPicker', String(!!window.showDirectoryPicker)) | |
| report('has FileSystemHandle', String(!!window.FileSystemHandle)) | |
| report('has FileSystemWritableFileStream', String(!!window.FileSystemWritableFileStream)) | |
| } | |
| const tryOpen = async () => { | |
| if (!window.showOpenFilePicker) { | |
| report('open attempt', 'skipped (no API)') | |
| return | |
| } | |
| try { | |
| const [h] = await window.showOpenFilePicker({ | |
| types: [{ description:'Markdown', accept: { 'text/markdown': ['.md'], 'text/plain': ['.md','.markdown','.txt'] } }], | |
| excludeAcceptAllOption: true, | |
| multiple: false | |
| }) | |
| const f = await h.getFile() | |
| report('open attempt', `OK → ${f.name} (${f.size} bytes)`) | |
| } catch (e) { | |
| report('open attempt ERROR', `${e?.name || 'Error'} — ${e?.message || e}`) | |
| } | |
| } | |
| $('#probeBtn').addEventListener('click', async () => { | |
| probe() | |
| await tryOpen() | |
| }) | |
| })() | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment