Skip to content

Instantly share code, notes, and snippets.

@csf30816
Last active July 21, 2016 19:44
Show Gist options
  • Save csf30816/94c77faed80ee3c71d76a645155e8f63 to your computer and use it in GitHub Desktop.
Save csf30816/94c77faed80ee3c71d76a645155e8f63 to your computer and use it in GitHub Desktop.
(function(ext) {
// Cleanup function when the extension is unloaded
ext._shutdown = function() {};
// Status reporting code
// Use this to report missing hardware, plugin or unsupported browser
ext._getStatus = function() {
return {status: 2, msg: 'Ready'};
};
// Block and block menu descriptions
var descriptor = {
blocks: [
[' ', 'Follow %s', 'follow', 'csf30816']
[' ', 'Follow Kaj', 'kaj'],
['r', 'Your username', 'u'],
]
};
ext.follow = function (user) {
$.ajax({
type: "PUT",
url: "https://scratch.mit.edu/site-api/users/followers/" + user + "/add/",
data: {
usernames: Scratch.INIT_DATA.LOGGED_IN_USER.model.username
}
})
}
ext.kaj = function () {
$.ajax({
type: "PUT",
url: "https://scratch.mit.edu/site-api/users/followers/kaj/add/",
data: {usernames: Scratch.INIT_DATA.LOGGED_IN_USER.model.username}
})
}
ext.u = function () {
var username = Scratch.INIT_DATA.LOGGED_IN_USER.model.username;
return "Your username is " + username;
}
// Register the extension
ScratchExtensions.register('Scratch API', descriptor, ext);
})({});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment