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

  1. Install a userscript manager for your browser:
  2. Click the install link below for this script.
  3. Click โ€œInstallโ€ when prompted by your userscript manager.

parkrun Countries Visited Screenshot

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:

  1. Copy the JavaScript code below to your clipboard.
  2. Create a new bookmark for any page.
  3. Edit the bookmark and replace its URL with the code you copied.
  4. Navigate to the relevant parkrun page.
  5. 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")})();
Last updated
Version
1.1.8
Author
Pete Johns (@johnsyweb)
Homepage
https://www.johnsy.com/tampermonkey-parkrun//
Support
Issues / support
License
MIT