fix: config not reaching content.js — race condition with script removal

The data-ss-config attribute on the script tag was being removed
(via script.onload) before content.js could read it. Changed approach:
inject config as a separate <script type="application/json" id="ss-config-data">
element that persists in the DOM until content.js reads and removes it.

This eliminates the race condition between script execution and onload
removal. Bump 0.9.20.

https://claude.ai/code/session_01KF4i7Ra7zCEDskxDBaNtcT
This commit is contained in:
Claude
2026-03-29 18:25:28 +00:00
parent b622d5abd4
commit 740f692ff1
6 changed files with 16 additions and 7 deletions
+3 -2
View File
@@ -26,12 +26,13 @@
let settings = { enabled: true, revealMode: false, showHighlights: false };
try {
const configEl = document.querySelector('script[data-ss-config]');
const configEl = document.getElementById('ss-config-data');
if (configEl) {
const config = JSON.parse(configEl.getAttribute('data-ss-config'));
const config = JSON.parse(configEl.textContent);
mappings = config.mappings || [];
identity = config.identity || {};
settings = { ...settings, ...(config.settings || {}) };
configEl.remove(); // clean up
}
} catch (e) {
console.warn('[Silent Send] Failed to parse initial config:', e);