forked from scratchfoundation/scratch-extension-docs
-
Notifications
You must be signed in to change notification settings - Fork 8
/
browser_extension.js
45 lines (35 loc) · 1.1 KB
/
browser_extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Scratch Extension to demonstrate some simple web browser functionality
// 2014 Shane M. Clements
(function(ext) {
ext.alert = function(message) {
alert(message);
};
ext.confirm = function(question) {
return confirm(question);
};
ext.ask = function(question) {
return prompt(question);
};
ext.setTitle = function(title) {
window.document.title = title;
};
ext.openTab = function(location) {
window.open(location, '_blank');
};
ext._shutdown = function() {
console.log('Shutting down...');
};
ext._getStatus = function() {
return {status: 2, msg: 'Ready'};
};
var descriptor = {
blocks: [
[' ', 'alert %s', 'alert', ''],
['r', 'confirm %s', 'confirm', 'Are you sure?'],
['r', 'ask %s', 'ask', 'How are you?'],
[' ', 'set window title to %s', 'setTitle', 'title'],
[' ', 'open tab with %s', 'openTab', 'https://twitter.com/scratchteam']
]
};
ScratchExtensions.register('Browser Stuff', descriptor, ext);
})({});