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 2 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
45 changes: 9 additions & 36 deletions features/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,8 @@
"type": ["Website"]
},
{
"title": "Show if Following on Profile",
"description": "If a user is following you, it will show next to their username when you visit their profile.",
"credits": ["Bob the Potato with Drip", "TimMcCool"],
"urls": [
"https://scratch.mit.edu/users/JefferyTheSuperKat/",
"https://scratch.mit.edu/users/TimMcCool/"
],
"file": "follows-you",
"type": ["Website"],
"tags": ["Featured"],
"dynamic": true
"version": 2,
"id": "follows-you"
},
{
"title": "Custom Studio Section",
Expand All @@ -203,15 +194,9 @@
{ "id": "Studio ID", "name": "Studio ID", "default": "27205657" }
]
},
{
"title": "Highlight Unanswered Forum Topics",
"description": "Adds a blue highlight to topics in the forums that have no replies.",
"credits": ["rgantzos"],
"urls": ["https://scratch.mit.edu/users/rgantzos/"],
"file": "highlight-unanswered",
"type": ["Website"],
"tags": ["New", "Recommended"],
"dynamic": true
{
"version": 2,
"id": "highlight-unanswered"
},
{
"title": "Hide Project Tags",
Expand Down Expand Up @@ -764,13 +749,8 @@
"type": ["Website"]
},
{
"title": "Go to Parent Button",
"description": "In the editor for any project that is a remix, you can click a button to go to the editor in the parent project.",
"credits": ["rgantzos"],
"urls": ["https://scratch.mit.edu/users/rgantzos/"],
"file": "go-to-parent",
"tags": [],
"type": ["Editor"]
"version": 2,
"id": "go-to-parent"
},
{
"title": "Most Popular Project",
Expand Down Expand Up @@ -1013,15 +993,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"]
"version": 2,
"id": "round-profile-pictures"
},
{
"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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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();