Discuss Scratch

NitroCipher
Scratcher
500+ posts

Scratch 3.0 block hacking

In the latest build of Scratch 3.0 they have added the ability to save and load programs.

They are stored with minified json formatting, and pictures for sprites. These are all inside a zip file with the extension changed to “.sb3”. The json file is still labeled as project.json but the internals look entirely different from those of scratch 2.

I just thought since there was so much done with block hacking in 2.0, that we could have a group discussing and sharing tips with the new 3.0 format
miniepicness
Scratcher
1000+ posts

Scratch 3.0 block hacking

All the hacked blocks I've loaded into 3.0 have broken. Even my own
MikeDEV
Scratcher
1000+ posts

Scratch 3.0 block hacking

After writing this, I realized I necroposted. My apologies.

I'm also very disappointed that hacked blocks are so broken in 3.0. All of my projects except one use hacked blocks, and they are completely destroyed. I don't really know why Scratch decided to remove this feature, but for whatever reason, it completely destroys the purpose of building your own blocks.

I decided to dig deeper into this topic, and found out that the JSON code file is compressed (white space removed). It should be easy to hack if you have a reliable JSON compressor/decompressor and JSON editor (To be honest, I don't program in JSON so please don't judge me).

I found that this editor can decompress (add white space) the JSON file and remove the white space, and is a fairly usable editor. I could make out a few things here and there, such as variables info, list data, block info, etc.

What I can determine is that the variables and lists are encoded, but the type of encoder I am unsure of.

I'm not sure what anyone can do with this information, but I felt like I just had to do a bit of digging.
_nix
Scratcher
1000+ posts

Scratch 3.0 block hacking

MikeDEV wrote:

What I can determine is that the variables and lists are encoded, but the type of encoder I am unsure of.
They aren't exactly encoded; rather, variables are referred to by ID instead of name in Scratch 3.0. When you rename a variable, it changes the variable's name, but not its ID (I think). Same deal with lists (and broadcast messages). That said, when a “set” block is called with a value that is not a variable ID, it will look for the variable with that name, and create it if it's not found (basically just like Scratch 2.0). The problem is that the actual hacked blocks themselves don't import properly.

You can read about why hacked blocks don't work in 3.0 here: https://github.com/LLK/scratch-vm/issues/1030
As you can see, that issue is labelled “help wanted”, which means it's open for people to contribute code that does implement it. It's just that nobody has quite figured out how to do it yet, since unfortunately it's quite a bit more complicated than just not removing a feature.
apple502j
Scratcher
1000+ posts

Scratch 3.0 block hacking

-ShadowOfTheFuture-
Scratcher
1000+ posts

Scratch 3.0 block hacking

Here's the project.json of a newly created .sb3 project

{"targets":[{"isStage":true,"name":"Stage","variables":{"`jEk@4|i[#*?(8x)AV.-my variable":["my variable",0]},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"assetId":"cd21514d0531fdffb22204e0ec5ed84a","name":"backdrop1","md5ext":"cd21514d0531fdffb22204e0ec5ed84a.svg","dataFormat":"svg","rotationCenterX":240,"rotationCenterY":180}],"sounds":[{"assetId":"83a9787d4cb6f3b7632b4ddfebf74367","name":"pop","dataFormat":"wav","format":"","rate":48000,"sampleCount":1123,"md5ext":"83a9787d4cb6f3b7632b4ddfebf74367.wav"}],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"off","textToSpeechLanguage":null},{"isStage":false,"name":"Sprite1","variables":{},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"assetId":"09dc888b0b7df19f70d81588ae73420e","name":"costume1","bitmapResolution":1,"md5ext":"09dc888b0b7df19f70d81588ae73420e.svg","dataFormat":"svg","rotationCenterX":47,"rotationCenterY":55},{"assetId":"3696356a03a8d938318876a593572843","name":"costume2","bitmapResolution":1,"md5ext":"3696356a03a8d938318876a593572843.svg","dataFormat":"svg","rotationCenterX":47,"rotationCenterY":55}],"sounds":[{"assetId":"83c36d806dc92327b9e7049a565c6bff","name":"Meow","dataFormat":"wav","format":"","rate":48000,"sampleCount":40681,"md5ext":"83c36d806dc92327b9e7049a565c6bff.wav"}],"volume":100,"layerOrder":1,"visible":true,"x":0,"y":0,"size":100,"direction":90,"draggable":false,"rotationStyle":"all around"}],"extensions":[],"meta":{"semver":"3.0.0","vm":"0.2.0-prerelease.20181108103702","agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"}}

