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

"Round Profile Pictures" update to feature version 2 #494

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions features/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -1013,15 +1013,8 @@
"type": ["Editor"]
},
{
"title": "Round Profile Pictures",
"description": "All profile pictures on the Scratch website will be rounded.",
"credits": ["Scratchfangs", "rgantzos"],
"urls": [
"https://scratch.mit.edu/users/scratchfangs/",
"https://scratch.mit.edu/users/rgantzos/"
],
"file": "round-profile-pictures",
"type": ["Website", "Theme"]
"id": "round-profile-pictures",
"version": 2
Comment on lines +1016 to +1017
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature was previously bugged and has a few super cool new changes with this update, so let's move this to the top of the list as well.

},
{
"title": "Sidebar",
Expand Down
14 changes: 14 additions & 0 deletions features/round-profile-pictures/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"title": "Round Profile Pictures",
"description": "All profile pictures on the Scratch website will be rounded.",
"credits": [
{ "username": "Scratchfangs", "url": "https://scratch.mit.edu/users/scratchfangs/" },
{ "username": "rgantzos", "url": "https://scratch.mit.edu/users/rgantzos/" }
],
"type": ["Website", "Theme"],
"tags": [],
"scripts": [{ "file": "script.js", "runOn": "/*" }],
"options": [
{ "id": "Rounding Percentage", "name": "Rounding Percentage", "default": "50%" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to add things like this, then we should also add an option validation system.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make an issue for this and it should be added in the next few days.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Wilamaxin It's been merged, something like "validation":[{ "regex": "^(100(?:\\.0{1,2})?|\\d{1,2}(?:\\.\\d{1,2})?)%$", "explanation": "Percentage must be between 0% and 100%."}] for the option would work now.

]
}
17 changes: 17 additions & 0 deletions features/round-profile-pictures/script.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this would work better as CSS. Options create CSS variables, so something such as img[src*="/get_image/user/"] should work as a selector, and then the CSS variable could just be used for roundness.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var roundness = ScratchTools.Storage["Rounding Percentage"];
if (!roundness.includes("%")){roundness = roundness.concat("%");}
function roundProfile() {
document.querySelectorAll("img").forEach(function (el) {
if (el.src !== undefined) {
if (el.src.includes("scratch.mit.edu/get_image/user/")) {
el.style.borderRadius = roundness;
}
}
document.querySelectorAll(".mod-social-message").forEach(function (mod) {
mod.style.paddingLeft = ".825rem";
el.style.paddingRight = "0rem";
});
});
window.setTimeout(roundProfile, 80);
}
roundProfile();