Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons Galore - Mass Icon Unification #617

Merged
merged 12 commits into from Nov 1, 2020
21 changes: 12 additions & 9 deletions addons/scratch-notifier/addon.json
Expand Up @@ -4,6 +4,9 @@
"credits": [
{
"name": "World_Languages"
},
{
"name": "NitroCipher/ZenithRogue"
}
],
"permissions": ["notifications"],
Expand All @@ -16,55 +19,55 @@
"default": true
},
{
"name": "💬 Notify profile comments & replies",
"name": "@comment.svg Notify profile comments & replies",
"id": "commentsforme_notifications",
"type": "boolean",
"default": true
},
{
"name": "💬 Notify comments on my projects",
"name": "@comment.svg Notify comments on my projects",
"id": "commentsonmyprojects_notifications",
"type": "boolean",
"default": true
},
{
"name": "📚 Notify forum activity",
"name": "@forum.svg Notify forum activity",
"id": "forumpost_notifications",
"type": "boolean",
"default": true
},
{
"name": "❤️ Notify loves",
"name": "@heart.svg Notify loves",
"id": "loveproject_notifications",
"type": "boolean",
"default": true
},
{
"name": " Notify favorites",
"name": "@star.svg Notify favorites",
"id": "favoriteproject_notifications",
"type": "boolean",
"default": true
},
{
"name": "🧑 Notify new followers",
"name": "@follow.svg Notify new followers",
"id": "followuser_notifications",
"type": "boolean",
"default": true
},
{
"name": "✉️ Notify studio invites",
"name": "@studio-add.svg Notify studio invites",
"id": "curatorinvite_notifications",
"type": "boolean",
"default": true
},
{
"name": "🆕 Notify studio activity",
"name": "@studio.svg Notify studio activity",
"id": "studioactivity_notifications",
"type": "boolean",
"default": true
},
{
"name": "🔄 Notify remixes",
"name": "@remix.svg Notify remixes",
"id": "remixproject_notifications",
"type": "boolean",
"default": true
Expand Down
127 changes: 80 additions & 47 deletions addons/scratch-notifier/background.js
Expand Up @@ -5,14 +5,14 @@ export default async function ({ addon, global, console, setTimeout, setInterval
let lastDateTime = null;
let lastAuthChange; // Used to check if auth changed while waiting for promises to resolve
const emojis = {
addcomment: "💬",
forumpost: "📚",
loveproject: "❤️",
favoriteproject: "",
followuser: "🧑",
curatorinvite: "✉️",
remixproject: "🔄",
studioactivity: "🆕",
addcomment: "comment",
forumpost: "forum",
loveproject: "heart",
favoriteproject: "star",
followuser: "follow",
curatorinvite: "studio-add",
remixproject: "remix",
studioactivity: "studio",
};

checkCount();
Expand Down Expand Up @@ -44,52 +44,85 @@ export default async function ({ addon, global, console, setTimeout, setInterval
}) {
let text = "";
let url;
if (emoji) text += `${emoji} `;
if (messageType.startsWith("addcomment/")) {
url = commentUrl;
if (title.length > 20) title = `${title.substring(0, 17).trimEnd()}...`;
if (messageType === "addcomment/ownProjectNewComment") {
text += `${actor} commented in your project "${title}":\n${fragment}`;
} else if (messageType === "addcomment/projectReplyToSelf") {
text += `${actor} replied to you in project "${title}":\n${fragment}`;
} else if (messageType === "addcomment/ownProjectReplyToOther") {
text += `${actor} replied to ${commentee} in project "${title}":\n${fragment}`;
} else if (messageType === "addcomment/ownProfileNewComment") {
text += `${actor} commented in your profile:\n${fragment}`;
} else if (messageType === "addcomment/ownProfileReplyToSelf") {
text += `${actor} replied to you in your profile:\n${fragment}`;
} else if (messageType === "addcomment/ownProfileReplyToOther") {
text += `${actor} replied to ${commentee} in your profile:\n${fragment}`;
} else if (messageType === "addcomment/otherProfileReplyToSelf") {
text += `${actor} replied in ${title}'s profile:\n${fragment}`;
} else if (messageType === "addcomment/studio") {
text += `${actor} replied in studio "${title}":\n${fragment}`;
var notificationTitle;
switch (messageType.split("/")[1]) {
case "ownProjectNewComment":
notificationTitle = `${actor} commented on your project "${title}"`;
text = fragment;
break;
case "projectReplyToSelf":
notificationTitle = `${actor} replied to you on project "${title}"`;
text = fragment;
break;
case "ownProjectReplyToOther":
notificationTitle = `${actor} replied to ${commentee} on project "${title}"`;
text = fragment;
break;
case "ownProfileNewComment":
notificationTitle = `${actor} commented on your profile`;
text = fragment;
break;
case "ownProfileReplyToSelf":
notificationTitle = `${actor} replied to you on your profile`;
text = fragment;
break;
case "ownProfileReplyToOther":
notificationTitle = `${actor} replied to ${commentee} on your profile`;
text = fragment;
break;
case "otherProfileReplyToSelf":
notificationTitle = `${actor} replied on ${title}'s profile`;
text = fragment;
break;
case "studio":
notificationTitle = `${actor} replied in studio "${title}"`;
text = fragment;
break;
default:
notificationTitle = "New Scratch comment";
break;
}
} else {
switch (messageType) {
case "forumpost":
notificationTitle = `There are new posts in the forum thread "${title}"`;
url = `https://scratch.mit.edu/discuss/topic/${element_id}/unread/`;
break;
case "loveproject":
notificationTitle = `${actor} loved your project "${title}"`;
url = `https://scratch.mit.edu/users/${actor}/`;
break;
case "favoriteproject":
notificationTitle = `${actor} favorited your project "${title}"`;
url = `https://scratch.mit.edu/users/${actor}/`;
break;
case "followuser":
notificationTitle = `${actor} is now following you`;
url = `https://scratch.mit.edu/users/${actor}/`;
break;
case "curatorinvite":
notificationTitle = `${actor} invited you to curate the studio "${title}"`;
url = `https://scratch.mit.edu/studios/${element_id}/curators/`;
break;
case "remixproject":
notificationTitle = `${actor} remixed your project "${parent_title}" as "${title}"`;
url = `https://scratch.mit.edu/projects/${element_id}/`;
break;
case "studioactivity":
notificationTitle = `There was new activity in studio "${title}" today`;
break;
default:
notificationTitle = "New Scratch message";
break;
}
} else if (messageType === "forumpost") {
text += `There are new posts in the forum thread "${title}"`;
url = `https://scratch.mit.edu/discuss/topic/${element_id}/unread/`;
} else if (messageType === "loveproject") {
text += `${actor} loved your project "${title}"`;
url = `https://scratch.mit.edu/users/${actor}/`;
} else if (messageType === "favoriteproject") {
text += `${actor} favorited your project "${title}"`;
url = `https://scratch.mit.edu/users/${actor}/`;
} else if (messageType === "followuser") {
text += `${actor} is now following you`;
url = `https://scratch.mit.edu/users/${actor}/`;
} else if (messageType === "curatorinvite") {
text += `${actor} invited you to curate the studio "${title}"`;
url = `https://scratch.mit.edu/studios/${element_id}/curators/`;
} else if (messageType === "remixproject") {
text += `${actor} remixed your project "${parent_title}" as "${title}"`;
url = `https://scratch.mit.edu/projects/${element_id}/`;
} else if (messageType === "studioactivity") {
text += `There was new activity in studio "${title}" today`;
}
const notifId = await addon.notifications.create({
type: "basic",
title: "New Scratch message",
iconUrl: "/images/icon.png",
title: notificationTitle,
iconUrl: emoji ? `../../images/icons/${emoji}.svg` : "/images/icon.png",
message: text,
buttons: [
{
Expand Down
File renamed without changes
1 change: 1 addition & 0 deletions images/icons/cloud.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/comment.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/envelope.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
1 change: 1 addition & 0 deletions images/icons/follow.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/forum.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/heart.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
1 change: 1 addition & 0 deletions images/icons/plus.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/popout.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
1 change: 1 addition & 0 deletions images/icons/read.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/reload.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/remix.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
1 change: 1 addition & 0 deletions images/icons/star.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/studio-add.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/icons/studio.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions images/icons/users.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
4 changes: 4 additions & 0 deletions popups/cloud-games/light.css
Expand Up @@ -20,3 +20,7 @@ body::-webkit-scrollbar-thumb {
.title a {
color: #222;
}

.small-icon:not(.colored) {
filter: brightness(0);
}
7 changes: 6 additions & 1 deletion popups/cloud-games/popup.css
Expand Up @@ -59,7 +59,7 @@ a:hover {
.float-right {
margin-left: 4px;
white-space: nowrap;
font-size: 0.9rem;
font-size: 12px;
}
.float-right > span {
display: inline-block;
Expand All @@ -86,3 +86,8 @@ a:hover {
.title a {
color: white;
}

.small-icon {
height: 14px;
vertical-align: text-bottom;
}