MegaScratchUserscript / Mega-Scratch-Userscript

A mega userscript for Scratch containing a lot of useful features (eventually, hopefully...)
http://scratch.mit.edu/discuss/topic/57450/
Apache License 2.0
18 stars 6 forks source link

Scratchy Stuff Extension Library doesn't save extensions #7

Open TheInitializer opened 10 years ago

TheInitializer commented 10 years ago

When you put an extension in your project from the Scratchy Stuff extension library, if you save and reload the page, the extension isn't already loaded. Maybe keep a dict of which projects use which extensions and automatically load the extensions when the user goes back to that project?

MegaApuTurkUltra commented 10 years ago

I had this problem too while fooling with extensions. Projects don't seem to put extension urls into their json like they do for djdolphin... Idk how to fix this

MegaApuTurkUltra commented 9 years ago

Any help? Djdolphin?

djdolphin commented 9 years ago

I'll have this implemented eventually (hopefully soon).

TheInitializer commented 9 years ago

So I looked in the JSON of a project with the PicoBoard extension, and I found this code:

    "savedExtensions": [{
                "extensionName": "PicoBoard",
                "blockSpecs": [["h", "when %m.booleanSensor", "whenSensorConnected", "button pressed"],
                    ["h", "when %m.sensor %m.lessMore %n", "whenSensorPass", "slider", ">", 50],
                    ["b", "sensor %m.booleanSensor?", "sensorPressed", "button pressed"],
                    ["rR", "%m.sensor sensor value", "sensor", "slider"]],
                "menus": {
                    "lessMore": [">", "<"],
                    "sensor": ["slider", "light", "sound", "resistance-A", "resistance-B", "resistance-C", "resistance-D"],
                    "booleanSensor": ["button pressed", "A connected", "B connected", "C connected", "D connected"]
                },
                "javascriptURL": "file:\/\/\/C:\\Users\\David\\AppData\\Roaming\\edu.media.mit.Scratch2Editor\\Local Store\\static\\js\\scratch_extensions\\picoExtension.js"
            }]

So all we need to do to save an extension is modify the JSON in that way! So where is the project file kept on the server?

bates64 commented 9 years ago

Wow, clever! I've got a couple questions of my own: How do you add css to the MSU settings? I've got a css file ready but how can I apply it? :cookie: Sorry. :blush:

MegaApuTurkUltra commented 9 years ago

Add CSS to the MSU settings? What do you mean? If you want additional CSS to apply to Scratch, right now the only way to do that is 1) (I recommend this) Add your CSS to a file in resources/<mycssfile>.css, then add // @resource customcssfile resources/<mycssfile>.css to the header on msu-base.user.js, and finally in ScratchUserscript.init(), add the line GM_addStyle(GM_getResourceText("customcssfile")) 2) (More hacky) Add your CSS to `resources/settings.css 3) (Most hacky) Paste your code into a string in msu-base.user.js and call GM_addStyle on that directly

In any case, please don't commit as it would mess up the repo. However, a good idea might be a MSU part where you can add custom CSS styles. Sorry, I didn't see your commits. So how should we add this? As a new part or as new CSS in the existing theme part?

bates64 commented 9 years ago

As new css in the theme part?

djdolphin commented 9 years ago

@davidkt Extensions are already saved with projects. They just aren't loaded again unless they're made by someone in the extension developer group and the project is unshared. That could be worked around by grabbing the JSON using a CORS proxy and loading everything in the savedExtensions section.

bates64 commented 9 years ago

@djdolphin It would be really cool, though.