(function(Scratch) { 'use strict'; class Base64Encoder { getInfo() { return { id: 'legendarybase64', name: 'Encode Base64!', color1: '#4c4c4c', blocks: [ { opcode: 'encodeB64', blockType: Scratch.BlockType.REPORTER, text: 'base64 encode [TEXT]', color1: '#666666', arguments: { TEXT: { type: Scratch.ArgumentType.STRING, defaultValue: 'hello' } } }, { opcode: 'decodeB64', blockType: Scratch.BlockType.REPORTER, text: 'base64 decode [TEXT]', color1: '#333333', arguments: { TEXT: { type: Scratch.ArgumentType.STRING, defaultValue: 'aGVsbG8=' } } } ] }; } encodeB64(args) { try { return btoa(args.TEXT); } catch (e) { return 'Error'; } } decodeB64(args) { try { return atob(args.TEXT); } catch (e) { return 'Error'; } } } Scratch.extensions.register(new Base64Encoder()); })(Scratch);