Skip to content

Commit c4a1885

Browse files
authored
Fix featured projects
1 parent a49ecbd commit c4a1885

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

features/better-featured-projects/script.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ export default async function ({ feature, console }) {
1414

1515
if (box) {
1616
// Add class to select using waitForElements API
17-
box.classList.add("featured-projects")
17+
box.classList.add("featured-projects");
1818

1919
// Change box title and link to studio
20-
box.querySelector("h4").textContent = "ScratchTools Featured Projects"
21-
box.querySelector("a").href = "/studios/32047713/comments"
22-
box.querySelector("a").textContent = "Submit a project"
20+
box.querySelector("h4").textContent = "ScratchTools Featured Projects";
21+
box.querySelector("a").href = "/studios/32047713/comments";
22+
box.querySelector("a").textContent = "Submit a project";
2323

2424
ScratchTools.waitForElements(".featured-projects .thumbnail-info", function(info) {
25-
let project = info.closest(".project")
26-
let indexOfProject = project[Object.keys(project).find((key) => key.startsWith("__reactInternalInstance"))].return.index
27-
25+
let project = info.closest(".project");
26+
let indexOfProject = [...document.querySelectorAll(".featured-projects .thumbnail-info")].indexOf(info);
27+
2828
if (data[indexOfProject]) {
29-
let thumbnail = project.querySelector("a.thumbnail-image")
30-
thumbnail.href = `/projects/${data[indexOfProject].id}/`
31-
thumbnail.firstChild.src = data[indexOfProject].thumbnail
29+
let thumbnail = project.querySelector("a.thumbnail-image");
30+
thumbnail.href = `/projects/${data[indexOfProject].id}/`;
31+
thumbnail.firstChild.src = data[indexOfProject].thumbnail;
3232

33-
info.querySelector(".thumbnail-creator a").href = `/users/${data[indexOfProject].author}/`
34-
info.querySelector(".thumbnail-creator a").textContent = data[indexOfProject].author
33+
info.querySelector(".thumbnail-creator a").href = `/users/${data[indexOfProject].author}/`;
34+
info.querySelector(".thumbnail-creator a").textContent = data[indexOfProject].author;
3535

36-
info.querySelector("a").href = `/projects/${data[indexOfProject].id}/`
37-
info.querySelector("a").title = data[indexOfProject].title
38-
info.querySelector("a").textContent = data[indexOfProject].title
36+
info.querySelector("a").href = `/projects/${data[indexOfProject].id}/`;
37+
info.querySelector("a").title = data[indexOfProject].title;
38+
info.querySelector("a").textContent = data[indexOfProject].title;
3939
}
40-
})
40+
});
4141
}
4242

4343
async function getFeatured() {
@@ -60,6 +60,6 @@ export default async function ({ feature, console }) {
6060
} catch (err) {}
6161
}
6262

63-
return FEATURED
63+
return FEATURED;
6464
}
6565
}

0 commit comments

Comments
 (0)