I don't know JSON, but hopefully someone here can understand it

Last edited by -ShadowOfTheFuture- (Dec. 15, 2018 21:26:10)

ryadyl
Scratcher
23 posts

Scratch 3.0 block hacking

I haven't tried this yet, but it just occurred to me.

Scratch 3.0 is made in html5, so in order to change blocks, you can just use inspect element.

For those of you who don't know what inspect element is, it allows you to change the code that you see. But you're not hacking; when you reload the webpage, it is as it usually is. Unless, if you inspect the scratch editor, you can download the project with the hacked blocks, and load it into the normal editor.

I did some googling, and I will post the link below. Check it out!
ryadyl
Scratcher
23 posts

Scratch 3.0 block hacking

ryadyl wrote:

I haven't tried this yet, but it just occurred to me.

Scratch 3.0 is made in html5, so in order to change blocks, you can just use inspect element.

For those of you who don't know what inspect element is, it allows you to change the code that you see. But you're not hacking; when you reload the webpage, it is as it usually is. Unless, if you inspect the scratch editor, you can download the project with the hacked blocks, and load it into the normal editor.

I did some googling, and I will post the link below. Check it out!
Here is the link:

https://scratch.mit.edu/discuss/topic/298595/?page=1#post-3068808
NitroCipher
Scratcher
500+ posts

Scratch 3.0 block hacking

ryadyl wrote:

I haven't tried this yet, but it just occurred to me.

Scratch 3.0 is made in html5, so in order to change blocks, you can just use inspect element.

For those of you who don't know what inspect element is, it allows you to change the code that you see. But you're not hacking; when you reload the webpage, it is as it usually is. Unless, if you inspect the scratch editor, you can download the project with the hacked blocks, and load it into the normal editor.

I did some googling, and I will post the link below. Check it out!

Yeah no, this doesn't work/do anything. You cant just edit blocks like this as Scratch 3 does not interpret directly from the html
JGames101
Scratcher
100+ posts

Scratch 3.0 block hacking

When I briefly looked into hacking Scratch 3 blocks a few days ago, it seems like it may be impossible to do many of the useful features such as putting a reporter in drop downs. Here's why:
      "blocks": {
        "1rT4h:hKy)T:T_E#Btd*": {
          "opcode": "data_setvariableto",
          "next": null,
          "parent": null,
          "inputs": {
            "VALUE": [
              1,
              [
                10,
                "0"
              ]
            ]
          },
          "fields": {
            "VARIABLE": [
              "my variable",
              "`jEk@4|i[#*?(8x)AV.-my variable"
            ]
          },
          "shadow": false,
          "topLevel": true,
          "x": 19,
          "y": 38
        }
      },
Notice that the drop down is in fields, not inputs, meaning that it may be impossible to put a variable there. But I'll keep researching.

Last edited by JGames101 (Jan. 5, 2019 03:01:14)

_nix
Scratcher
1000+ posts

Scratch 3.0 block hacking

JGames101 wrote:

When I briefly looked into hacking Scratch 3 blocks a few days ago, it seems like it may be impossible to do many of the useful features such as putting a reporter in drop downs. Here's why: […] Notice that the drop down is in fields, not inputs, meaning that it may be impossible to put a variable there. But I'll keep researching.
Yes, you're exactly right. This is why any Scratch 2.0 project that placed reporters in dropdowns that don't ordinary allow blocks are broken in 3.0. See my recent issue (and this older one, which goes into more details/discussion).
JGames101
Scratcher
100+ posts

Scratch 3.0 block hacking

