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>
This commit is contained in:
32
scratch-gui/src/lib/tw-persisted-unsandboxed.js
Normal file
32
scratch-gui/src/lib/tw-persisted-unsandboxed.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// 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
|
||||
};
|
||||
Reference in New Issue
Block a user