Skip to content

Commit aa00383

Browse files
authored
Consolidate Project Tags
Removes duplicate project tags from the instruction and credit box.
1 parent 2e4ca96 commit aa00383

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const updateProjectDescription = () => {
2+
const projectDescriptions = document.querySelectorAll('.project-description');
3+
let found = false;
4+
5+
projectDescriptions.forEach((projectDescription) => {
6+
const descriptionText = projectDescription.innerHTML;
7+
8+
if (descriptionText.trim() !== '') {
9+
const tagRegex = /<a\s+href="[^"]*"[^>]*>[^<]*<\/a>/g;
10+
const tags = descriptionText.match(tagRegex);
11+
12+
if (tags) {
13+
const uniqueTags = new Set();
14+
const updatedDescription = descriptionText.replace(tagRegex, (match) => {
15+
if (!uniqueTags.has(match)) {
16+
uniqueTags.add(match);
17+
return match;
18+
} else {
19+
return '';
20+
}
21+
});
22+
projectDescription.innerHTML = updatedDescription;
23+
}
24+
25+
found = true;
26+
}
27+
});
28+
};
29+
window.addEventListener('load', updateProjectDescription);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"title": "Consolidate Project Tags",
3+
"description": "Removes duplicate project tags from the instruction and credit box.",
4+
"credits": [
5+
{ "username": "palindromos", "url": "https://scratch.mit.edu/users/palindromos/" },
6+
{ "username": "MaterArc", "url": "https://scratch.mit.edu/users/MaterArc/" }
7+
],
8+
"type": ["Website"],
9+
"tags": ["New", "Featured"],
10+
"dynamic": true,
11+
"styles": [{ "file": "consolidate.js", "runOn": "/projects/*"}]
12+
}

0 commit comments

Comments
 (0)