YouTube emoji flags

Replaces YouTube country codes by their respective flag emojis

当前为 2022-04-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube emoji flags
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Replaces YouTube country codes by their respective flag emojis
  6. // @author snoekbaars
  7. // @match https://www.youtube.com/*
  8. // @icon https://www.google.com/s2/favicons?domain=youtube.com
  9. // @grant none
  10. // @licence MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. var countryCode = document.getElementById("country-code");
  15. function checkCode() {
  16. if(countryCode.textContent == "\n \n") {
  17. countryCode = document.getElementById("country-code");
  18. window.setTimeout(checkCode, 100); /* this checks the flag every 100 milliseconds*/
  19. } else {
  20. countryCode = document.getElementById("country-code");
  21. var pureCode = countryCode.textContent.replace("\n", "").replace(" ", "").replace("\n", "");;
  22. console.log(pureCode)
  23. countryCode.textContent = getFlags(pureCode);
  24. }
  25. }
  26. checkCode();
  27. function getFlags($code){ //From: https://stackoverflow.com/a/56009882
  28. console.log($code.length);
  29. if($code == 'AD') return '🇦🇩';
  30. if($code == 'AE') return '🇦🇪';
  31. if($code == 'AF') return '🇦🇫';
  32. if($code == 'AG') return '🇦🇬';
  33. if($code == 'AI') return '🇦🇮';
  34. if($code == 'AL') return '🇦🇱';
  35. if($code == 'AM') return '🇦🇲';
  36. if($code == 'AO') return '🇦🇴';
  37. if($code == 'AQ') return '🇦🇶';
  38. if($code == 'AR') return '🇦🇷';
  39. if($code == 'AS') return '🇦🇸';
  40. if($code == 'AT') return '🇦🇹';
  41. if($code == 'AU') return '🇦🇺';
  42. if($code == 'AW') return '🇦🇼';
  43. if($code == 'AX') return '🇦🇽';
  44. if($code == 'AZ') return '🇦🇿';
  45. if($code == 'BA') return '🇧🇦';
  46. if($code == 'BB') return '🇧🇧';
  47. if($code == 'BD') return '🇧🇩';
  48. if($code == 'BE') return '🇧🇪';
  49. if($code == 'BF') return '🇧🇫';
  50. if($code == 'BG') return '🇧🇬';
  51. if($code == 'BH') return '🇧🇭';
  52. if($code == 'BI') return '🇧🇮';
  53. if($code == 'BJ') return '🇧🇯';
  54. if($code == 'BL') return '🇧🇱';
  55. if($code == 'BM') return '🇧🇲';
  56. if($code == 'BN') return '🇧🇳';
  57. if($code == 'BO') return '🇧🇴';
  58. if($code == 'BQ') return '🇧🇶';
  59. if($code == 'BR') return '🇧🇷';
  60. if($code == 'BS') return '🇧🇸';
  61. if($code == 'BT') return '🇧🇹';
  62. if($code == 'BV') return '🇧🇻';
  63. if($code == 'BW') return '🇧🇼';
  64. if($code == 'BY') return '🇧🇾';
  65. if($code == 'BZ') return '🇧🇿';
  66. if($code == 'CA') return '🇨🇦';
  67. if($code == 'CC') return '🇨🇨';
  68. if($code == 'CD') return '🇨🇩';
  69. if($code == 'CF') return '🇨🇫';
  70. if($code == 'CG') return '🇨🇬';
  71. if($code == 'CH') return '🇨🇭';
  72. if($code == 'CI') return '🇨🇮';
  73. if($code == 'CK') return '🇨🇰';
  74. if($code == 'CL') return '🇨🇱';
  75. if($code == 'CM') return '🇨🇲';
  76. if($code == 'CN') return '🇨🇳';
  77. if($code == 'CO') return '🇨🇴';
  78. if($code == 'CR') return '🇨🇷';
  79. if($code == 'CU') return '🇨🇺';
  80. if($code == 'CV') return '🇨🇻';
  81. if($code == 'CW') return '🇨🇼';
  82. if($code == 'CX') return '🇨🇽';
  83. if($code == 'CY') return '🇨🇾';
  84. if($code == 'CZ') return '🇨🇿';
  85. if($code == 'DE') return '🇩🇪';
  86. if($code == 'DJ') return '🇩🇯';
  87. if($code == 'DK') return '🇩🇰';
  88. if($code == 'DM') return '🇩🇲';
  89. if($code == 'DO') return '🇩🇴';
  90. if($code == 'DZ') return '🇩🇿';
  91. if($code == 'EC') return '🇪🇨';
  92. if($code == 'EE') return '🇪🇪';
  93. if($code == 'EG') return '🇪🇬';
  94. if($code == 'EH') return '🇪🇭';
  95. if($code == 'ER') return '🇪🇷';
  96. if($code == 'ES') return '🇪🇸';
  97. if($code == 'ET') return '🇪🇹';
  98. if($code == 'FI') return '🇫🇮';
  99. if($code == 'FJ') return '🇫🇯';
  100. if($code == 'FK') return '🇫🇰';
  101. if($code == 'FM') return '🇫🇲';
  102. if($code == 'FO') return '🇫🇴';
  103. if($code == 'FR') return '🇫🇷';
  104. if($code == 'GA') return '🇬🇦';
  105. if($code == 'GB') return '🇬🇧';
  106. if($code == 'GD') return '🇬🇩';
  107. if($code == 'GE') return '🇬🇪';
  108. if($code == 'GF') return '🇬🇫';
  109. if($code == 'GG') return '🇬🇬';
  110. if($code == 'GH') return '🇬🇭';
  111. if($code == 'GI') return '🇬🇮';
  112. if($code == 'GL') return '🇬🇱';
  113. if($code == 'GM') return '🇬🇲';
  114. if($code == 'GN') return '🇬🇳';
  115. if($code == 'GP') return '🇬🇵';
  116. if($code == 'GQ') return '🇬🇶';
  117. if($code == 'GR') return '🇬🇷';
  118. if($code == 'GS') return '🇬🇸';
  119. if($code == 'GT') return '🇬🇹';
  120. if($code == 'GU') return '🇬🇺';
  121. if($code == 'GW') return '🇬🇼';
  122. if($code == 'GY') return '🇬🇾';
  123. if($code == 'HK') return '🇭🇰';
  124. if($code == 'HM') return '🇭🇲';
  125. if($code == 'HN') return '🇭🇳';
  126. if($code == 'HR') return '🇭🇷';
  127. if($code == 'HT') return '🇭🇹';
  128. if($code == 'HU') return '🇭🇺';
  129. if($code == 'ID') return '🇮🇩';
  130. if($code == 'IE') return '🇮🇪';
  131. if($code == 'IL') return '🇮🇱';
  132. if($code == 'IM') return '🇮🇲';
  133. if($code == 'IN') return '🇮🇳';
  134. if($code == 'IO') return '🇮🇴';
  135. if($code == 'IQ') return '🇮🇶';
  136. if($code == 'IR') return '🇮🇷';
  137. if($code == 'IS') return '🇮🇸';
  138. if($code == 'IT') return '🇮🇹';
  139. if($code == 'JE') return '🇯🇪';
  140. if($code == 'JM') return '🇯🇲';
  141. if($code == 'JO') return '🇯🇴';
  142. if($code == 'JP') return '🇯🇵';
  143. if($code == 'KE') return '🇰🇪';
  144. if($code == 'KG') return '🇰🇬';
  145. if($code == 'KH') return '🇰🇭';
  146. if($code == 'KI') return '🇰🇮';
  147. if($code == 'KM') return '🇰🇲';
  148. if($code == 'KN') return '🇰🇳';
  149. if($code == 'KP') return '🇰🇵';
  150. if($code == 'KR') return '🇰🇷';
  151. if($code == 'KW') return '🇰🇼';
  152. if($code == 'KY') return '🇰🇾';
  153. if($code == 'KZ') return '🇰🇿';
  154. if($code == 'LA') return '🇱🇦';
  155. if($code == 'LB') return '🇱🇧';
  156. if($code == 'LC') return '🇱🇨';
  157. if($code == 'LI') return '🇱🇮';
  158. if($code == 'LK') return '🇱🇰';
  159. if($code == 'LR') return '🇱🇷';
  160. if($code == 'LS') return '🇱🇸';
  161. if($code == 'LT') return '🇱🇹';
  162. if($code == 'LU') return '🇱🇺';
  163. if($code == 'LV') return '🇱🇻';
  164. if($code == 'LY') return '🇱🇾';
  165. if($code == 'MA') return '🇲🇦';
  166. if($code == 'MC') return '🇲🇨';
  167. if($code == 'MD') return '🇲🇩';
  168. if($code == 'ME') return '🇲🇪';
  169. if($code == 'MF') return '🇲🇫';
  170. if($code == 'MG') return '🇲🇬';
  171. if($code == 'MH') return '🇲🇭';
  172. if($code == 'MK') return '🇲🇰';
  173. if($code == 'ML') return '🇲🇱';
  174. if($code == 'MM') return '🇲🇲';
  175. if($code == 'MN') return '🇲🇳';
  176. if($code == 'MO') return '🇲🇴';
  177. if($code == 'MP') return '🇲🇵';
  178. if($code == 'MQ') return '🇲🇶';
  179. if($code == 'MR') return '🇲🇷';
  180. if($code == 'MS') return '🇲🇸';
  181. if($code == 'MT') return '🇲🇹';
  182. if($code == 'MU') return '🇲🇺';
  183. if($code == 'MV') return '🇲🇻';
  184. if($code == 'MW') return '🇲🇼';
  185. if($code == 'MX') return '🇲🇽';
  186. if($code == 'MY') return '🇲🇾';
  187. if($code == 'MZ') return '🇲🇿';
  188. if($code == 'NA') return '🇳🇦';
  189. if($code == 'NC') return '🇳🇨';
  190. if($code == 'NE') return '🇳🇪';
  191. if($code == 'NF') return '🇳🇫';
  192. if($code == 'NG') return '🇳🇬';
  193. if($code == 'NI') return '🇳🇮';
  194. if($code == 'NL') return '🇳🇱';
  195. if($code == 'NO') return '🇳🇴';
  196. if($code == 'NP') return '🇳🇵';
  197. if($code == 'NR') return '🇳🇷';
  198. if($code == 'NU') return '🇳🇺';
  199. if($code == 'NZ') return '🇳🇿';
  200. if($code == 'OM') return '🇴🇲';
  201. if($code == 'PA') return '🇵🇦';
  202. if($code == 'PE') return '🇵🇪';
  203. if($code == 'PF') return '🇵🇫';
  204. if($code == 'PG') return '🇵🇬';
  205. if($code == 'PH') return '🇵🇭';
  206. if($code == 'PK') return '🇵🇰';
  207. if($code == 'PL') return '🇵🇱';
  208. if($code == 'PM') return '🇵🇲';
  209. if($code == 'PN') return '🇵🇳';
  210. if($code == 'PR') return '🇵🇷';
  211. if($code == 'PS') return '🇵🇸';
  212. if($code == 'PT') return '🇵🇹';
  213. if($code == 'PW') return '🇵🇼';
  214. if($code == 'PY') return '🇵🇾';
  215. if($code == 'QA') return '🇶🇦';
  216. if($code == 'RE') return '🇷🇪';
  217. if($code == 'RO') return '🇷🇴';
  218. if($code == 'RS') return '🇷🇸';
  219. if($code == 'RU') return '🇷🇺';
  220. if($code == 'RW') return '🇷🇼';
  221. if($code == 'SA') return '🇸🇦';
  222. if($code == 'SB') return '🇸🇧';
  223. if($code == 'SC') return '🇸🇨';
  224. if($code == 'SD') return '🇸🇩';
  225. if($code == 'SE') return '🇸🇪';
  226. if($code == 'SG') return '🇸🇬';
  227. if($code == 'SH') return '🇸🇭';
  228. if($code == 'SI') return '🇸🇮';
  229. if($code == 'SJ') return '🇸🇯';
  230. if($code == 'SK') return '🇸🇰';
  231. if($code == 'SL') return '🇸🇱';
  232. if($code == 'SM') return '🇸🇲';
  233. if($code == 'SN') return '🇸🇳';
  234. if($code == 'SO') return '🇸🇴';
  235. if($code == 'SR') return '🇸🇷';
  236. if($code == 'SS') return '🇸🇸';
  237. if($code == 'ST') return '🇸🇹';
  238. if($code == 'SV') return '🇸🇻';
  239. if($code == 'SX') return '🇸🇽';
  240. if($code == 'SY') return '🇸🇾';
  241. if($code == 'SZ') return '🇸🇿';
  242. if($code == 'TC') return '🇹🇨';
  243. if($code == 'TD') return '🇹🇩';
  244. if($code == 'TF') return '🇹🇫';
  245. if($code == 'TG') return '🇹🇬';
  246. if($code == 'TH') return '🇹🇭';
  247. if($code == 'TJ') return '🇹🇯';
  248. if($code == 'TK') return '🇹🇰';
  249. if($code == 'TL') return '🇹🇱';
  250. if($code == 'TM') return '🇹🇲';
  251. if($code == 'TN') return '🇹🇳';
  252. if($code == 'TO') return '🇹🇴';
  253. if($code == 'TR') return '🇹🇷';
  254. if($code == 'TT') return '🇹🇹';
  255. if($code == 'TV') return '🇹🇻';
  256. if($code == 'TW') return '🇹🇼';
  257. if($code == 'TZ') return '🇹🇿';
  258. if($code == 'UA') return '🇺🇦';
  259. if($code == 'UG') return '🇺🇬';
  260. if($code == 'UM') return '🇺🇲';
  261. if($code == 'US') return '🇺🇸';
  262. if($code == 'UY') return '🇺🇾';
  263. if($code == 'UZ') return '🇺🇿';
  264. if($code == 'VA') return '🇻🇦';
  265. if($code == 'VC') return '🇻🇨';
  266. if($code == 'VE') return '🇻🇪';
  267. if($code == 'VG') return '🇻🇬';
  268. if($code == 'VI') return '🇻🇮';
  269. if($code == 'VN') return '🇻🇳';
  270. if($code == 'VU') return '🇻🇺';
  271. if($code == 'WF') return '🇼🇫';
  272. if($code == 'WS') return '🇼🇸';
  273. if($code == 'XK') return '🇽🇰';
  274. if($code == 'YE') return '🇾🇪';
  275. if($code == 'YT') return '🇾🇹';
  276. if($code == 'ZA') return '🇿🇦';
  277. if($code == 'ZM') return '🇿🇲';
  278. return '🏳';
  279. }
  280. })();