diff --git a/src/lib/extensions.js b/src/lib/extensions.js index e3b79b35f..8501e578c 100644 --- a/src/lib/extensions.js +++ b/src/lib/extensions.js @@ -80,7 +80,6 @@ export default [ creator: "Steve0Greatness", isGitHub: true, }, - { name: "Dictation", description: "Convert your voice into text. (not supported in all browsers)", @@ -88,7 +87,7 @@ export default [ banner: "pooiod/Dictation.svg", creator: "pooiod7", }, - { + { name: "Doodle Recognition", description: "A implementation of Google's Quick Draw image vision model", code: "TheShovel/doodlerec.js", @@ -96,7 +95,7 @@ export default [ creator: "TheShovel", isGitHub: true, }, - { + { name: "Stylus", description: "Get the pressure and tilt of a stylus or graphic tablet", code: "sourdoggy/stylus extension.js", @@ -152,31 +151,6 @@ export default [ banner: "dumzdev/removebgbanner.svg", creator: "dumzdev", }, - /*{ - name: "PenguinAI", - description: "Talk to AI! Use Models like DALL-E-3, GPT, LLama, Claude, and more!", - code: "MubiLop/penguingpt.js", - banner: "MubiLop/penguingpt.avif", - creator: "cicerorph", - creatorAlias: "MubiLop", - isGitHub: true, - unstable: true, - documentation: "PenguinAI", - unstableReason: "AI models can generate unintended or inappropriate output.\nSome AI models may also become temporarily inaccessible.\n\nUse at your own risk.", - },*/ -/* - { - name: "Block AI", - description: "An AI powered chat bot to help you code in your projects.", - code: "TheShovel/blockAI.js", - banner: "TheShovel/thumbnail-blockAI.avif", - creator: "TheShovel", - creatorAlias: "TheShovel", - isGitHub: true, - unstable: true, - unstableReason: "The AI model can generate inaccurate output and broken syntax!", - }, -*/ { name: "PenguinHook", description: "Send Webhook requests, that can be Discord or any type of webhook.", @@ -548,28 +522,14 @@ export default [ isGitHub: true, creatorAlias: "gaimerI17", }, - /* these extensions are completely dead as of now { - name: "Online Captcha", - description: "Protect your project with simple, easy to use captcha implementation. Fully client-side, bypass-proof captcha solution!", - code: "NotHouse/OnlineCaptcha.js", - banner: "NotHouse/OnlineCaptcha-banner.avif", - creator: "enderhacker", + name: "Links & Barcodes", + description: "Blocks to open web links and generate scannable QR codes on the stage.", + code: "codemaster/links-and-barcodes.js", + banner: "codemaster/links-and-barcodes.png", + creator: "moosanaeempc-lgtm", + creatorAlias: "codemaster", isGitHub: true, + isUnsandboxed: true, }, - { - name: "Better Storage", - description: "Like PenguinMod's Storage Extension, but with a couple more features, and faster servers.", - code: "Gen1x/better_storage.js", - banner: "Gen1x/betterstorage.avif", - creator: "G1nX", - }, - { - name: "Mouth Washer", - description: "Includes many utilities related to cleaning bad words, swearing and profanity. Thought of as an extra layer of security for filtering messages.\n\n(ft. violet and jwklong)", - code: "Gen1x/mouth_washer.js", - banner: "Gen1x/mw-placeholder.avif", - creator: "G1nX", - }, - */ ]; diff --git a/static/extensions/codemaster/links-and-barcodes.js b/static/extensions/codemaster/links-and-barcodes.js new file mode 100644 index 000000000..64a7a79b8 --- /dev/null +++ b/static/extensions/codemaster/links-and-barcodes.js @@ -0,0 +1,110 @@ +(function(Scratch) { + 'use strict'; + + class BarcodeExtension { + constructor() { + this.activeBarcodes = []; + this.currentSize = 100; + + if (Scratch.vm && Scratch.vm.runtime) { + Scratch.vm.runtime.on('PROJECT_START', () => this.deleteAllBarcodes()); + Scratch.vm.runtime.on('PROJECT_STOP_ALL', () => this.deleteAllBarcodes()); + } + } + + getInfo() { + return { + id: 'moosanaeempcLinksAndBarcodes', + name: 'Links & Barcodes', + blocks: [ + { + opcode: 'openLink', + blockType: Scratch.BlockType.COMMAND, + text: 'open link [URL]', + arguments: { + URL: { type: Scratch.ArgumentType.STRING, defaultValue: 'https://penguinmod.com' } + } + }, + { + opcode: 'generateBarcode', + blockType: Scratch.BlockType.COMMAND, + text: 'generate barcode of link [URL] at x [X] y [Y]', + arguments: { + URL: { type: Scratch.ArgumentType.STRING, defaultValue: 'https://penguinmod.com' }, + X: { type: Scratch.ArgumentType.NUMBER, defaultValue: 0 }, + Y: { type: Scratch.ArgumentType.NUMBER, defaultValue: 0 } + } + }, + { + opcode: 'setSize', + blockType: Scratch.BlockType.COMMAND, + text: 'set barcode size to [SIZE]', + arguments: { + SIZE: { type: Scratch.ArgumentType.NUMBER, defaultValue: 100, min: 5, max: 300 } + } + }, + { + opcode: 'deleteAllBarcodes', + blockType: Scratch.BlockType.COMMAND, + text: 'delete all barcodes' + } + ] + }; + } + + _clampSize(size) { + return Math.min(Math.max(Number(size), 5), 300); + } + + openLink(args) { + const url = args.URL; + if (Scratch.openWindow) { + Scratch.openWindow(url); + } else { + window.open(url, '_blank', 'noopener,noreferrer'); + } + } + + generateBarcode(args) { + const stageLayer = document.querySelector('.stage_stage_2SR8W') || + document.querySelector('[class*="stage_stage"]') || + document.body; + + const img = document.createElement('img'); + img.src = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(args.URL)}`; + + img.style.position = 'absolute'; + img.style.pointerEvents = 'auto'; + img.style.zIndex = '10'; + + const left = 240 + Number(args.X); + const top = 180 - Number(args.Y); + + img.style.left = `${(left / 480) * 100}%`; + img.style.top = `${(top / 360) * 100}%`; + img.style.transform = 'translate(-50%, -50%)'; + + const finalSize = this._clampSize(this.currentSize); + img.style.width = `${finalSize}px`; + img.style.height = 'auto'; + + stageLayer.appendChild(img); + this.activeBarcodes.push(img); + } + + setSize(args) { + this.currentSize = this._clampSize(args.SIZE); + } + + deleteAllBarcodes() { + this.activeBarcodes.forEach(el => { + if (el && el.parentNode) { + el.remove(); + } + }); + this.activeBarcodes = []; + } + } + + Scratch.extensions.register(new BarcodeExtension()); +})(Scratch); diff --git a/static/images/codemaster/links-and-barcodes.png b/static/images/codemaster/links-and-barcodes.png new file mode 100644 index 000000000..b6381b2b7 Binary files /dev/null and b/static/images/codemaster/links-and-barcodes.png differ