From 8f9fb4c2396adc8afbd3aa5f7ef94940d4865553 Mon Sep 17 00:00:00 2001 From: rgantzos <86856959+rgantzos@users.noreply.github.com> Date: Sun, 3 Aug 2025 09:17:29 -0700 Subject: [PATCH 1/4] Update `advanced-search` --- features/advanced-search/script.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/features/advanced-search/script.js b/features/advanced-search/script.js index 3699b3f6..107329bc 100644 --- a/features/advanced-search/script.js +++ b/features/advanced-search/script.js @@ -1,24 +1,24 @@ -async function checkIfUser() { +export default async function ({ feature, console, className }) { var search = new URLSearchParams(window.location.search).get("q"); var user = await ( await fetch(`https://api.scratch.mit.edu/users/${search}/`) ).json(); if (user.username) { var div = document.createElement("div"); - div.className = "ste-search-user"; + div.className = className("search user"); var pfp = document.createElement("img"); pfp.src = user.profile.images["90x90"]; - pfp.className = "ste-search-user-pfp"; + pfp.className = className("search user pfp"); var data = document.createElement("div"); - data.className = "ste-search-user-data"; + data.className = className("search user data"); var span = document.createElement("span"); - span.className = "ste-search-user-username"; + span.className = className("search user username"); span.textContent = `@${user.username}`; var p = document.createElement("p"); p.textContent = user.profile.bio; - p.className = "ste-search-user-bio"; + p.className = className("search user bio"); div.appendChild(pfp); data.appendChild(span); @@ -26,7 +26,7 @@ async function checkIfUser() { div.appendChild(data); var a = document.createElement("a"); - a.className = "ste-search-user-btn"; + a.className = className("search user btn"); a.href = `/users/${user.username}/`; var button = document.createElement("button"); button.className = "button"; @@ -35,10 +35,10 @@ async function checkIfUser() { div.appendChild(a); var outerDiv = document.createElement("div"); - outerDiv.className = "ste-search-border-top"; + outerDiv.className = className("search border top"); outerDiv.appendChild(div); - ScratchTools.waitForElements( + feature.page.waitForElements( "div.sort-controls", function (box) { if (!box.querySelector(".ste-search-user")) { @@ -50,4 +50,3 @@ async function checkIfUser() { ); } } -checkIfUser(); From ddbd3c1d88f8ec0f1078e663230d7ae631d1e383 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 3 Aug 2025 16:17:41 +0000 Subject: [PATCH 2/4] Update class-names.json --- class-names.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/class-names.json b/class-names.json index 0637a088..7c4e4ac3 100644 --- a/class-names.json +++ b/class-names.json @@ -1 +1,9 @@ -[] \ No newline at end of file +[ + "ste-search-user", + "ste-search-user-pfp", + "ste-search-user-data", + "ste-search-user-username", + "ste-search-user-bio", + "ste-search-user-btn", + "ste-search-border-top" +] \ No newline at end of file From 86ca01684da456d8d534ad58c7af673c0ba3b758 Mon Sep 17 00:00:00 2001 From: rgantzos <86856959+rgantzos@users.noreply.github.com> Date: Sun, 3 Aug 2025 09:25:05 -0700 Subject: [PATCH 3/4] Some changes --- .github/scripts/extract-classnames.js | 21 +++++++++++++++++---- .github/workflows/extract-classnames.yml | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/scripts/extract-classnames.js b/.github/scripts/extract-classnames.js index af2b709a..78234e19 100644 --- a/.github/scripts/extract-classnames.js +++ b/.github/scripts/extract-classnames.js @@ -19,7 +19,12 @@ function traverseDir(dir) { const regex = /className\(["'`](.*?)["'`]\)/g; let match; while ((match = regex.exec(content)) !== null) { - collected.add("ste-" + match[1].replaceAll(" ", "-")); + collected.add({ + className: "ste-" + match[1].replaceAll(" ", "-"), + features: [ + dir.split("/features/")[1].split("/")[0].replaceAll(".js", ""), + ], + }); } } } @@ -27,6 +32,14 @@ function traverseDir(dir) { traverseDir(rootDir); -// Write results -fs.writeFileSync(outputFile, JSON.stringify([...collected], null, 2)); -console.log(`✅ Extracted ${collected.size} class names to ${outputFile}`); +const mergedFeatures = Object.values( + [...collected].reduce((acc, item) => { + if (!acc[item.className]) { + acc[item.className] = { className: item.className, features: new Set() }; + } + item.features.forEach(f => acc[item.className].features.add(f)); + return acc; + }, {}) + ).map(obj => ({ className: obj.className, features: [...obj.features] })); + +fs.writeFileSync(outputFile, JSON.stringify(mergedFeatures, null, 2)); diff --git a/.github/workflows/extract-classnames.yml b/.github/workflows/extract-classnames.yml index e904b8f1..6514b118 100644 --- a/.github/workflows/extract-classnames.yml +++ b/.github/workflows/extract-classnames.yml @@ -8,6 +8,7 @@ on: jobs: extract: + if: github.repository == 'STForScratch/ScratchTools' runs-on: ubuntu-latest steps: From 9e7cb419fce9b94d6c313df24850a23901fe0b9e Mon Sep 17 00:00:00 2001 From: rgantzos <86856959+rgantzos@users.noreply.github.com> Date: Sun, 3 Aug 2025 09:25:45 -0700 Subject: [PATCH 4/4] Update class-names.json --- class-names.json | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/class-names.json b/class-names.json index 7c4e4ac3..0637a088 100644 --- a/class-names.json +++ b/class-names.json @@ -1,9 +1 @@ -[ - "ste-search-user", - "ste-search-user-pfp", - "ste-search-user-data", - "ste-search-user-username", - "ste-search-user-bio", - "ste-search-user-btn", - "ste-search-border-top" -] \ No newline at end of file +[] \ No newline at end of file