|
| 1 | +export default async function ({ feature, console }) { |
| 2 | + const locationElement = await ScratchTools.waitForElement( |
| 3 | + "p.profile-details > span.location" |
| 4 | + ); |
| 5 | + |
| 6 | + const locationText = locationElement.textContent.trim(); |
| 7 | + const countryFlag = getCountryFlag(locationText); |
| 8 | + 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); |
| 14 | + |
| 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 | + }; |
| 229 | + |
| 230 | + return flags[locationText] || ""; |
| 231 | + } |
| 232 | +} |
0 commit comments