Skip to content

Commit 92874da

Browse files
authored
Merge pull request #760 from STForScratch/MaterArc-patch-17
Flag on Profile
2 parents 8a83221 + f89d65b commit 92874da

File tree

4 files changed

+484
-0
lines changed

4 files changed

+484
-0
lines changed

features/features.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
[
2+
{
3+
"version": 2,
4+
"id": "profile-flag",
5+
"versionAdded": "v3.5.0"
6+
},
27
{
38
"version": 2,
49
"id": "follow-on-projects",

features/flag-on-profile/flag.js

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
(function() {
2+
'use strict';
3+
4+
const locationElement = document.querySelector('.location');
5+
6+
if (locationElement) {
7+
const locationText = locationElement.textContent.trim();
8+
const countryFlag = getCountryFlag(locationText);
9+
if (!countryFlag) return;
10+
const flagElement = document.createElement('span');
11+
flagElement.textContent = countryFlag;
12+
flagElement.style.marginRight = '4px';
13+
locationElement.insertBefore(flagElement, locationElement.firstChild);
14+
}
15+
function getCountryFlag(locationText) {
16+
const flags = {
17+
'Afghanistan': '🇦🇫',
18+
'Albania': '🇦🇱',
19+
'Aland Islands':'🇦🇽',
20+
'Algeria': '🇩🇿',
21+
'American Samoa': '🇦🇸',
22+
'Andorra': '🇦🇩',
23+
'Angola': '🇦🇴',
24+
'Anguilla': '🇦🇮',
25+
'Antigua and Barbuda': '🇦🇬',
26+
'Argentina': '🇦🇷',
27+
'Armenia': '🇦🇲',
28+
'Aruba': '🇦🇼',
29+
'Azerbaijan': '🇦🇿'
30+
'Australia': '🇦🇺',
31+
'Austria': '🇦🇹',
32+
'Azerbaijan': '🇦🇿',
33+
'Bahamas, The': '🇧🇸',
34+
'Bahrain': '🇧🇭',
35+
'Bangladesh': '🇧🇩',
36+
'Barbados': '🇧🇧',
37+
'Belarus': '🇧🇾',
38+
'Belgium': '🇧🇪',
39+
'Belize': '🇧🇿',
40+
'Benin': '🇧🇯',
41+
'Bhutan': '🇧🇹',
42+
'Bolivia': '🇧🇴',
43+
'Bosnia and Herzegovina': '🇧🇦',
44+
'Botswana': '🇧🇼',
45+
'Brazil': '🇧🇷',
46+
'Brunei': '🇧🇳',
47+
'Bulgaria': '🇧🇬',
48+
'Burkina Faso': '🇧🇫',
49+
'Burma': '🇲🇲',
50+
'Burundi': '🇧🇮',
51+
'Cabo Verde': '🇨🇻',
52+
'Cambodia': '🇰🇭',
53+
'Cameroon': '🇨🇲',
54+
'Canada': '🇨🇦',
55+
'Central African Republic': '🇨🇫',
56+
'Chad': '🇹🇩',
57+
'Chile': '🇨🇱',
58+
'China': '🇨🇳',
59+
'Colombia': '🇨🇴',
60+
'Comoros': '🇰🇲',
61+
'Congo Free State, The': '🇨🇬',
62+
'Costa Rica': '🇨🇷',
63+
'Cote d’Ivoire (Ivory Coast)': '🇨🇮',
64+
'Croatia': '🇭🇷',
65+
'Cuba': '🇨🇺',
66+
'Cyprus': '🇨🇾',
67+
'Czechia': '🇨🇿',
68+
'Czechoslovakia': '🇨🇿',
69+
'Democratic Republic of the Congo': '🇨🇩',
70+
'Denmark': '🇩🇰',
71+
'Djibouti': '🇩🇯',
72+
'Dominica': '🇩🇲',
73+
'Dominican Republic': '🇩🇴',
74+
'East Germany (German Democratic Republic)': '🇩🇪',
75+
'Ecuador': '🇪🇨',
76+
'Egypt': '🇪🇬',
77+
'El Salvador': '🇸🇻',
78+
'Equatorial Guinea': '🇬🇶',
79+
'Eritrea': '🇪🇷',
80+
'Estonia': '🇪🇪',
81+
'Eswatini': '🇸🇿',
82+
'Ethiopia': '🇪🇹',
83+
'Fiji': '🇫🇯',
84+
'Finland': '🇫🇮',
85+
'France': '🇫🇷',
86+
'Gabon': '🇬🇦',
87+
'Gambia, The': '🇬🇲',
88+
'Georgia': '🇬🇪',
89+
'Germany': '🇩🇪',
90+
'Ghana': '🇬🇭',
91+
'Greece': '🇬🇷',
92+
'Grenada': '🇬🇩',
93+
'Guatemala': '🇬🇹',
94+
'Guinea': '🇬🇳',
95+
'Guinea-Bissau': '🇬🇼',
96+
'Guyana': '🇬🇾',
97+
'Haiti': '🇭🇹',
98+
'Hanover': '🇩🇪',
99+
'Hanseatic Republics': '🇩🇪',
100+
'Hawaii': '🇺🇸',
101+
'Hesse': '🇩🇪',
102+
'Holy See': '🇻🇦',
103+
'Honduras': '🇭🇳',
104+
'Hungary': '🇭🇺',
105+
'Iceland': '🇮🇸',
106+
'India': '🇮🇳',
107+
'Indonesia': '🇮🇩',
108+
'Iran': '🇮🇷',
109+
'Iraq': '🇮🇶',
110+
'Ireland': '🇮🇪',
111+
'Israel': '🇮🇱',
112+
'Italy': '🇮🇹',
113+
'Jamaica': '🇯🇲',
114+
'Japan': '🇯🇵',
115+
'Jordan': '🇯🇴',
116+
'Kazakhstan': '🇰🇿',
117+
'Kenya': '🇰🇪',
118+
'Serbia': '🇷🇸',
119+
'Kiribati': '🇰🇮',
120+
'Korea': '🇰🇵',
121+
'Kosovo': '🇽🇰',
122+
'Kuwait': '🇰🇼',
123+
'Kyrgyzstan': '🇰🇬',
124+
'Laos': '🇱🇦',
125+
'Latvia': '🇱🇻',
126+
'Lebanon': '🇱🇧',
127+
'Lesotho': '🇱🇸',
128+
'Liberia': '🇱🇷',
129+
'Libya': '🇱🇾',
130+
'Liechtenstein': '🇱🇮',
131+
'Lithuania': '🇱🇹',
132+
'Luxembourg': '🇱🇺',
133+
'Madagascar': '🇲🇬',
134+
'Malawi': '🇲🇼',
135+
'Malaysia': '🇲🇾',
136+
'Maldives': '🇲🇻',
137+
'Mali': '🇲🇱',
138+
'Malta': '🇲🇹',
139+
'Marshall Islands': '🇲🇭',
140+
'Mauritania': '🇲🇷',
141+
'Mauritius': '🇲🇺',
142+
'Mexico': '🇲🇽',
143+
'Micronesia': '🇫🇲',
144+
'Moldova': '🇲🇩',
145+
'Monaco': '🇲🇨',
146+
'Mongolia': '🇲🇳',
147+
'Montenegro': '🇲🇪',
148+
'Morocco': '🇲🇦',
149+
'Mozambique': '🇲🇿',
150+
'Namibia': '🇳🇦',
151+
'Nauru': '🇳🇷',
152+
'Nepal': '🇳🇵',
153+
'Netherlands': '🇳🇱',
154+
'New Zealand': '🇳🇿',
155+
'Nicaragua': '🇳🇮',
156+
'Niger': '🇳🇪',
157+
'Nigeria': '🇳🇬',
158+
'North Macedonia': '🇲🇰',
159+
'Northern Mariana Islands': '🇲🇵',
160+
'Norway': '🇳🇴',
161+
'Oman': '🇴🇲',
162+
'Pakistan': '🇵🇰',
163+
'Palau': '🇵🇼',
164+
'Palestine, State of': '🇵🇸',
165+
'Panama': '🇵🇦',
166+
'Papua New Guinea': '🇵🇬',
167+
'Paraguay': '🇵🇾',
168+
'Peru': '🇵🇪',
169+
'Philippines': '🇵🇭',
170+
'Poland': '🇵🇱',
171+
'Portugal': '🇵🇹',
172+
'Qatar': '🇶🇦',
173+
'Romania': '🇷🇴',
174+
'Russia': '🇷🇺',
175+
'Rwanda': '🇷🇼',
176+
'Saint Kitts and Nevis': '🇰🇳',
177+
'Saint Lucia': '🇱🇨',
178+
'Saint Vincent and the Grenadines': '🇻🇨',
179+
'Samoa': '🇼🇸',
180+
'San Marino': '🇸🇲',
181+
'Sao Tome and Principe': '🇸🇹',
182+
'Saudi Arabia': '🇸🇦',
183+
'Senegal': '🇸🇳',
184+
'Serbia': '🇷🇸',
185+
'Seychelles': '🇸🇨',
186+
'Sierra Leone': '🇸🇱',
187+
'Singapore': '🇸🇬',
188+
'Slovakia': '🇸🇰',
189+
'Slovenia': '🇸🇮',
190+
'Solomon Islands': '🇸🇧',
191+
'Somalia': '🇸🇴',
192+
'South Africa': '🇿🇦',
193+
'South Sudan': '🇸🇸',
194+
'Spain': '🇪🇸',
195+
'Sri Lanka': '🇱🇰',
196+
'Sudan': '🇸🇩',
197+
'Suriname': '🇸🇷',
198+
'Sweden': '🇸🇪',
199+
'Switzerland': '🇨🇭',
200+
'Syria': '🇸🇾',
201+
'Taiwan': '🇹🇼',
202+
'Tajikistan': '🇹🇯',
203+
'Tanzania': '🇹🇿',
204+
'Thailand': '🇹🇭',
205+
'Timor-Leste': '🇹🇱',
206+
'Togo': '🇹🇬',
207+
'Tonga': '🇹🇴',
208+
'Trinidad and Tobago': '🇹🇹',
209+
'Tunisia': '🇹🇳',
210+
'Turkey': '🇹🇷',
211+
'Turkmenistan': '🇹🇲',
212+
'Tuvalu': '🇹🇻',
213+
'Uganda': '🇺🇬',
214+
'Ukraine': '🇺🇦',
215+
'United Arab Emirates': '🇦🇪',
216+
'United Kingdom': '🇬🇧',
217+
'United States': '🇺🇸',
218+
'Uruguay': '🇺🇾',
219+
'Uzbekistan': '🇺🇿',
220+
'Vanuatu': '🇻🇺',
221+
'Venezuela': '🇻🇪',
222+
'Vietnam': '🇻🇳',
223+
'Yemen': '🇾🇪',
224+
'Zambia': '🇿🇲',
225+
'Zimbabwe': '🇿🇼',
226+
'Antarctica': '🇦🇶',
227+
'French Southern Territories': '🇹🇫',
228+
'Bonaire, Sint Eustatius and Saba':' 🇧🇶',
229+
'Christmas Island': '🇨🇽',
230+
'Heard Island and McDonald Islands': '🇭🇲',
231+
'Location not given': '❓',
232+
};
233+
234+
return flags[locationText] || '';
235+
}
236+
})();

features/profile-flag/data.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"title": "Flag on Profile",
3+
"description": "Adds flag emojis near selected locations on profile pages.",
4+
"credits": [
5+
{ "username": "MaterArc", "url": "https://scratch.mit.edu/users/MaterArc/" }
6+
],
7+
"type": ["Website"],
8+
"tags": ["New"],
9+
"dynamic": true,
10+
"scripts": [{ "file": "script.js", "runOn": "/users/*", "module": true }]
11+
}

0 commit comments

Comments
 (0)