fix: PPI + button replaces text immediately; add auto-sync folder

PPI + button fix:
- After adding a mapping, the real PPI value is now immediately replaced
  with the fake value in the input/contenteditable element via the new
  replaceInInput() helper (handles both <textarea>/<input> and
  contenteditable divs by walking text nodes).
- Triggers a re-scan 150ms later so the pre-send warning updates or
  dismisses itself if no more PPI remains.

Auto-sync folder (File System Access API):
- User picks a folder once per browser via "Choose Sync Folder".
  Any settings/mappings/identity change writes silent-send-sync.json
  to that folder automatically (via api.storage.onChanged listener).
- On options page open and every time the page regains focus, the file
  is read back; if its lastModified is newer than local data, settings
  are imported immediately and the UI refreshes.
- File handle is stored in IndexedDB (ss_sync_handles) so it persists
  across browser sessions without repeated permission prompts.
- Pick the SAME folder in each browser (or a synced cloud folder for
  cross-computer sync) — fully automatic after that, no copy-paste.
- sync.js gains saveSyncDirHandle / loadSyncDirHandle / clearSyncDirHandle
  helpers backed by IndexedDB.

https://claude.ai/code/session_01TKpSR9M8JgHLXCp5CeDsQP
This commit is contained in:
Claude
2026-03-26 14:32:53 +00:00
parent 84f6e675db
commit f05375c2ec
4 changed files with 238 additions and 1 deletions
+17
View File
@@ -140,6 +140,23 @@
<div id="syncStatus" style="margin-top:8px;font-size:12px;min-height:16px"></div>
</div>
<div style="margin-top:20px;padding-top:16px;border-top:1px solid #e5e7eb">
<h3 style="font-size:13px;font-weight:600;margin:0 0 4px">Auto-Sync Folder — fully automatic, no copy-paste</h3>
<p class="section-desc" style="margin-bottom:8px">
Pick the same folder in each browser once. Changes are written to
<code>silent-send-sync.json</code> automatically whenever settings change,
and read back whenever this page is opened or regains focus.
Use a shared folder (Dropbox, OneDrive, iCloud Drive, or any network share)
for cross-computer sync too.
</p>
<div class="bulk-actions" style="align-items:center">
<button class="btn btn-primary" id="btnPickSyncFolder">Choose Sync Folder</button>
<span id="syncFolderName" style="font-size:12px;color:#6b7280;font-family:monospace"></span>
<button class="btn btn-danger btn-sm" id="btnClearSyncFolder" style="display:none">Clear</button>
</div>
<div id="fileSyncStatus" style="margin-top:6px;font-size:12px;min-height:16px"></div>
</div>
</section>
<section class="section">