Skip to content

Commit

Permalink
🐛 fix unsandboxed extension scope error (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonShiki authored Nov 5, 2023
2 parents 09be349 + 62f15ae commit 6f7a811
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/injector/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ export function inject (vm: ChibiCompatibleVM) {
sideloadTempButton.setAttribute('text', format('chibi.sideloadTemporarily'));
sideloadTempButton.setAttribute('callbackKey', 'CHIBI_SIDELOAD_FROM_FILE_TEMPORAILY');
workspace.registerButtonCallback('CHIBI_SIDELOAD_FROM_FILE_TEMPORAILY', () => {
if (prompt(format('chibi.exprimentalFileWarning'))) {
if (confirm(format('chibi.exprimentalFileWarning'))) {
const input = document.createElement('input');
input.setAttribute('type', 'file');
input.setAttribute('accept', '.js');
Expand Down
8 changes: 6 additions & 2 deletions src/loader/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ class UnsandboxedLoader {
new Blob(
[
`
var Scratch = document.getElementById('chibiExtension')?.Scratch;
eval(${JSON.stringify(`${code}\n//# sourceURL=${extensionURL}`)});
/**
* Generated by Chibi
*/
let Scratch = document.getElementById('chibiExtension')?.Scratch;
${code}
//# sourceURL=${extensionURL}
`
],
{ type: 'text/javascript' }
Expand Down

0 comments on commit 6f7a811

Please sign in to comment.