Skip to content

Commit 0712260

Browse files
authored
Merge pull request #281 from rgantzos/main
format, bump version, add new description
2 parents 3aaee1e + 1bed1f2 commit 0712260

14 files changed

+300
-211
lines changed

extras/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var version = "2.20.0";
1+
var version = "2.21.0";
22

33
chrome.runtime.onInstalled.addListener(async function (object) {
44
chrome.alarms.clearAll();

extras/new.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
update(
2-
"ScratchTools v2.20.0",
3-
"We are so happy to be releasing v2.20.0! This new version includes a lot of new features, including the ability to see if someone is following you, just by looking at their profile!"
2+
"ScratchTools v2.21.0",
3+
"This new version includes plenty of new features, including the ability to upload images directly to the forums without using other image hosting services. It also adds a user statistics box on profiles, as well as a button to leave studios."
44
);
55
function update(updateVersion, updateDescription) {
66
if (document.querySelector(".scratchtoolsUpdateInfo") === null) {

features/block-count-in-mystuff.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ if (window.location.href.startsWith("https://scratch.mit.edu/mystuff")) {
2121
ScratchTools.waitForElements(
2222
"ul.media-list > li",
2323
async function (el) {
24-
if (stillLookingForBlockCount && !el.querySelector('.scratchtoolsBlockCount')) {
24+
if (
25+
stillLookingForBlockCount &&
26+
!el.querySelector(".scratchtoolsBlockCount")
27+
) {
2528
if (el.querySelector('a[href*="/projects/"]')) {
2629
var blocks = await getBlockCount(
2730
el
@@ -39,7 +42,7 @@ if (window.location.href.startsWith("https://scratch.mit.edu/mystuff")) {
3942
el.querySelector(".media-info-item.date.shortDateFormat").appendChild(
4043
span
4144
);
42-
el.querySelector('a[data-control="edit"]').style.transition = 'none'
45+
el.querySelector('a[data-control="edit"]').style.transition = "none";
4346
el.querySelector('a[data-control="edit"]').style.marginTop = "1px";
4447
}
4548
}

features/custom-studio.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ async function addStudioProjects(studioId) {
8282
.querySelector(".inner.mod-splash")
8383
.insertBefore(box, document.querySelector(".inner.mod-splash > .box"));
8484
}
85-
let alreadyStarted = false
85+
let alreadyStarted = false;
8686
ScratchTools.waitForElements(
8787
".inner.mod-splash > .box",
8888
function () {
8989
let studioid = ScratchTools.Storage["Studio ID"];
9090
if (/^\d+$/.test(studioid)) {
91-
if (!alreadyStarted && document.querySelector('.splash-header')) {
92-
alreadyStarted = true
91+
if (!alreadyStarted && document.querySelector(".splash-header")) {
92+
alreadyStarted = true;
9393
addStudioProjects(studioid);
9494
}
9595
}

features/features.json

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,16 @@
1-
[
2-
{
3-
"title": "Frontpage Curator Name as Link",
4-
"description": "Makes the name of the Frontpage Curator to a clickable link to his profile.",
5-
"credits": ["Dr_Lego"],
6-
"urls": [
7-
"https://scratch.mit.edu/users/Dr_Lego/"
8-
],
9-
"file": "frontpage-curator",
10-
"type": ["Website"],
11-
"tags": ["New"]
12-
},
1+
[
132
{
14-
"title": "Show User Statistics",
15-
"description": "Replaces the 'What I've been doing' section on a profile page with the user's statistics.",
16-
"credits": ["Dr_Lego"],
3+
"title": "Direct image uploads in the forums",
4+
"description": "Allows you to easily upload images to the Scratch forums for posts and signatures without having to use third party image uploading services.",
5+
"credits": ["ISTILLMAKESTUFF", "TheGlassPenguin", "StickFireGames"],
176
"urls": [
18-
"https://scratch.mit.edu/users/Dr_Lego/"
7+
"https://scratch.mit.edu/users/ISTILLMAKESTUFF",
8+
"https://scratch.mit.edu/users/TheGlassPenguin",
9+
"https://scratch.mit.edu/users/stickfiregames"
1910
],
20-
"file": "user-stats",
11+
"file": "upload-img-directly",
2112
"type": ["Website"],
22-
"tags": ["New"]
23-
},
24-
{
25-
"title": "Minimized Remix Credits",
26-
"description": "The remix credit boxes for projects take space from the project Instructions, so this makes the box smaller.",
27-
"credits": ["callumjt", "rgantzos"],
28-
"urls": [
29-
"https://scratch.mit.edu/users/callumjt/",
30-
"https://scratch.mit.edu/users/rgantzos/"
31-
],
32-
"file": "minimized-remix-credits",
33-
"tags": ["New"],
34-
"type": ["Website"]
13+
"tags": ["New", "Recommended"]
3514
},
3615
{
3716
"title": "Leave Studio Button",
@@ -46,17 +25,34 @@
4625
"type": ["Website"]
4726
},
4827
{
49-
"title": "Direct image uploads in the forums",
50-
"description": "Allows you to easily upload images to the Scratch forums for posts and signatures without having to use third party image uploading services.",
51-
"credits": ["ISTILLMAKESTUFF", "TheGlassPenguin", "StickFireGames"],
28+
"title": "Show User Statistics",
29+
"description": "Replaces the 'What I've been doing' section on a profile page with the user's statistics.",
30+
"credits": ["Dr_Lego"],
31+
"urls": ["https://scratch.mit.edu/users/Dr_Lego/"],
32+
"file": "user-stats",
33+
"type": ["Website"],
34+
"tags": ["New"]
35+
},
36+
{
37+
"title": "Frontpage Curator Name as Link",
38+
"description": "Makes the name of the Frontpage Curator to a clickable link to his profile.",
39+
"credits": ["Dr_Lego"],
40+
"urls": ["https://scratch.mit.edu/users/Dr_Lego/"],
41+
"file": "frontpage-curator",
42+
"type": ["Website"],
43+
"tags": ["New"]
44+
},
45+
{
46+
"title": "Minimized Remix Credits",
47+
"description": "The remix credit boxes for projects take space from the project Instructions, so this makes the box smaller.",
48+
"credits": ["callumjt", "rgantzos"],
5249
"urls": [
53-
"https://scratch.mit.edu/users/ISTILLMAKESTUFF",
54-
"https://scratch.mit.edu/users/TheGlassPenguin",
55-
"https://scratch.mit.edu/users/stickfiregames"
50+
"https://scratch.mit.edu/users/callumjt/",
51+
"https://scratch.mit.edu/users/rgantzos/"
5652
],
57-
"file": "upload-img-directly",
58-
"type": ["Website"],
59-
"tags": ["New", "Recommended"]
53+
"file": "minimized-remix-credits",
54+
"tags": ["New"],
55+
"type": ["Website"]
6056
},
6157
{
6258
"title": "Show if Following on Profile",
@@ -68,7 +64,7 @@
6864
],
6965
"file": "follows-you",
7066
"type": ["Website"],
71-
"tags": ["New", "Featured"],
67+
"tags": ["Featured"],
7268
"dynamic": true
7369
},
7470
{

features/follows-you.js

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,53 @@
11
async function getFollowing(user1, user2) {
2-
var notFound = true
3-
var isFollowing = false
4-
var offset = 0
2+
var notFound = true;
3+
var isFollowing = false;
4+
var offset = 0;
55
while (notFound) {
6-
var response = await fetch(`https://api.scratch.mit.edu/users/${user2}/following/?limit=40&offset=${offset.toString()}`)
7-
var data = await response.json()
8-
if (data.length === 0) {
9-
notFound = false
10-
}
11-
data.forEach(function(el) {
12-
if (el.username.toLowerCase() === user1.toLowerCase()) {
13-
notFound = false
14-
isFollowing = true
15-
ScratchTools.waitForElements('.header-text', function(element) {
16-
if (!document.querySelector('.scratchtoolsFollowsYou')) {
17-
var span = element.insertBefore(document.createElement('span'), document.querySelector('.profile-details'))
18-
span.className = 'scratchtoolsFollowsYou'
19-
span.textContent = 'Follows You'
20-
span.style.opacity = '.5'
21-
span.style.fontSize = '.8rem'
22-
element.querySelector('h2').style.display = 'inline-block'
23-
}
24-
})
6+
var response = await fetch(
7+
`https://api.scratch.mit.edu/users/${user2}/following/?limit=40&offset=${offset.toString()}`
8+
);
9+
var data = await response.json();
10+
if (data.length === 0) {
11+
notFound = false;
12+
}
13+
data.forEach(function (el) {
14+
if (el.username.toLowerCase() === user1.toLowerCase()) {
15+
notFound = false;
16+
isFollowing = true;
17+
ScratchTools.waitForElements(".header-text", function (element) {
18+
if (!document.querySelector(".scratchtoolsFollowsYou")) {
19+
var span = element.insertBefore(
20+
document.createElement("span"),
21+
document.querySelector(".profile-details")
22+
);
23+
span.className = "scratchtoolsFollowsYou";
24+
span.textContent = "Follows You";
25+
span.style.opacity = ".5";
26+
span.style.fontSize = ".8rem";
27+
element.querySelector("h2").style.display = "inline-block";
2528
}
26-
})
27-
offset = offset+40
29+
});
30+
}
31+
});
32+
offset = offset + 40;
2833
}
29-
3034
}
31-
if (window.location.href.toLowerCase().startsWith('https://scratch.mit.edu/users/')) {
32-
getFollowing(Scratch.INIT_DATA.LOGGED_IN_USER.model.username, window.location.href.toLowerCase().split('https://scratch.mit.edu/users/')[1].split('/')[0])
35+
if (
36+
window.location.href
37+
.toLowerCase()
38+
.startsWith("https://scratch.mit.edu/users/")
39+
) {
40+
getFollowing(
41+
Scratch.INIT_DATA.LOGGED_IN_USER.model.username,
42+
window.location.href
43+
.toLowerCase()
44+
.split("https://scratch.mit.edu/users/")[1]
45+
.split("/")[0]
46+
);
3347
}
3448

35-
ScratchTools.setDisable('follows-you', function() {
36-
if (document.querySelector('.scratchtoolsFollowsYou')) {
37-
document.querySelector('.scratchtoolsFollowsYou').remove()
49+
ScratchTools.setDisable("follows-you", function () {
50+
if (document.querySelector(".scratchtoolsFollowsYou")) {
51+
document.querySelector(".scratchtoolsFollowsYou").remove();
3852
}
39-
})
53+
});

features/frontpage-curator.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
if (window.location.href == "https://scratch.mit.edu/"){
2-
text = document.getElementsByClassName("inner mod-splash")[1].firstChild.firstChild.firstChild;
3-
Name = text.innerText.split(" ")[3]
4-
text.innerHTML = `Projects Curated by <a href='https://scratch.mit.edu/users/${Name}/'>${Name}</a>`
5-
};
1+
if (window.location.href == "https://scratch.mit.edu/") {
2+
text =
3+
document.getElementsByClassName("inner mod-splash")[1].firstChild.firstChild
4+
.firstChild;
5+
Name = text.innerText.split(" ")[3];
6+
text.innerHTML = `Projects Curated by <a href='https://scratch.mit.edu/users/${Name}/'>${Name}</a>`;
7+
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var style = document.createElement('style')
1+
var style = document.createElement("style");
22
style.textContent = `
33
.scratchCategoryItemBubble {
44
border-radius: .2rem !important;
@@ -8,8 +8,8 @@ style.textContent = `
88
.scratchCategoryMenuItemLabel {
99
display: none !important;
1010
}
11-
`
12-
document.body.appendChild(style)
13-
ScratchTools.setDisable('hide-block-category-names', function() {
14-
style.remove()
15-
})
11+
`;
12+
document.body.appendChild(style);
13+
ScratchTools.setDisable("hide-block-category-names", function () {
14+
style.remove();
15+
});

features/highlight-unanswered.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ ScratchTools.setDisable("highlight-unanswered", function () {
1616
document.querySelectorAll("tbody > tr").forEach(function (el) {
1717
el.style.backgroundColor = null;
1818
});
19-
});
19+
});

0 commit comments

Comments
 (0)