From 8975b5cdadc1a14f004e1be6b83c0fccc9e685bb Mon Sep 17 00:00:00 2001 From: G1nX-01 <81038333+G1nX-01@users.noreply.github.com> Date: Tue, 22 Aug 2023 20:22:19 -0300 Subject: [PATCH 001/589] Create better_storage.js --- static/extensions/Gen1x/better_storage.js | 220 ++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 static/extensions/Gen1x/better_storage.js diff --git a/static/extensions/Gen1x/better_storage.js b/static/extensions/Gen1x/better_storage.js new file mode 100644 index 00000000..77c91d84 --- /dev/null +++ b/static/extensions/Gen1x/better_storage.js @@ -0,0 +1,220 @@ +let externalWindow; +let username; +let hadError = false; +let errorText = ""; +let errors = []; + +function addNewError(err) { + errors.push(err + " | " + new Date().toLocaleString()) +} + +//Server icon by Icons8 (https://icons8.com/) - https://icons8.com/icon/1340/server + +const image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAACC0lEQVR4nO2bTStEURjHfyIrE+p+Aqz4AGwUFjJev4UNq7GQbsJMIgvlWygLKV9A7CllbWGLJGOaZHTqqGO6EzLnZZznX8/mLu7zf35zznOe7p0Lf1M/cAI8AzXH8QqcA6N40gTw5KHw+qhoL07VD9xrA+/AEbDrOA6BN+1BeRlwVXwXcG38AntAn6fYN3zcAN22i28DjgNY9o3i1DaAmQCK/C4mbQJYNRIVgMVAomD4Uh6tKTUSJYSjxPClPFpTKgCQFVCTLUDDHjAOrOhGZCPUvcdC7QGbDo+6jdAAtANlhwBedM5gACTG9RLQaylKP8jvHUD6j/Pj24Dv/Pg24Ds/vg34zo9vA77z08hAj3H9zOJToDMjT09IAJRuHc4BKhchAejUDyddAajonMEASGQQIu4mmAgAZAXUZAsQbw/IeRiEciEBULpyOAdc8lVBABgCLoCqxcKrOsdgiAB8SgAgKwDZAkgPQJogcgogxyAWlcocQNMGoXXgUUca2xwwnTHm5mMCUMwAsBUTgPkMALMxAVDa1u/5X/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mV8Jdho1aXwGwPWAejDtAJ4Br26l0HcFjOtAKIoQmvTayi/WlXwgaNNtJ3+r5DpBJD4v8KSoSLwCAjzKQA8B9h4EgReBWy8DMKZWwcM9Y5A5fVquHvjPgz3jVqrDAb9ISgt/nXEBYGfQ4FF6wjgSztgocI3PWsdAdbX15UTZaoNfNP7fef3vxZASu0k42YqbnbmbeMsCyAVAFyA8BmPgGg0mnHI0VIRMPjWDRXX7ilwdQ9ZS4CgP5hx0BI/49rAMgL4pi2+DhBFMeMwFZ4Cj4pR6wggKeRXlY1ORHrzg2UEkAoALkCYRwDwKWA7eQ5IWjUHEELiQqpLlKljBA8uq46xnOndKJUN6aUUOakCMDVNEUIcuX5B7RXEOn4arXLZ4Khq1N4pkGOu4yGE2AXspcV2UtaWubXVNRjp9xjSKPk3jL7zKFxUXsiRqXESL1mWL+XSOou9OGZol80G5JZLvxCONRaLXRDSL+ylRVVYI8EswKbJHAcf+2PwQurCkEjlhAVsKvxXNGCTolEt8ydspcexzOOc18I+df0EoxMBmk6ZTmQAAAAASUVORK5CYII=" + +function openWindow(url) { + const windowFeatures = 'width=400,height=500,top=100,left=100'; + + // Open the external window + externalWindow = window.open(url, "_blank", windowFeatures); + + // Listen for messages from the external window + window.addEventListener("message", handleMessage); + + function handleMessage(event) { + // Check the origin of the message to ensure it's from the expected source + // Handle the message data sent from the external window + const data = event.data; + username = data; + //externalWindow.close(); + window.removeEventListener("message", handleMessage); + access = true + } +} + +let access = false; +class Storage { + getInfo() { + return { + id: 'g1nxbetterstorage', + name: 'Better Server Storage', + menuIconURI: menuimg, + blockIconURI: image, + color1: '#42a9cf', + color2: '#327f9c', + color3: '#245c70', + blocks: [ + { + opcode: 'lockbutton', + blockType: Scratch.BlockType.BUTTON, + text: 'Reserve a key...', + }, + { + opcode: 'login', + blockType: Scratch.BlockType.COMMAND, + text: 'log in first', + }, + { + opcode: 'errorlog', + blockType: Scratch.BlockType.REPORTER, + text: 'error log (array format)', + disableMonitor: true + }, + { + opcode: 'islocked', + blockType: Scratch.BlockType.BOOLEAN, + text: 'is key [KEY] reserved (read-only) [MENU]?', + arguments: { + KEY: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'scratch' + }, + MENU: { + type: Scratch.ArgumentType.STRING, + menu: 'BOOLEANLOCK' + } + } + }, + "---", + { + opcode: 'haderror', + blockType: Scratch.BlockType.BOOLEAN, + text: 'server error?', + }, + { + opcode: 'errortext', + blockType: Scratch.BlockType.REPORTER, + text: 'error text', + }, + { + opcode: 'savetostorage', + blockType: Scratch.BlockType.COMMAND, + text: 'save key [KEY] and value [VALUE] to server', + arguments: { + KEY: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'hello' + }, + VALUE: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'world!' + } + } + }, + { + opcode: 'getfromstorage', + blockType: Scratch.BlockType.REPORTER, + text: 'get key [KEY] from server', + arguments: { + KEY: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'scratch' + } + } + } + ], + menus: { + BOOLEANLOCK: { + acceptReporters: true, + items: ['for everyone else', 'for me'] + } + } + }; + } + + savetostorage(args) { + if (access) { + fetch("https://save.genarunchisacoa.repl.co/set.php?key=" + encodeURIComponent(args.KEY) + "&value=" + encodeURIComponent(args.VALUE) + "&username=" + encodeURIComponent(username), { + method: 'GET' + }) + .then((response) => { + if (!response.ok) { + hadError = true; + return response.text().then((errorContent) => { + errorText = errorContent; + addNewError(errorContent) + }); + } + hadError = false; + errorText = ""; + return response.text(); + }) + .catch((error) => { + console.error(error); + hadError = true; + errorText = error; + addNewError(error) + return 'Uh oh! Something went wrong.'; + }); + } else { + alert("You are not logged in."); + } + } + getfromstorage(args) { + return fetch("https://save.genarunchisacoa.repl.co/get.php?key=" + encodeURIComponent(args.KEY), { + method: 'GET' + }) + .then((response) => { + hadError = false + return response.text(); + }) + .catch((error) => { + console.error(error); + hadError = true + errorText = error + addNewError(error) + return 'Uh oh! Something went wrong.'; + }); + } + login() { + openWindow("https://storage-auth.genarunchisacoa.repl.co/") + } + haderror() { + return hadError; + } + errortext() { + return errorText; + } + errorlog() { + return JSON.stringify(errors) + } + islocked(args) { + if (access) { + var url; + if (args.MENU == "for everyone else") { + url = "https://save.genarunchisacoa.repl.co/islocked.php?key=" + encodeURIComponent(args.KEY) + } else { + url = "https://save.genarunchisacoa.repl.co/islocked.php?key=" + encodeURIComponent(args.KEY) + "&username=" + encodeURIComponent(username) + } + return fetch(url, { + method: 'GET' + }) + .then((response) => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); + }) + .then((data) => { + if (data.result !== undefined) { + return data.result; + } else { + throw new Error('The "result" property was not found in the JSON response'); + } + }) + .catch((error) => { + console.error(error); + addNewError(error) + return 'Uh oh! Something went wrong.'; + }); + } else { + alert("You are not logged in.") + } + } + lockbutton() { + window.open('https://forms.gle/hQ5Qiq1gtkppR1Fj7', '_blank'); + } +} +Scratch.extensions.register(new Storage()); From d6c0f6fe660eb2e531a24a4da5e276a6689c6615 Mon Sep 17 00:00:00 2001 From: UnluckyCrafter <117037081+minidogg@users.noreply.github.com> Date: Tue, 22 Aug 2023 19:08:38 -0500 Subject: [PATCH 002/589] sitebuilder extension --- src/lib/extensions.js | 8 + static/extensions/minidogg/sitebuilder.js | 306 ++++++++++++++++++ .../site builder extension banner.png | Bin 0 -> 13833 bytes 3 files changed, 314 insertions(+) create mode 100644 static/extensions/minidogg/sitebuilder.js create mode 100644 static/images/minidogg/site builder extension banner.png diff --git a/src/lib/extensions.js b/src/lib/extensions.js index b81abf89..b82f35e9 100644 --- a/src/lib/extensions.js +++ b/src/lib/extensions.js @@ -34,4 +34,12 @@ export default [ banner: "Gen1x/placeholder-cats.png", creator: "G1nX", }, + { + name: "Site Builder", // The name of the extension. + description: "Extension for making basic websites with PenguinMod blocks. Do know that this extension isn't completely done yet, I have plans to add more blocks to simplify making sites.", // The description for the extension. + code: "minidogg/sitebuilder.js", // The folder and file name for the code of the extension. + banner: "minidogg/site builder extension banner.png", + creator: "minidogg", // Your username. Adds a link to your profile. + isGitHub: true, // Optional. false means this is your Scratch username, true means this is your GitHub username. + }, ]; \ No newline at end of file diff --git a/static/extensions/minidogg/sitebuilder.js b/static/extensions/minidogg/sitebuilder.js new file mode 100644 index 00000000..681003b3 --- /dev/null +++ b/static/extensions/minidogg/sitebuilder.js @@ -0,0 +1,306 @@ +class siteBuilder { + constructor (runtime) { + this.runtime = runtime + this.siteHtml = "" + this.siteWindow; + } + getInfo() { + return { + id: 'sitebuilder', + name: 'Site Builder', + //colors + color1: '#7e69beff', + color2: '#3a286f', + docsURI: 'https://github.com/minidogg/my-penguinmod-extensions/blob/88ff87b8fff13b4e601415d94b201f12c6d475fc/site%20builder/docs/home.md', + blocks: [ + { + blockType: Scratch.BlockType.LABEL, + text: "Note: Extension must be unsandboxed to work in its entirety." + }, + { + blockType: Scratch.BlockType.LABEL, + text: "Advanced Stuffs" + }, + { + opcode: 'site', + blockType: Scratch.BlockType.REPORTER, + text: 'Site HTML' + }, + { + opcode: 'setHtml', + blockType: Scratch.BlockType.COMMAND, + text: 'Set Site HTML[html]', + arguments:{ + html: { + type: Scratch.ArgumentType.STRING, + defaultValue:"
World
" + }, + } + }, + + { + blockType: Scratch.BlockType.LABEL, + text: "Init stuffs" + }, + { + opcode: 'resetHtml', + blockType: Scratch.BlockType.COMMAND, + text: 'Reset Site HTML', + }, + { + opcode: 'openSiteWindow', + blockType: Scratch.BlockType.COMMAND, + text: 'Open Site Window', + }, + // { + // opcode: 'closeSiteWindow', + // blockType: Scratch.BlockType.COMMAND, + // text: 'Close Site Window', + // }, + // { + // opcode: 'updateSiteWindow', + // blockType: Scratch.BlockType.COMMAND, + // text: 'Update Site Window', + // }, + { + blockType: Scratch.BlockType.LABEL, + text: "Elements. One new ID per element!" + }, + { + opcode: 'addHeader', + blockType: Scratch.BlockType.COMMAND, + text: 'Add Header Element Text: [TEXT] Size: [SIZE] ID: [ID] Class: [CLASS]', + arguments:{ + TEXT: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'Apple' + }, + SIZE: { + type: Scratch.ArgumentType.STRING, + menu: 'headers' + }, + ID: { + type: Scratch.ArgumentType.STRING, + defaultValue: "" + }, + CLASS: { + type: Scratch.ArgumentType.STRING, + defaultValue: "" + } + } + }, + { + opcode: 'addPara', + blockType: Scratch.BlockType.COMMAND, + text: 'Add Paragraph Element Text: [TEXT] ID: [ID] Class: [CLASS]', + arguments:{ + TEXT: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'Apple' + }, + ID: { + type: Scratch.ArgumentType.STRING, + defaultValue: "" + }, + CLASS: { + type: Scratch.ArgumentType.STRING, + defaultValue: "" + } + } + }, + { + blockType: Scratch.BlockType.LABEL, + text: "Page Modification. Window must be created first!" + }, + { + opcode: 'setInnerHtml', + blockType: Scratch.BlockType.COMMAND, + text: 'Set text/innerHTML of elements with selector [type] named [name] to [text]', + arguments:{ + name: { + type: Scratch.ArgumentType.STRING, + defaultValue: '' + }, + text: { + type: Scratch.ArgumentType.STRING, + defaultValue: "" + }, + type: { + type: Scratch.ArgumentType.STRING, + menu:"selectors" + } + } + }, + { + blockType: Scratch.BlockType.LABEL, + text: "Styles" + }, + { + opcode: 'addColorStyle', + blockType: Scratch.BlockType.COMMAND, + text: 'Add color style with color [value] to all elements with [type] selector named [name]', + arguments:{ + value: { + type: Scratch.ArgumentType.STRING, + defaultValue: "" + }, + type: { + type: Scratch.ArgumentType.STRING, + menu:"selectors" + }, + name: { + type: Scratch.ArgumentType.STRING, + defaultValue: "" + }, + } + }, + { + opcode: 'addTextColorStyle', + blockType: Scratch.BlockType.COMMAND, + text: 'Add text color style with color [value] to all elements with [type] selector named [name]', + arguments:{ + value: { + type: Scratch.ArgumentType.STRING, + defaultValue: "" + }, + type: { + type: Scratch.ArgumentType.STRING, + menu:"selectors" + }, + name: { + type: Scratch.ArgumentType.STRING, + defaultValue: "" + }, + } + }, + { + opcode: 'addPositionStyle', + blockType: Scratch.BlockType.COMMAND, + text: 'Add position style type [posType] [dir] with value [num][numType] to all elements with [type] selector named [name]', + arguments:{ + dir: { + type: Scratch.ArgumentType.STRING, + menu:"dir" + }, + num: { + type: Scratch.ArgumentType.NUMBER, + defaultValue:0 + }, + numType:{ + type: Scratch.ArgumentType.STRING, + menu:"numType" + }, + type: { + type: Scratch.ArgumentType.STRING, + menu:"selectors" + }, + posType: { + type: Scratch.ArgumentType.STRING, + menu:"posType" + }, + name: { + type: Scratch.ArgumentType.STRING, + defaultValue: "" + }, + } + }, + + ], + menus: { + headers: { + acceptReporters: true, + items: ["big","medium","small","tiny","even tinier","tiniest"] + }, + styles: { + acceptReporters: true, + items: ["big","medium","small","tiny","even tinier","tiniest"] + }, + selectors: { + acceptReporters: true, + items: ["id","class"] + }, + dir: { + acceptReporters: true, + items: ["top","bottom","left","right"] + }, + numType: { + acceptReporters: true, + items: ["px","%"] + }, + posType: { + acceptReporters: true, + items: ["absolute","fixed","sticky"] + }, + } + }; + } + + temp(){ + return; + } + site() { + return this.siteHtml; + } + setHtml(args) { + this.siteHtml = args.html + } + addHtml(args) { + this.siteHtml += args.html + } + resetHtml(args) { + this.siteHtml = "" + } + openSiteWindow(){ + this.siteWindow = window.open("", "", "width=1000,height=1000") + this.siteWindow.document.write(this.siteHtml) + } + closeSiteWindow(){ + this.siteWindow.close() + } + updateSiteWindow(){ + this.siteWindow.document.body.innerHTML = "" + this.siteWindow.document.write(this.siteHtml) + } + addHeader(args){ + var items = {"big":"h1","medium":"h2","small":"h3","tiny":"h4","even tinier":"h5","tiniest":"h6"} + this.siteHtml += `<${items[args.SIZE]} id="${args.ID}" class="${args.CLASS}">${args.TEXT}${items[args.SIZE]}>` + } + addPara(args){ + this.siteHtml += `${args.TEXT}
` + } + addColorStyle(args){ + var items = {"id":"#","class":"."} + this.siteHtml += `` + } + addTextColorStyle(args){ + var items = {"id":"#","class":"."} + this.siteHtml += `` + } + addPositionStyle(args){ + var items = {"id":"#","class":"."} + this.siteHtml += `` + } + setInnerHtml(args){ + if(args.type = "id"){ + this.siteWindow.document.getElementById(args.name).innerHTML = args.text + + return; + } + for(let el of this.siteWindow.document.getElementsByClassName(args.name)){ + el.innerHTML = args.text + } + } + } + + Scratch.extensions.register(new siteBuilder()); diff --git a/static/images/minidogg/site builder extension banner.png b/static/images/minidogg/site builder extension banner.png new file mode 100644 index 0000000000000000000000000000000000000000..6f20a76cce7ff4d6a341ceee3e9187e79f5bc154 GIT binary patch literal 13833 zcmV+kHulMhP)j-X<-NF-FR&h>SU+jKL5DOfGbDI-9@IP2pn|zC6q|Vv
zLDEOm^P!wxzQB4!jK%CpY?w#PR7$Jy$};b(FQv7i@V`Q_sNE1M(hRDU
zyl`PDB@OY<%Fhk+C>B}qV5rDSh~rMzHn=8QvKaC!-D6S3im