diff --git a/extensions/extensions.json b/extensions/extensions.json index e38c08ca2e..0c7f5d79c3 100644 --- a/extensions/extensions.json +++ b/extensions/extensions.json @@ -26,6 +26,7 @@ "Lily/MoreEvents", "NexusKitten/moremotion", "CubesterYT/WindowControls", + "veggiecan/browserfullscreen", "navigator", "battery", "TheShovel/CustomStyles", diff --git a/extensions/veggiecan/browserfullscreen.js b/extensions/veggiecan/browserfullscreen.js new file mode 100644 index 0000000000..7aa3f93b3d --- /dev/null +++ b/extensions/veggiecan/browserfullscreen.js @@ -0,0 +1,103 @@ +// Name: Browser Fullscreen +// ID: fullscreen0419 +// Description: Enter and exit fullscreen mode. +// By: Veggiecan0419 + +(function (Scratch) { + "use strict"; + const icon = + "data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSI2My4yNjc0MiIgaGVpZ2h0PSI2My4xODQ5NSIgdmlld0JveD0iMCwwLDYzLjI2NzQyLDYzLjE4NDk1Ij48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMjA4LjM2NjI5LC0xNDguNDA3NTMpIj48ZyBkYXRhLXBhcGVyLWRhdGE9InsmcXVvdDtpc1BhaW50aW5nTGF5ZXImcXVvdDs6dHJ1ZX0iIGZpbGwtcnVsZT0ibm9uemVybyIgc3Ryb2tlLWxpbmVjYXA9ImJ1dHQiIHN0cm9rZS1saW5lam9pbj0ibWl0ZXIiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgc3Ryb2tlLWRhc2hhcnJheT0iIiBzdHJva2UtZGFzaG9mZnNldD0iMCIgc3R5bGU9Im1peC1ibGVuZC1tb2RlOiBub3JtYWwiPjxwYXRoIGQ9IiIgZmlsbD0iI2ZmZDI0ZCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjAuNSI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z4="; + + window.addEventListener("fullscreenchange", () => { + Scratch.vm.runtime.startHats("fullscreen0419_whenfullscreen", { + ENABLED: document.fullscreenElement === null ? "exited" : "entered", + }); + }); + + class FullscreenExtension { + getInfo() { + return { + id: "fullscreen0419", + color1: "#F39016", + color2: "#C77612", + color3: "#9D5D0E", + blockIconURI: icon, + name: "Browser Fullscreen", + blocks: [ + { + opcode: "fullscreen", + blockType: Scratch.BlockType.COMMAND, + text: "[ACTION] fullscreen", + arguments: { + ACTION: { + type: Scratch.ArgumentType.STRING, + menu: "fullscreenMenu", + defaultValue: "enter", + }, + }, + }, + { + opcode: "isInFullscreen", + blockType: Scratch.BlockType.BOOLEAN, + text: "in browser fullscreen?", + arguments: {}, + }, + { + opcode: "whenfullscreen", + blockType: Scratch.BlockType.EVENT, + text: "when browser fullscreen [ENABLED]", + isEdgeActivated: false, + arguments: { + ENABLED: { + type: Scratch.ArgumentType.STRING, + menu: "whenfullscreenMenu", + }, + }, + }, + ], + menus: { + fullscreenMenu: { + acceptReporters: true, + items: [ + { + text: "enter", + value: "enter", + }, + { + text: "exit", + value: "exit", + }, + ], + }, + whenfullscreenMenu: { + // Used for startHats filtering. + acceptReporters: false, + items: [ + { + text: "entered", + value: "entered", + }, + { + text: "exited", + value: "exited", + }, + ], + }, + }, + }; + } + fullscreen(args) { + const action = args.ACTION; + if (action === "enter") { + document.documentElement.requestFullscreen(); + } else if (action === "exit") { + document.exitFullscreen(); + } + } + isInFullscreen() { + return document.fullscreenElement !== null; + } + } + + Scratch.extensions.register(new FullscreenExtension()); +})(Scratch);