Skip to content

Commit 55bb51e

Browse files
authored
Merge pull request #985 from rgantzos/main
Request permissions API
2 parents b3be510 + 1a87e03 commit 55bb51e

31 files changed

+488
-2
lines changed

api/feature.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ class Feature {
66
finalFeature = el;
77
}
88
});
9+
this.requestPermissions = async function(...permissions) {
10+
return await ScratchTools.sendMessage("request-perms", permissions)
11+
}
912
this.data = finalFeature;
1013
this.msg = function (string) {
1114
return this.data.localesData[`${this.data.id}/`+string] || `ScratchTools.${this.data.id}.${string}`;

api/main.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,23 @@ if (
101101
ScratchTools.type = "Website";
102102
}
103103

104+
ScratchTools.MESSAGES = []
105+
ScratchTools.sendMessage = function(id, content) {
106+
let uuid = UUID()
107+
chrome.runtime.sendMessage(ScratchTools.id, { message: id, content, source: "message-api", uuid });
108+
return new Promise((resolve, reject) => {
109+
ScratchTools.MESSAGES.push({ message: id, source: "message-api", uuid, resolve });
110+
});
111+
}
112+
113+
function UUID() {
114+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
115+
const random = Math.random() * 16 | 0;
116+
const value = char === 'x' ? random : (random & 0x3 | 0x8);
117+
return value.toString(16);
118+
});
119+
}
120+
104121
var storagePromises = [];
105122
ScratchTools.storage = {
106123
get: async function (key) {

api/update/changelogs/forum.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"active": false,
3+
"title": "Forum Changes for {{ version }}",
4+
"description": "",
5+
"changes": []
6+
}
7+

api/update/changelogs/project.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"active": true,
3+
"title": "Project Page Changes for {{ version }}",
4+
"description": "ScratchTools is introducing many new project page and editor features that will revolutionize the way that you use Scratch. You can enable them on the settings page.",
5+
"changes": [
6+
{
7+
"icon": "gradient.svg",
8+
"slogan": "Rotate gradient colors in the paint editor"
9+
},
10+
{
11+
"icon": "align.svg",
12+
"slogan": "Align shapes and objects in the paint editor"
13+
},
14+
{
15+
"icon": "align.svg",
16+
"slogan": "Quickly center text in your project instructions"
17+
},
18+
{
19+
"icon": "extend.svg",
20+
"slogan": "Extend C-blocks around code when dragging them"
21+
},
22+
{
23+
"icon": "filesize.svg",
24+
"slogan": "View file sizes for any asset"
25+
},
26+
{
27+
"icon": "font.svg",
28+
"slogan": "Use dozens of extra fonts in the paint editor"
29+
},
30+
{
31+
"icon": "nocloud.svg",
32+
"slogan": "Temporarily disable cloud variables in projects"
33+
},
34+
{
35+
"icon": "opacity.svg",
36+
"slogan": "Customize the opacity of stage variable monitors"
37+
},
38+
{
39+
"icon": "outline.svg",
40+
"slogan": "Customize and round lines and shape outlines"
41+
},
42+
{
43+
"icon": "reaction.svg",
44+
"slogan": "Add and view emoji reactions on any project"
45+
},
46+
{
47+
"icon": "record.svg",
48+
"slogan": "Record and save videos of your project stage"
49+
},
50+
{
51+
"icon": "shapes.svg",
52+
"slogan": "Unite, subtract, intersect, and exclude shapes"
53+
},
54+
{
55+
"icon": "thumbnail.svg",
56+
"slogan": "Upload custom project thumbnails"
57+
},
58+
{
59+
"icon": "upload.svg",
60+
"slogan": "Upload WEBP images as costumes and sprites"
61+
}
62+
]
63+
}

api/update/changelogs/website.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"active": true,
3+
"title": "Website Changes for {{ version }}",
4+
"description": "ScratchTools is introducing many new features for the Scratch website. You can enable them on the settings page.",
5+
"changes": [
6+
{
7+
"icon": "change.svg",
8+
"slogan": "Customize what tag is used by default on the explore page"
9+
},
10+
{
11+
"icon": "gift.svg",
12+
"slogan": "A ScratchTools selection of featured projects"
13+
},
14+
{
15+
"icon": "filter.svg",
16+
"slogan": "Filter through studio, explore, and searched projects"
17+
},
18+
{
19+
"icon": "date.svg",
20+
"slogan": "See when a studio was created"
21+
},
22+
{
23+
"icon": "countdown.svg",
24+
"slogan": "View how many replies are left in a thread"
25+
}
26+
]
27+
}
28+

api/update/icons/align.svg

Lines changed: 1 addition & 0 deletions
Loading

api/update/icons/change.svg

Lines changed: 1 addition & 0 deletions
Loading

api/update/icons/countdown.svg

Lines changed: 1 addition & 0 deletions
Loading

api/update/icons/date.svg

Lines changed: 1 addition & 0 deletions
Loading

api/update/icons/extend.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)