Skip to content
Merged
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
2 changes: 1 addition & 1 deletion extras/background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var version = "2.20.0";
var version = "2.21.0";

chrome.runtime.onInstalled.addListener(async function (object) {
chrome.alarms.clearAll();
Expand Down
4 changes: 2 additions & 2 deletions extras/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
update(
"ScratchTools v2.20.0",
"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!"
"ScratchTools v2.21.0",
"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."
);
function update(updateVersion, updateDescription) {
if (document.querySelector(".scratchtoolsUpdateInfo") === null) {
Expand Down
7 changes: 5 additions & 2 deletions features/block-count-in-mystuff.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ if (window.location.href.startsWith("https://scratch.mit.edu/mystuff")) {
ScratchTools.waitForElements(
"ul.media-list > li",
async function (el) {
if (stillLookingForBlockCount && !el.querySelector('.scratchtoolsBlockCount')) {
if (
stillLookingForBlockCount &&
!el.querySelector(".scratchtoolsBlockCount")
) {
if (el.querySelector('a[href*="/projects/"]')) {
var blocks = await getBlockCount(
el
Expand All @@ -39,7 +42,7 @@ if (window.location.href.startsWith("https://scratch.mit.edu/mystuff")) {
el.querySelector(".media-info-item.date.shortDateFormat").appendChild(
span
);
el.querySelector('a[data-control="edit"]').style.transition = 'none'
el.querySelector('a[data-control="edit"]').style.transition = "none";
el.querySelector('a[data-control="edit"]').style.marginTop = "1px";
}
}
Expand Down
6 changes: 3 additions & 3 deletions features/custom-studio.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ async function addStudioProjects(studioId) {
.querySelector(".inner.mod-splash")
.insertBefore(box, document.querySelector(".inner.mod-splash > .box"));
}
let alreadyStarted = false
let alreadyStarted = false;
ScratchTools.waitForElements(
".inner.mod-splash > .box",
function () {
let studioid = ScratchTools.Storage["Studio ID"];
if (/^\d+$/.test(studioid)) {
if (!alreadyStarted && document.querySelector('.splash-header')) {
alreadyStarted = true
if (!alreadyStarted && document.querySelector(".splash-header")) {
alreadyStarted = true;
addStudioProjects(studioid);
}
}
Expand Down
76 changes: 36 additions & 40 deletions features/features.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,16 @@
[
{
"title": "Frontpage Curator Name as Link",
"description": "Makes the name of the Frontpage Curator to a clickable link to his profile.",
"credits": ["Dr_Lego"],
"urls": [
"https://scratch.mit.edu/users/Dr_Lego/"
],
"file": "frontpage-curator",
"type": ["Website"],
"tags": ["New"]
},
[
{
"title": "Show User Statistics",
"description": "Replaces the 'What I've been doing' section on a profile page with the user's statistics.",
"credits": ["Dr_Lego"],
"title": "Direct image uploads in the forums",
"description": "Allows you to easily upload images to the Scratch forums for posts and signatures without having to use third party image uploading services.",
"credits": ["ISTILLMAKESTUFF", "TheGlassPenguin", "StickFireGames"],
"urls": [
"https://scratch.mit.edu/users/Dr_Lego/"
"https://scratch.mit.edu/users/ISTILLMAKESTUFF",
"https://scratch.mit.edu/users/TheGlassPenguin",
"https://scratch.mit.edu/users/stickfiregames"
],
"file": "user-stats",
"file": "upload-img-directly",
"type": ["Website"],
"tags": ["New"]
},
{
"title": "Minimized Remix Credits",
"description": "The remix credit boxes for projects take space from the project Instructions, so this makes the box smaller.",
"credits": ["callumjt", "rgantzos"],
"urls": [
"https://scratch.mit.edu/users/callumjt/",
"https://scratch.mit.edu/users/rgantzos/"
],
"file": "minimized-remix-credits",
"tags": ["New"],
"type": ["Website"]
"tags": ["New", "Recommended"]
},
{
"title": "Leave Studio Button",
Expand All @@ -46,17 +25,34 @@
"type": ["Website"]
},
{
"title": "Direct image uploads in the forums",
"description": "Allows you to easily upload images to the Scratch forums for posts and signatures without having to use third party image uploading services.",
"credits": ["ISTILLMAKESTUFF", "TheGlassPenguin", "StickFireGames"],
"title": "Show User Statistics",
"description": "Replaces the 'What I've been doing' section on a profile page with the user's statistics.",
"credits": ["Dr_Lego"],
"urls": ["https://scratch.mit.edu/users/Dr_Lego/"],
"file": "user-stats",
"type": ["Website"],
"tags": ["New"]
},
{
"title": "Frontpage Curator Name as Link",
"description": "Makes the name of the Frontpage Curator to a clickable link to his profile.",
"credits": ["Dr_Lego"],
"urls": ["https://scratch.mit.edu/users/Dr_Lego/"],
"file": "frontpage-curator",
"type": ["Website"],
"tags": ["New"]
},
{
"title": "Minimized Remix Credits",
"description": "The remix credit boxes for projects take space from the project Instructions, so this makes the box smaller.",
"credits": ["callumjt", "rgantzos"],
"urls": [
"https://scratch.mit.edu/users/ISTILLMAKESTUFF",
"https://scratch.mit.edu/users/TheGlassPenguin",
"https://scratch.mit.edu/users/stickfiregames"
"https://scratch.mit.edu/users/callumjt/",
"https://scratch.mit.edu/users/rgantzos/"
],
"file": "upload-img-directly",
"type": ["Website"],
"tags": ["New", "Recommended"]
"file": "minimized-remix-credits",
"tags": ["New"],
"type": ["Website"]
},
{
"title": "Show if Following on Profile",
Expand All @@ -68,7 +64,7 @@
],
"file": "follows-you",
"type": ["Website"],
"tags": ["New", "Featured"],
"tags": ["Featured"],
"dynamic": true
},
{
Expand Down
76 changes: 45 additions & 31 deletions features/follows-you.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
async function getFollowing(user1, user2) {
var notFound = true
var isFollowing = false
var offset = 0
var notFound = true;
var isFollowing = false;
var offset = 0;
while (notFound) {
var response = await fetch(`https://api.scratch.mit.edu/users/${user2}/following/?limit=40&offset=${offset.toString()}`)
var data = await response.json()
if (data.length === 0) {
notFound = false
}
data.forEach(function(el) {
if (el.username.toLowerCase() === user1.toLowerCase()) {
notFound = false
isFollowing = true
ScratchTools.waitForElements('.header-text', function(element) {
if (!document.querySelector('.scratchtoolsFollowsYou')) {
var span = element.insertBefore(document.createElement('span'), document.querySelector('.profile-details'))
span.className = 'scratchtoolsFollowsYou'
span.textContent = 'Follows You'
span.style.opacity = '.5'
span.style.fontSize = '.8rem'
element.querySelector('h2').style.display = 'inline-block'
}
})
var response = await fetch(
`https://api.scratch.mit.edu/users/${user2}/following/?limit=40&offset=${offset.toString()}`
);
var data = await response.json();
if (data.length === 0) {
notFound = false;
}
data.forEach(function (el) {
if (el.username.toLowerCase() === user1.toLowerCase()) {
notFound = false;
isFollowing = true;
ScratchTools.waitForElements(".header-text", function (element) {
if (!document.querySelector(".scratchtoolsFollowsYou")) {
var span = element.insertBefore(
document.createElement("span"),
document.querySelector(".profile-details")
);
span.className = "scratchtoolsFollowsYou";
span.textContent = "Follows You";
span.style.opacity = ".5";
span.style.fontSize = ".8rem";
element.querySelector("h2").style.display = "inline-block";
}
})
offset = offset+40
});
}
});
offset = offset + 40;
}

}
if (window.location.href.toLowerCase().startsWith('https://scratch.mit.edu/users/')) {
getFollowing(Scratch.INIT_DATA.LOGGED_IN_USER.model.username, window.location.href.toLowerCase().split('https://scratch.mit.edu/users/')[1].split('/')[0])
if (
window.location.href
.toLowerCase()
.startsWith("https://scratch.mit.edu/users/")
) {
getFollowing(
Scratch.INIT_DATA.LOGGED_IN_USER.model.username,
window.location.href
.toLowerCase()
.split("https://scratch.mit.edu/users/")[1]
.split("/")[0]
);
}

ScratchTools.setDisable('follows-you', function() {
if (document.querySelector('.scratchtoolsFollowsYou')) {
document.querySelector('.scratchtoolsFollowsYou').remove()
ScratchTools.setDisable("follows-you", function () {
if (document.querySelector(".scratchtoolsFollowsYou")) {
document.querySelector(".scratchtoolsFollowsYou").remove();
}
})
});
12 changes: 7 additions & 5 deletions features/frontpage-curator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
if (window.location.href == "https://scratch.mit.edu/"){
text = document.getElementsByClassName("inner mod-splash")[1].firstChild.firstChild.firstChild;
Name = text.innerText.split(" ")[3]
text.innerHTML = `Projects Curated by <a href='https://scratch.mit.edu/users/${Name}/'>${Name}</a>`
};
if (window.location.href == "https://scratch.mit.edu/") {
text =
document.getElementsByClassName("inner mod-splash")[1].firstChild.firstChild
.firstChild;
Name = text.innerText.split(" ")[3];
text.innerHTML = `Projects Curated by <a href='https://scratch.mit.edu/users/${Name}/'>${Name}</a>`;

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML

[DOM text](1) is reinterpreted as HTML without escaping meta-characters.
}
12 changes: 6 additions & 6 deletions features/hide-block-category-names.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var style = document.createElement('style')
var style = document.createElement("style");
style.textContent = `
.scratchCategoryItemBubble {
border-radius: .2rem !important;
Expand All @@ -8,8 +8,8 @@ style.textContent = `
.scratchCategoryMenuItemLabel {
display: none !important;
}
`
document.body.appendChild(style)
ScratchTools.setDisable('hide-block-category-names', function() {
style.remove()
})
`;
document.body.appendChild(style);
ScratchTools.setDisable("hide-block-category-names", function () {
style.remove();
});
2 changes: 1 addition & 1 deletion features/highlight-unanswered.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ ScratchTools.setDisable("highlight-unanswered", function () {
document.querySelectorAll("tbody > tr").forEach(function (el) {
el.style.backgroundColor = null;
});
});
});
Loading