Skip to content

Commit d89f614

Browse files
committed
Combine with hide-project-tags
1 parent 58dc6cf commit d89f614

6 files changed

Lines changed: 81 additions & 68 deletions

File tree

features/consolidate-project-tags/consolidate.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

features/consolidate-project-tags/data.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

features/features.json

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[
22
{
33
"version": 2,
4-
"id": "consolidate-project-tags",
5-
"versionAdded": "v3.5.0"
4+
"id": "hide-project-tags",
5+
"versionAdded": "v3.9.0"
66
},
77
{
88
"version": 2,
@@ -427,16 +427,6 @@
427427
"tags": ["New", "Recommended"],
428428
"dynamic": true
429429
},
430-
{
431-
"title": "Hide Project Tags",
432-
"description": "Hides all linked tags in the Instructions/Notes and Credits of projects.",
433-
"credits": ["rgantzos"],
434-
"urls": ["https://scratch.mit.edu/users/rgantzos/"],
435-
"file": "hide-project-tags",
436-
"type": ["Website"],
437-
"tags": ["New"],
438-
"dynamic": true
439-
},
440430
{
441431
"title": "Search Assets",
442432
"description": "Search through costume and sound assets in the editor.",

features/hide-project-tags.js

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"title": "Hide Project Tags",
3+
"description": "Hides all linked tags in the Instructions/Notes and Credits of projects.",
4+
"credits": [
5+
{
6+
"username": "MaterArc",
7+
"url": "https://scratch.mit.edu/users/MaterArc/"
8+
},
9+
{
10+
"username": "rgantzos",
11+
"url": "https://scratch.mit.edu/users/rgantzos/"
12+
}
13+
],
14+
"type": [
15+
"Website"
16+
],
17+
"tags": [
18+
"New",
19+
"Featured"
20+
],
21+
"scripts": [
22+
{
23+
"file": "script.js",
24+
"runOn": "/projects/*"
25+
}
26+
],
27+
"dynamic": true,
28+
"options": [{ "id": "remove-dupes", "name": "Hide Duplicate Tags", "type": 1 }]
29+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
export default async function ({ feature, console }) {
2+
let ALL_TAGS = []
3+
4+
ScratchTools.waitForElements('.project-description a[href*="/search/projects?q="]:not(.scratchtoolsTag)', function (tag) {
5+
if (tag.textContent?.startsWith("#")) {
6+
ALL_TAGS.push({
7+
tag,
8+
content: tag.textContent.toLowerCase(),
9+
})
10+
11+
update()
12+
}
13+
})
14+
15+
function update() {
16+
if (feature.self.enabled) {
17+
let dupesOnly = feature.settings.get("remove-dupes")
18+
19+
if (dupesOnly) {
20+
for (var i in ALL_TAGS) {
21+
if (ALL_TAGS.filter((tag) => tag.content === ALL_TAGS[i].content)[0].tag === ALL_TAGS[i].tag) {
22+
if (ALL_TAGS[i].tag?.style) {
23+
ALL_TAGS[i].tag.style.display = null
24+
}
25+
} else {
26+
if (ALL_TAGS[i].tag?.style) {
27+
ALL_TAGS[i].tag.style.display = "none"
28+
}
29+
}
30+
}
31+
} else {
32+
for (var i in ALL_TAGS) {
33+
if (ALL_TAGS[i].tag?.style) {
34+
ALL_TAGS[i].tag.style.display = "none"
35+
}
36+
}
37+
}
38+
} else {
39+
for (var i in ALL_TAGS) {
40+
if (ALL_TAGS[i].tag?.style) {
41+
ALL_TAGS[i].tag.style.display = null
42+
}
43+
}
44+
}
45+
}
46+
47+
feature.settings.addEventListener("changed", update)
48+
feature.addEventListener("disabled", update)
49+
feature.addEventListener("enabled", update)
50+
}

0 commit comments

Comments
 (0)