From c91dc6dc5854073105e8b4ec257b9fc6b110a46f Mon Sep 17 00:00:00 2001 From: rgantzos <86856959+rgantzos@users.noreply.github.com> Date: Tue, 8 Aug 2023 08:49:37 -0700 Subject: [PATCH] Fix dumpster fire with custom studio section --- features/dumpster-fire/data.json | 14 ++++++++++++++ features/dumpster-fire/script.js | 20 ++++++++++++++++++++ features/features.json | 17 +++++------------ 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 features/dumpster-fire/data.json create mode 100644 features/dumpster-fire/script.js diff --git a/features/dumpster-fire/data.json b/features/dumpster-fire/data.json new file mode 100644 index 00000000..2715fac2 --- /dev/null +++ b/features/dumpster-fire/data.json @@ -0,0 +1,14 @@ +{ + "title": "Dumpster Fire", + "description": "The Scratch homepage is a liar with their \"Featured Projects\" section. This changes the name to the proper form, which is \"Dumpster Fire\".", + "credits": [ + { + "username": "Kuzyn_Official", + "url": "https://scratch.mit.edu/users/Kuzyn_Official/" + }, + { "username": "rgantzos", "url": "https://scratch.mit.edu/users/rgantzos/" } + ], + "type": ["Website", "Egg"], + "dynamic": true, + "scripts": [{ "file": "script.js", "runOn": "/" }] +} diff --git a/features/dumpster-fire/script.js b/features/dumpster-fire/script.js new file mode 100644 index 00000000..3bbdfea3 --- /dev/null +++ b/features/dumpster-fire/script.js @@ -0,0 +1,20 @@ +export default async function ({ feature }) { + let box = await ScratchTools.waitForElement(".inner.mod-splash > .box"); + + if (box.className.includes("scratchtoolsCustomStudio")) { + box = box.nextSibling; + } + + let oldContent = box.querySelector("h4").textContent; + if (feature.self.enabled) { + box.querySelector("h4").textContent = "Dumpster Fire"; + } + + feature.addEventListener("disabled", function () { + box.querySelector("h4").textContent = oldContent; + }); + + feature.addEventListener("enabled", function () { + box.querySelector("h4").textContent = "Dumpster Fire"; + }); +} diff --git a/features/features.json b/features/features.json index 101108f9..54977cce 100644 --- a/features/features.json +++ b/features/features.json @@ -1,4 +1,9 @@ [ + { + "version": 2, + "id": "dumpster-fire", + "versionUpdated": "v3.1.0" + }, { "version": 2, "id": "steal-game", @@ -424,18 +429,6 @@ "tags": [], "dynamic": true }, - { - "title": "Dumpster Fire", - "description": "The Scratch homepage is a liar with their \"Featured Projects\" section. This changes the name to the proper form, which is \"Dumpster Fire\".", - "credits": ["Kuzyn_Official", "rgantzos"], - "urls": [ - "https://scratch.mit.edu/users/Kuzyn_Official/", - "https://scratch.mit.edu/users/rgantzos/" - ], - "file": "dumpster-fire", - "type": ["Website", "Egg"], - "dynamic": true - }, { "title": "Follower Count on Projects", "description": "Displays the follower count of the project creator on their projects.",