forked from TurboWarp/extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch.js
38 lines (34 loc) · 823 Bytes
/
fetch.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
// Name: Fetch
// ID: fetch
// Description: Make requests to the broader internet.
// License: MIT AND MPL-2.0
(function (Scratch) {
"use strict";
class Fetch {
getInfo() {
return {
id: "fetch",
name: Scratch.translate("Fetch"),
blocks: [
{
opcode: "get",
blockType: Scratch.BlockType.REPORTER,
text: "GET [URL]",
arguments: {
URL: {
type: Scratch.ArgumentType.STRING,
defaultValue: "https://extensions.turbowarp.org/hello.txt",
},
},
},
],
};
}
get(args) {
return Scratch.fetch(args.URL)
.then((r) => r.text())
.catch(() => "");
}
}
Scratch.extensions.register(new Fetch());
})(Scratch);