Skip to content

Commit 030b195

Browse files
committed
Update profile flags
1 parent c70a596 commit 030b195

File tree

4 files changed

+34
-225
lines changed

4 files changed

+34
-225
lines changed

features/features.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@
107107
{
108108
"version": 2,
109109
"id": "profile-flag",
110-
"versionAdded": "v3.5.0"
110+
"versionAdded": "v3.5.0",
111+
"versionUpdated": "v3.10.0"
111112
},
112113
{
113114
"version": 2,

features/profile-flag/data.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"type": ["Website"],
88
"tags": ["New"],
99
"dynamic": true,
10-
"scripts": [{ "file": "script.js", "runOn": "/users/*", "module": true }]
11-
}
10+
"styles": [{ "file": "style.css", "runOn": "/users/*" }],
11+
"scripts": [{ "file": "script.js", "runOn": "/users/*" }]
12+
}

features/profile-flag/script.js

Lines changed: 21 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -1,232 +1,31 @@
1-
export default async function ({ feature, console }) {
1+
export default async function ({ feature }) {
22
const locationElement = await ScratchTools.waitForElement(
33
"p.profile-details > span.location"
44
);
55

66
const locationText = locationElement.textContent.trim();
77
const countryFlag = getCountryFlag(locationText);
88
if (!countryFlag) return;
9-
const flagElement = document.createElement("span");
10-
flagElement.textContent = countryFlag;
11-
flagElement.style.marginRight = "4px";
12-
feature.self.hideOnDisable(flagElement);
13-
locationElement.insertBefore(flagElement, locationElement.firstChild);
149

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

230-
return flags[locationText] || "";
19+
feature.self.hideOnDisable(locationHolder);
20+
21+
function getCountryFlag(locationText) {
22+
const GithubUrl = "https://raw.githubusercontent.com/STForScratch/data/main/flags/";
23+
const countryName = locationText.toLowerCase()
24+
.replaceAll(" ", "-")
25+
.replaceAll("(", "")
26+
.replaceAll(")", "")
27+
.replaceAll(",", "")
28+
.replaceAll(".", "") + ".svg";
29+
return GithubUrl + countryName;
23130
}
232-
}
31+
}

features/profile-flag/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.location img {
2+
width: 15px;
3+
height: auto;
4+
margin-top: -1rem;
5+
position: relative;
6+
bottom: -.25rem;
7+
margin-left: .4rem;
8+
}

0 commit comments

Comments
 (0)