โ Back to parkrun Userscripts
Shows country flag emojis next to parkrunner name for all countries they have completed parkruns in
What is a userscript?
A userscript is a small piece of JavaScript that runs in your browser and enhances specific websites. These scripts work with parkrun event pages, parkrunner profile pages, and results pages, and can be used with any userscript manager including Userscripts, Tampermonkey, Violentmonkey, or any compatible browser extension.
Installation
-
Install a userscript manager for your browser:
- Desktop: Userscripts (Safari), Tampermonkey (Chrome, Firefox, Edge, Opera), or Violentmonkey (Orion)
- iOS: Userscripts (Safari) or Violentmonkey (Orion)
- Android: Install Kiwi Browser, then install Tampermonkey or Violentmonkey from the Chrome Web Store.
- Click the install link below for this script.
- Click โInstallโ when prompted by your userscript manager.
Install parkrun Countries Visited
Bookmarklet version
You can also use this script as a bookmarklet (a bookmark whose URL is JavaScript), which can be useful on browsers that support bookmarks but not userscript managers.
Desktop bookmarklet
Drag this link to your bookmarks bar:
parkrun Countries Visited bookmarklet
Mobile bookmarklet
On mobile browsers that let you edit bookmark URLs:
- Copy the JavaScript code below to your clipboard.
- Create a new bookmark for any page.
- Edit the bookmark and replace its URL with the code you copied.
- Navigate to the relevant parkrun page.
- Select the bookmark to run the script.
javascript:function _slicedToArray(e,a){return _arrayWithHoles(e)||_iterableToArrayLimit(e,a)||_unsupportedIterableToArray(e,a)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,a){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,a):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,a):void 0}function _arrayLikeToArray(e,a){(null==a||a>e.length)&&(a=e.length);for(var n=0,t=Array(a);n<a;n++)t[n]=e[n];return t}function _iterableToArrayLimit(e,a){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var t,r,l,o,i=[],u=!0,c=!1;try{if(l=(n=n.call(e)).next,0===a){if(Object(n)!==n)return;u=!1}else for(;!(u=(t=l.call(n)).done)&&(i.push(t.value),i.length!==a);u=!0);}catch(e){c=!0,r=e}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw r}}return i}}function _arrayWithHoles(e){if(Array.isArray(e))return e}(()=>{var e,a,r,n,t,l={at:{flag:"๐ฆ๐น",name:"Austria"},ru:{flag:"๐ท๐บ",name:"Russia"},au:{flag:"๐ฆ๐บ",name:"Australia"},ca:{flag:"๐จ๐ฆ",name:"Canada"},com:{flag:"๐บ๐ธ",name:"United States"},de:{flag:"๐ฉ๐ช",name:"Germany"},dk:{flag:"๐ฉ๐ฐ",name:"Denmark"},fi:{flag:"๐ซ๐ฎ",name:"Finland"},fr:{flag:"๐ซ๐ท",name:"France"},ie:{flag:"๐ฎ๐ช",name:"Ireland"},is:{flag:"๐ฎ๐ธ",name:"Iceland"},it:{flag:"๐ฎ๐น",name:"Italy"},jp:{flag:"๐ฏ๐ต",name:"Japan"},lt:{flag:"๐ฑ๐น",name:"Lithuania"},my:{flag:"๐ฒ๐พ",name:"Malaysia"},nl:{flag:"๐ณ๐ฑ",name:"Netherlands"},no:{flag:"๐ณ๐ด",name:"Norway"},nz:{flag:"๐ณ๐ฟ",name:"New Zealand"},pl:{flag:"๐ต๐ฑ",name:"Poland"},se:{flag:"๐ธ๐ช",name:"Sweden"},sg:{flag:"๐ธ๐ฌ",name:"Singapore"},uk:{flag:"๐ฌ๐ง",name:"United Kingdom"},us:{flag:"๐บ๐ธ",name:"United States "},za:{flag:"๐ฟ๐ฆ",name:"South Africa"}};function o(e){var e=e.hostname.split("."),a=e[e.length-1];return a="com"===a&&2===e[0].length?e[0]:a}"undefined"!=typeof module&&module.exports?module.exports={getCountryCodeFromUrl:o}:(t=(t=document.querySelectorAll("#results"))[t.length-1])?(t.querySelectorAll("tr").forEach(function(e){var a,n,e=e.querySelector('td a[href*="parkrun"]');e&&(a=o(new URL(e.href)),a=l[a])&&((n=document.createElement("span")).textContent=" ".concat(a.flag),n.title=a.name,n.style.cursor="help",e.appendChild(n))}),t=t,n=new Map,t.querySelectorAll("tr").forEach(function(e){var e=e.querySelector('td a[href*="parkrun"]');e&&(e=o(new URL(e.href)),n.set(e,(n.get(e)||0)+1))}),(t=t=Array.from(n.entries()).sort(function(e,a){var n=(null==(n=l[e[0]])?void 0:n.name)||e[0],e=(null==(e=l[a[0]])?void 0:e.name)||a[0];return n.localeCompare(e)}).map(function(e){var e=_slicedToArray(e,2),a=e[0],e=e[1],n=l[a];return{symbol:n?n.flag:a,name:n?n.name:a.toUpperCase(),count:e}})).length?(e=document.querySelector("h2"))?((a=document.createElement("div")).id="countries-visited",a.style.marginLeft="10px",a.style.fontSize="1.8em",a.style.marginTop="5px",a.title="".concat(t.length," Countries visited, according to parkrun's domains. Political boundaries may not be accurate."),(r=document.createElement("span")).style.lineHeight="1.5",r.style.display="inline-block",t.forEach(function(e){var a=e.symbol,n=e.name,e=e.count,t=document.createElement("span");t.textContent=a,t.title="".concat(n," (").concat(e,")"),t.style.cursor="help",r.appendChild(t),r.appendChild(document.createTextNode(" "))}),a.appendChild(r),e.appendChild(a)):console.log("No title"):console.log("No countries visited")):console.log("Results table not found")})();