Skip to content

Project

Top Dog edited this page Apr 6, 2019 · 20 revisions

Properties

id

The ID of the project (String)

title

The title of the project (String)

description

The "Notes and Credits" section of the project (String)

instructions

The "Instructions" section of the project (String)

visible

Whether the project is visible or not (Boolean)

public

Whether the project is open to the public or not (Boolean)

commentsAllowed

Whether comments are able to be posted or not (Boolean)

isPublished

Whether the project is shared or not (Boolean)

author

Who the author of the project is (IncompleteUser)

thumbnail

The thumbnail of the project (Image)

thumbnails

An array of different sizes of the thumbnail to use (Array<Image>)

createdTimestamp

When the project was created (String)

lastModifiedTimestamp

When the project was last modified (String)

sharedTimestamp

When the project was shared. null if never been shared (String)

viewCount

The amount of views the project has (Number)

loveCount

The amount of loves the project has (Number)

favoriteCount

The amount of favorites the project has (Number)

commentCount

The amount of comments the project has (Number)

remixCount

The amount of remixes the project has (Number)

parent

The parent project if the project is a remix (Project)

root

The root project if the project is a remix (Project)

isRemix

Whether the project is a remix or not (Boolean)

Methods

love()

Add a love to the project on behalf of the authorised user. NOTE: Authorisation required. Returns Promise<Boolean>

Project.love().then(isLoved => {
  console.log("Project is " + (isLoved ? "loved" : "not loved"));
});

/*
Project is loved
*/

unlove()

Remove a love for the project on behalf of the authorised user. NOTE: Authorisation required. Returns Promise<Boolean>

Project.unlove().then(isLoved => {
  console.log("Project is " + (isLoved ? "loved" : "not loved"));
});

/*
Project is not loved
*/

favorite()

Add a favorite to the project on behalf of the authorised user. NOTE: Authorisation required. Returns Promise<Boolean>

Project.favorite().then(isFavorited => {
  console.log("Project is " + (isFavorited ? "favorited" : "not favorited"));
});

/*
Project is favorited
*/

unfavorite()

Remove a favorite for the project on behalf of the authorised user. NOTE: Authorisation required. Returns Promise<Boolean>

Project.unfavorite().then(isFavorited => {
  console.log("Project is " + (isFavorited ? "favorited" : "not favorited"));
});

/*
Project is not favorited
*/

getScripts()

Get the inner JSON scripts in the project. If unshared, this method requires authorisation. NOTE: Only works for projects made in Scratch 3.0. Returns Promise<Object>

Project.getScripts().then(scripts => {
  console.log(scripts);
});

/*
...
*/

getRemixes([options])

Get all remixes for the projcet. Returns Promise<Array<Project>>

  • options
    • fetchAll

    Whether to fetch all remixes or not NOTE: Can take a while if the project has alot of remixes (Boolean)

    • limit

    Amount of remixes to return. Default 20. NOTE: Max is 40, use offset to get more (Number)

    • offset

    Offset of remixes to return. Default 0. (Number)

Project.getRemixes({
  fetchAll: true
}).then(projects => {
  console.log(projects);
});

/*
[Project, Project, Project, Project, Project, ...]
*/

getStudios([options])

Get all studios that the project is in. Returns Promise<Array<Studio>>

  • options
    • fetchAll

    Whether to fetch all studios or not NOTE: Can take a while if the project is in alot of studios (Boolean)

    • limit

    Amount of studios to return. Default 20. NOTE: Max is 40, use offset to get more (Number)

    • offset

    Offset of studios to return. Default 0. (Number)

Project.getStudios({
  fetchAll: true
}).then(studios => {
  console.log(studios);
});

/*
[Studio, Studio, Studio, Studio, Studio, ...]
*/

getComments([options])

Get all studios that the project is in. Returns Promise<Array<ProjectComment>>

  • options
    • fetchAll

    Whether to fetch all comments or not NOTE: Can take a while if the project has alot of comments (Boolean)

    • limit

    Amount of comments to return. Default 20. NOTE: Max is 40, use offset to get more (Number)

    • offset

    Offset of comments to return. Default 0. (Number)

Project.getComments({
  fetchAll: true
}).then(comments => {
  console.log(comments);
});

/*
[ProjectComment, ProjectComment, ProjectComment, ProjectComment, ProjectComment, ...]
*/

postComment(content[, parent])

Post a comment to the project on behalf of the authorised user. NOTE: Authorisation required. Returns Promise<>

  • content

The entire text to comment (String)

  • parent

The parent id of the comment (String)

Project.postComment("Great project!").then(() => {
  console.log("Posted comment!");
});

/*
Posted comment!
*/

turnOffCommenting()

Turn off commenting for the project. NOTE: Authorisation required. Returns Promise<Project>

Project.turnOffCommenting().then(newProject => {
  console.log("Are comments allowed????????? - " + (newProject.commentsAllowed ? "yes" : "nop"));
});

/*
Are comments allowed????????? - nop
*/

turnOnCommenting()

Turn on commenting for the project. NOTE: Authorisation required. Returns Promise<Project>

Project.turnOnCommenting().then(newProject => {
  console.log("Are comments allowed????????? - " + (newProject.commentsAllowed ? "yes" : "nop"));
});

/*
Are comments allowed????????? - yes
*/

toggleCommenting()

Toggle commenting for the project. NOTE: Authorisation required. Returns Promise<Project>

Project.toggleCommenting().then(newProject => {
  console.log("Are comments allowed????????? - " + (newProject.commentsAllowed ? "yes" : "nop"));
});

/*
Are comments allowed????????? - yes/nop???
*/

report(category, reason, image)

Report the project. NOTE: Authorisation required, I am not responsible for any negative impacts this has on your account. Returns Promise<>

  • category

Category to report the project for. (Number)

Project.report(8, "Offensive images inside the project.", "...").then(() => {
  console.log("Making scratch a better place!"));
});

/*
Making scratch a better place!
*/

getAllAssets()

Get all assets for the project. NOTE: Authorisation required, Not reccomended, further testing needed, only works for Scratch 3.0 projects. Returns Promise<Array<ScratchImageAsset, ScratchSoundAsset>>

Project.getAllAssets().then(assets => {
  console.log(assets);
});

/*
[ScratchImageAsset, ScratchImageAsset, ScratchImageAsset, ScratchSoundAsset, ScratchSoundAsset, ..]
*/
Clone this wiki locally