File tree Expand file tree Collapse file tree
features/consolidate-project-tags Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 + h r e f = " [ ^ " ] * " [ ^ > ] * > [ ^ < ] * < \/ 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 ) ;
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments