Skip to content

Commit 97e17f1

Browse files
authored
Merge pull request #681 from Samq64/admin-notifications
2 parents f212e50 + 5f78476 commit 97e17f1

5 files changed

Lines changed: 57 additions & 48 deletions

File tree

features/admin-notifications.js

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"title": "Red Admin Message Indicator",
3+
"description": "If you have an admin notification from the Scratch Team, the message indicator in the navigation bar will display red instead of orange.",
4+
"credits": [
5+
{
6+
"username": "rgantzos",
7+
"url": "https://scratch.mit.edu/users/rgantzos"
8+
}
9+
],
10+
"scripts": [
11+
{
12+
"file": "script.js",
13+
"runOn": "/*"
14+
}
15+
],
16+
"styles": [
17+
{
18+
"file": "style.css",
19+
"runOn": "/*"
20+
}
21+
],
22+
"tags": [],
23+
"type": ["Website"],
24+
"dynamic": "true"
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export default async function ({ feature, console }) {
2+
const session = await ScratchTools.Session();
3+
if (!session.user) return;
4+
5+
const username = session.user.username;
6+
const response = await fetch(
7+
`https://api.scratch.mit.edu/users/${username}/messages/admin`,
8+
{
9+
headers: {
10+
"x-token": session.user.token,
11+
},
12+
}
13+
);
14+
const data = await response.json();
15+
16+
if (data.length > 0) {
17+
if (feature.tab.scratch === 2) {
18+
document
19+
.querySelector(".notificationsCount")
20+
.classList.add("ste-red-alert");
21+
} else {
22+
document.querySelector(".message-count").classList.add("ste-red-alert");
23+
}
24+
}
25+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.ste-red-alert {
2+
background-color: #ff1a1a !important;
3+
}

features/features.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@
232232
"version": 2,
233233
"id": "box-shadows"
234234
},
235+
{
236+
"version": 2,
237+
"id": "admin-notifications"
238+
},
235239
{
236240
"title": "Nicknames",
237241
"description": "Set nicknames for other Scratchers. Only you can see the nicknames, and their username will be replaced with the nickname when you see their name.",
@@ -672,15 +676,6 @@
672676
"type": ["Website", "Editor"],
673677
"dynamic": true
674678
},
675-
{
676-
"title": "Message Indicator Red for Admin Messages",
677-
"description": "If you have an admin notification from the Scratch Team, the message indicator in the navigation bar will display red instead of orange.",
678-
"credits": ["rgantzos"],
679-
"urls": ["https://scratch.mit.edu/users/rgantzos/"],
680-
"file": "admin-notifications",
681-
"tags": [],
682-
"type": ["Website"]
683-
},
684679
{
685680
"title": "Custom Website Font",
686681
"description": "On the Scratch website, you can set the font to whatever font you want, as long as it is on the Google Fonts website. This is case-sensitive.",

0 commit comments

Comments
 (0)