Confirming what I said above, there are two kinds of dropdowns in Scratch 3. On blocks like broadcast… there is a round darker-coloured dropdown, whereas on blocks like set variable to… there is an almost square dropdown and it is the same colour as the block.
"blocks": {
        "*4;EKmc:C!$IxU,yw*1[": {
          "opcode": "data_setvariableto",
          "next": null,
          "parent": null,
          "inputs": {
            "VALUE": [
              1,
              [
                10,
                "0"
              ]
            ]
          },
          "fields": {
            "VARIABLE": [
              "my variable",
              "`jEk@4|i[#*?(8x)AV.-my variable"
            ]
          },
          "shadow": false,
          "topLevel": true,
          "x": 16,
          "y": 26
        },
        "qLr@zRzqJDN*RiTtQkiK": {
          "opcode": "event_broadcast",
          "next": null,
          "parent": null,
          "inputs": {
            "BROADCAST_INPUT": [
              3,
              [
                12,
                "my variable",
                "`jEk@4|i[#*?(8x)AV.-my variable"
              ],
              [
                11,
                "message1",
                "EH~R0~l|IBg,J,HtrgOh"
              ]
            ]
          },
          "fields": {
            
          },
          "shadow": false,
          "topLevel": true,
          "x": 19,
          "y": 295
        },
        "]+R*$Hs_@tTPI:]!iI#g": {
          "opcode": "event_broadcast",
          "next": null,
          "parent": null,
          "inputs": {
            "BROADCAST_INPUT": [
              1,
              [
                11,
                "message1",
                "EH~R0~l|IBg,J,HtrgOh"
              ]
            ]
          },
          "fields": {
            
          },
          "shadow": false,
          "topLevel": true,
          "x": 22,
          "y": 160
        }
      },
When it's the former type, it's in the inputs section. When it's the latter, it's in the fields section.
Raytracing
Scratcher
86 posts

Scratch 3.0 block hacking

-ShadowOfTheFuture- wrote:

Here's the project.json of a newly created .sb3 project

{"targets":[{"isStage":true,"name":"Stage","variables":{"`jEk@4|i[#*?(8x)AV.-my variable":["my variable",0]},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"assetId":"cd21514d0531fdffb22204e0ec5ed84a","name":"backdrop1","md5ext":"cd21514d0531fdffb22204e0ec5ed84a.svg","dataFormat":"svg","rotationCenterX":240,"rotationCenterY":180}],"sounds":[{"assetId":"83a9787d4cb6f3b7632b4ddfebf74367","name":"pop","dataFormat":"wav","format":"","rate":48000,"sampleCount":1123,"md5ext":"83a9787d4cb6f3b7632b4ddfebf74367.wav"}],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"off","textToSpeechLanguage":null},{"isStage":false,"name":"Sprite1","variables":{},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"assetId":"09dc888b0b7df19f70d81588ae73420e","name":"costume1","bitmapResolution":1,"md5ext":"09dc888b0b7df19f70d81588ae73420e.svg","dataFormat":"svg","rotationCenterX":47,"rotationCenterY":55},{"assetId":"3696356a03a8d938318876a593572843","name":"costume2","bitmapResolution":1,"md5ext":"3696356a03a8d938318876a593572843.svg","dataFormat":"svg","rotationCenterX":47,"rotationCenterY":55}],"sounds":[{"assetId":"83c36d806dc92327b9e7049a565c6bff","name":"Meow","dataFormat":"wav","format":"","rate":48000,"sampleCount":40681,"md5ext":"83c36d806dc92327b9e7049a565c6bff.wav"}],"volume":100,"layerOrder":1,"visible":true,"x":0,"y":0,"size":100,"direction":90,"draggable":false,"rotationStyle":"all around"}],"extensions":[],"meta":{"semver":"3.0.0","vm":"0.2.0-prerelease.20181108103702","agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"}}

I don't know JSON, but hopefully someone here can understand it

JSON is not a language its just a format. anyway here are the basics:

{“myvar”:0} myvar is 0
{“myvar”:0,“myvar2”:“hello”} myvar is 0 myvar2 is the string “hello”
{“list1”:} list1 is a list of 4,7,“apple”,1

I think that covers enough.
imfh
Scratcher
1000+ posts

Scratch 3.0 block hacking

It's a lot easier to understand when it is properly formatted:

