Discuss Scratch

donotforgetmycode
Scratcher
100+ posts

My Scratch Extension

How to link to another website on Scratch
Step 1:
Highlight the code below and press Ctrl+C or right-click and select Copy.
(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'};
};

ext.my_first_block = function(website) {
window.location.href = website;
};

// Block and block menu descriptions
var descriptor = {
blocks: [
// Block type, block name, function name
[' ', 'link to %s', 'my_first_block', 'https://scratch.mit.edu'],
]
};

// Register the extension
ScratchExtensions.register('Link', descriptor, ext);
})({});
Step 2:
Go to Scratch and press Ctrl+Shift+J.
Press Ctrl+V or right-click and select Paste.
Step 3:
Click More Blocks. You should see this block:
link to [https://scratch.mit.edu]
Use the block!

<mouse down?> //Add comment here...


Those are my three pets. Johnny (the comment) eats signature thieves, John (the emoji) is a signature thief and Bob (the block) thinks that Johnny is annoying.

My semicolon was eaten by an evil Kaj
herohamp
Scratcher
1000+ posts

My Scratch Extension

donotforgetmycode
Scratcher
100+ posts

My Scratch Extension

herohamp wrote:

Wrong forum…………………..
My I teach you about /discuss/48?
https://scratch.mit.edu/discuss/48/
Oops, sorry
I think it has been moved though.

Last edited by donotforgetmycode (Aug. 15, 2017 08:26:09)


<mouse down?> //Add comment here...


Those are my three pets. Johnny (the comment) eats signature thieves, John (the emoji) is a signature thief and Bob (the block) thinks that Johnny is annoying.

My semicolon was eaten by an evil Kaj
JGames101
Scratcher
100+ posts

My Scratch Extension

donotforgetmycode wrote:

How to link to another website on Scratch
Step 1:
Highlight the code below and press Ctrl+C or right-click and select Copy.
(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'};
};

ext.my_first_block = function(website) {
window.location.href = website;
};

// Block and block menu descriptions
var descriptor = {
blocks: [
// Block type, block name, function name
[' ', 'link to %s', 'my_first_block', 'https://scratch.mit.edu'],
]
};

// Register the extension
ScratchExtensions.register('Link', descriptor, ext);
})({});
Step 2:
Go to Scratch and press Ctrl+Shift+J.
Press Ctrl+V or right-click and select Paste.
Step 3:
Click More Blocks. You should see this block:
link to [https://scratch.mit.edu]
Use the block!
This is great! I remember my first extension was just true and false blocks…
Here are a few tips for your forum post, though:
instead of having your block look like
link to [https://scratch.mit.edu]
link to [https://scratch.mit.edu]
You can do
link to [https://scratch.mit.edu] :: extension
link to [https://scratch.mit.edu] :: extension
Just to make it look better
Another thing you can do is instead of using
[code]
[/code]
You can do
[code=javascript]
[/code]
And instead of being all grey, it makes the text look like
(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'};
    };
    ext.my_first_block = function(website) {
        window.location.href = website;
    };
    // Block and block menu descriptions
    var descriptor = {
        blocks: [
            // Block type, block name, function name
            [' ', 'link to %s', 'my_first_block', 'https://scratch.mit.edu'],
        ]
    };
    // Register the extension
    ScratchExtensions.register('Link', descriptor, ext);
})({});
So it's easier to understand. Anyway, great extension, and I look forward to seeing what you create in the future


Hey! I like working with Scratch 3.

Scratch 3 Modding

My Website
donotforgetmycode
Scratcher
100+ posts

My Scratch Extension

JGames101 wrote:

This is great! I remember my first extension was just true and false blocks…
Here are a few tips for your forum post, though:
instead of having your block look like
link to [https://scratch.mit.edu]
link to [https://scratch.mit.edu]
You can do
link to [https://scratch.mit.edu] :: extension
link to [https://scratch.mit.edu] :: extension
Just to make it look better
Another thing you can do is instead of using
[code]
[/code]
You can do
[code=javascript]
[/code]
And instead of being all grey, it makes the text look like
(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'};
    };
    ext.my_first_block = function(website) {
        window.location.href = website;
    };
    // Block and block menu descriptions
    var descriptor = {
        blocks: [
            // Block type, block name, function name
            [' ', 'link to %s', 'my_first_block', 'https://scratch.mit.edu'],
        ]
    };
    // Register the extension
    ScratchExtensions.register('Link', descriptor, ext);
})({});
So it's easier to understand. Anyway, great extension, and I look forward to seeing what you create in the future
Thank you

Last edited by donotforgetmycode (Aug. 20, 2017 12:55:34)


<mouse down?> //Add comment here...


Those are my three pets. Johnny (the comment) eats signature thieves, John (the emoji) is a signature thief and Bob (the block) thinks that Johnny is annoying.

My semicolon was eaten by an evil Kaj
jackkillian
Scratcher
24 posts

My Scratch Extension

You said go to Scratch and press Control+Shift+J.
The Scratch homepage or the Scratch project editor.

Last edited by jackkillian on March 9, 9999
#Bring_it_Back
Hi, and welcome to Scratch! Click Here to go to the Scratch home page.
jackkillian
Scratcher
24 posts

My Scratch Extension

My browser / operating system: MacOS Macintosh X 10.12.5, Chrome 60.0.3112.101, Flash 26.0 (release 0)
Not working for me on either.

Last edited by jackkillian on March 9, 9999
#Bring_it_Back
Hi, and welcome to Scratch! Click Here to go to the Scratch home page.
donotforgetmycode
Scratcher
100+ posts

My Scratch Extension

jackkillian wrote:

My browser / operating system: MacOS Macintosh X 10.12.5, Chrome 60.0.3112.101, Flash 26.0 (release 0)
Not working for me on either.
Try holding cmd instead of ctrl in the project editor. Do not do anything on the editor, otherwise the JavaScript console will not appear. ☺

<mouse down?> //Add comment here...


Those are my three pets. Johnny (the comment) eats signature thieves, John (the emoji) is a signature thief and Bob (the block) thinks that Johnny is annoying.

My semicolon was eaten by an evil Kaj
donotforgetmycode
Scratcher
100+ posts

My Scratch Extension

bump

<mouse down?> //Add comment here...


Those are my three pets. Johnny (the comment) eats signature thieves, John (the emoji) is a signature thief and Bob (the block) thinks that Johnny is annoying.

My semicolon was eaten by an evil Kaj

Powered by DjangoBB

Standard | Mobile