forked from TurboWarp/extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.js
More file actions
39 lines (35 loc) · 890 Bytes
/
fetch.js
File metadata and controls
39 lines (35 loc) · 890 Bytes
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
// 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,
// eslint-disable-next-line extension/should-translate
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);