{  
   "targets":[  
      {  
         "isStage":true,
         "name":"Stage",
         "variables":{  
            "`jEk@4|i[#*?(8x)AV.-my variable":[  
               "my variable",
               0
            ]
         },
         "lists":{  
         },
         "broadcasts":{  
         },
         "blocks":{  
         },
         "comments":{  
         },
         "currentCostume":0,
         "costumes":[  
            {  
               "assetId":"cd21514d0531fdffb22204e0ec5ed84a",
               "name":"backdrop1",
               "md5ext":"cd21514d0531fdffb22204e0ec5ed84a.svg",
               "dataFormat":"svg",
               "rotationCenterX":240,
               "rotationCenterY":180
            }
         ],
         "sounds":[  
            {  
               "assetId":"83a9787d4cb6f3b7632b4ddfebf74367",
               "name":"pop",
               "dataFormat":"wav",
               "format":"",
               "rate":48000,
               "sampleCount":1123,
               "md5ext":"83a9787d4cb6f3b7632b4ddfebf74367.wav"
            }
         ],
         "volume":100,
         "layerOrder":0,
         "tempo":60,
         "videoTransparency":50,
         "videoState":"off",
         "textToSpeechLanguage":null
      },
      {  
         "isStage":false,
         "name":"Sprite1",
         "variables":{  
         },
         "lists":{  
         },
         "broadcasts":{  
         },
         "blocks":{  
         },
         "comments":{  
         },
         "currentCostume":0,
         "costumes":[  
            {  
               "assetId":"09dc888b0b7df19f70d81588ae73420e",
               "name":"costume1",
               "bitmapResolution":1,
               "md5ext":"09dc888b0b7df19f70d81588ae73420e.svg",
               "dataFormat":"svg",
               "rotationCenterX":47,
               "rotationCenterY":55
            },
            {  
               "assetId":"3696356a03a8d938318876a593572843",
               "name":"costume2",
               "bitmapResolution":1,
               "md5ext":"3696356a03a8d938318876a593572843.svg",
               "dataFormat":"svg",
               "rotationCenterX":47,
               "rotationCenterY":55
            }
         ],
         "sounds":[  
            {  
               "assetId":"83c36d806dc92327b9e7049a565c6bff",
               "name":"Meow",
               "dataFormat":"wav",
               "format":"",
               "rate":48000,
               "sampleCount":40681,
               "md5ext":"83c36d806dc92327b9e7049a565c6bff.wav"
            }
         ],
         "volume":100,
         "layerOrder":1,
         "visible":true,
         "x":0,
         "y":0,
         "size":100,
         "direction":90,
         "draggable":false,
         "rotationStyle":"all around"
      }
   ],
   "extensions":[  
   ],
   "meta":{  
      "semver":"3.0.0",
      "vm":"0.2.0-prerelease.20181108103702",
      "agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"
   }
}
ryadyl
Scratcher
23 posts

Scratch 3.0 block hacking

requin323 wrote:

post deleted
um…

Last edited by ryadyl (Jan. 16, 2019 21:08:07)

ryadyl
Scratcher
23 posts

Scratch 3.0 block hacking

giphPATCH wrote:

i found out how to fix it!!!!!!!!!!!!!!!
making a project about it….
My browser / operating system: ChromeOS 11151.59.0, Chrome 71.0.3578.94, No Flash version detectedMy browser / operating system: ChromeOS 11151.59.0, Chrome 71.0.3578.94, No Flash version detected
Can you post a comment to the link of this project when you are done with it on my profile? It's @ryadyl.
MikeDEV
Scratcher
1000+ posts

Scratch 3.0 block hacking

ryadyl wrote:

giphPATCH wrote:

i found out how to fix it!!!!!!!!!!!!!!!
making a project about it….
My browser / operating system: ChromeOS 11151.59.0, Chrome 71.0.3578.94, No Flash version detectedMy browser / operating system: ChromeOS 11151.59.0, Chrome 71.0.3578.94, No Flash version detected
Can you post a comment to the link of this project when you are done with it on my profile? It's @ryadyl.

…Yes, please?
TheLegendaryPro
Scratcher
14 posts

Scratch 3.0 block hacking

You Can Convert Scratch 3 which uses HTMl5 to Java, Convert Java to C# and then convert it to text then find every single code of each block until we figure out how Scratch 3 uses blocks.
JGames101
Scratcher
100+ posts

Scratch 3.0 block hacking

TheLegendaryPro wrote:

You Can Convert Scratch 3 which uses HTMl5 to Java, Convert Java to C# and then convert it to text then find every single code of each block until we figure out how Scratch 3 uses blocks.
The source code for Scratch 3 is already available. The problem is that the official editor doesn't work with hacked blocks.
12944qwerty
Scratcher
100+ posts

Scratch 3.0 block hacking

giphPATCH wrote:

i found out how to fix it!!!!!!!!!!!!!!!
making a project about it….
My browser / operating system: ChromeOS 11151.59.0, Chrome 71.0.3578.94, No Flash version detectedMy browser / operating system: ChromeOS 11151.59.0, Chrome 71.0.3578.94, No Flash version detected
When you get it fixed, post the link here!

Powered by DjangoBB