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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user