Files
001code-html--cocos/scratch-gui/src/lib/tw-persisted-unsandboxed.js
刘宇飞 6e0a1fbcbb Initial commit of 001code-html Scratch frontend project.
Includes scratch-gui, scratch-vm, scratch-blocks, scratch-render, scratch-l10n, and deployment config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 15:37:45 +08:00

33 lines
792 B
JavaScript

// All we save is whether the box was checked last time, nothing more.
// User still has to manually confirm loading the extension and has
// every opportunity to uncheck the box.
const PERSISTED_UNSANDBOXED_KEY = 'tw:persisted_unsandboxed';
/**
* @returns {boolean} True if persistence enabled
*/
const getPersistedUnsandboxed = () => {
try {
return localStorage.getItem(PERSISTED_UNSANDBOXED_KEY) === 'true';
} catch (e) {
return false;
}
};
/**
* @param {boolean} persisted True if persistence enabled
*/
const setPersistedUnsandboxed = persisted => {
try {
localStorage.setItem(PERSISTED_UNSANDBOXED_KEY, persisted === true);
} catch (e) {
// ignore
}
};
export {
getPersistedUnsandboxed,
setPersistedUnsandboxed
};