About

Visualizes your progress on the compass challenge (North, South, East, West parkruns)

Version 1.1.19 Updated

Screenshot

parkrun Compass Challenge Screenshot

Install

Recommended: userscript. Bookmarklet works where a userscript manager isn’t available.

Userscript (recommended)

Install parkrun Compass Challenge

First time? Userscript basics and installation steps

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 steps

  1. Install a userscript manager for your browser:
  2. Click the Install button above for this script.
  3. Click “Install” when prompted by your userscript manager.

Bookmarklet

A bookmarklet is a bookmark whose URL is JavaScript. Use it on browsers that support bookmarks but not userscript managers.

Drag this link to your bookmarks bar:

parkrun Compass Challenge bookmarklet

Mobile bookmarklet setup and full code

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(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_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(t,e){var n;if(t)return"string"==typeof t?_arrayLikeToArray(t,e):"Map"===(n="Object"===(n={}.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}function _iterableToArrayLimit(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var o,a,r,i,c=[],s=!0,l=!1;try{if(r=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(o=r.call(n)).done)&&(c.push(o.value),c.length!==e);s=!0);}catch(t){l=!0,a=t}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(l)throw a}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}(()=>{var t,e,h={backgroundColor:"#2b223d",accentColor:"#FFA300",completedColor:"#53BA9D",pendingColor:"#666",textColor:"#e0e0e0",subtleTextColor:"#cccccc"},y={north:/north/i,south:/south/i,east:/east/i,west:/west/i};function s(){return window.innerWidth<768?{isMobile:!0,spacing:{small:"10px",medium:"15px",statsMarginBottom:"8px",completionMarginTop:"8px"},container:{padding:"10px",marginTop:"10px"},typography:{heading:"1.1em",stats:"1em",statsSubtext:"0.9em",completion:"0.95em"},compass:{baseSize:320},button:{padding:"6px 12px",fontSize:"0.9em",marginTop:"10px"}}:{isMobile:!1,spacing:{small:"20px",medium:"20px",statsMarginBottom:"10px",completionMarginTop:"10px"},container:{padding:"20px",marginTop:"20px"},typography:{heading:"1.3em",stats:"1.2em",statsSubtext:"1em",completion:"1.1em"},compass:{baseSize:700},button:{padding:"8px 15px",fontSize:"1em",marginTop:"15px"}}}function n(t){var e=s(),n=(n="Compass Challenge",o=s(),(r=document.createElement("div")).className="parkrun-compass-container",r.style.width="100%",r.style.maxWidth="800px",r.style.margin="".concat(o.container.marginTop," auto"),r.style.padding=o.container.padding,r.style.backgroundColor=h.backgroundColor,r.style.borderRadius="8px",r.style.boxShadow="0 2px 4px rgba(0,0,0,0.1)",r.style.textAlign="center",(a=document.createElement("h3")).textContent=n,a.style.marginBottom=o.spacing.small,a.style.color=h.accentColor,a.style.fontSize=o.typography.heading,r.appendChild(a),r),o=document.createElement("div"),a=(o.style.marginBottom=e.spacing.small,o.style.color=h.textColor,'<div style="font-size: '.concat(e.typography.stats,"; margin-bottom: ").concat(e.spacing.statsMarginBottom,';"><strong>').concat(t.completedCount," of 4</strong> compass directions completed</div>")),r=(a+='<div style="font-size: '.concat(e.typography.statsSubtext,';">After ').concat(t.totalEvents," parkruns</div>"),t.dateOfCompletion&&(a+='<div style="margin-top: '.concat(e.spacing.completionMarginTop,"; font-size: ").concat(e.typography.completion,';">🧭 Challenge completed on ').concat(t.dateOfCompletion,"</div>")),o.innerHTML=a,n.appendChild(o),e.isMobile?Math.min(e.compass.baseSize,window.innerWidth-40):e.compass.baseSize),a=document.createElement("div"),p=(a.style.position="relative",a.style.width="".concat(r,"px"),a.style.height="".concat(r,"px"),a.style.margin="0 auto",a.style.boxSizing="content-box",document.createElementNS("http://www.w3.org/2000/svg","svg")),m=(p.setAttribute("width","100%"),p.setAttribute("height","100%"),p.setAttribute("viewBox","0 0 ".concat(700," ").concat(700)),p.style.position="absolute",p.style.top="0",p.style.left="0",350),b=350,o=document.createElementNS("http://www.w3.org/2000/svg","circle");o.setAttribute("cx",m),o.setAttribute("cy",b),o.setAttribute("r",230),o.setAttribute("fill","#334"),o.setAttribute("stroke",h.accentColor),o.setAttribute("stroke-width","5"),p.appendChild(o);[{name:"north",angle:270,label:"N",data:t.directions.north},{name:"east",angle:0,label:"E",data:t.directions.east},{name:"south",angle:90,label:"S",data:t.directions.south},{name:"west",angle:180,label:"W",data:t.directions.west}].forEach(function(t){var e=t.angle*(Math.PI/180),n=m+230*Math.cos(e),o=b+230*Math.sin(e),a=230*.12,r=m+115*Math.cos(e),i=b+115*Math.sin(e),c=e+Math.PI/2,s=r+a*Math.cos(c),l=i+a*Math.sin(c),r=r-a*Math.cos(c),i=i-a*Math.sin(c),a=document.createElementNS("http://www.w3.org/2000/svg","path"),c="M ".concat(m," ").concat(b," L ").concat(s," ").concat(l," L ").concat(n," ").concat(o," L ").concat(r," ").concat(i," Z"),s=(a.setAttribute("d",c),a.setAttribute("fill",t.data?h.completedColor:h.pendingColor),a.setAttribute("stroke","#000"),a.setAttribute("stroke-width","1"),a.setAttribute("stroke-opacity","0.3"),p.appendChild(a),m+115*Math.cos(e)),l=b+115*Math.sin(e),n=document.createElementNS("http://www.w3.org/2000/svg","text");if(n.setAttribute("x",s),n.setAttribute("y",l),n.setAttribute("text-anchor","middle"),n.setAttribute("dominant-baseline","middle"),n.setAttribute("fill","#fff"),n.setAttribute("font-size","28px"),n.setAttribute("font-weight","bold"),n.setAttribute("stroke","#000"),n.setAttribute("stroke-width","1"),n.setAttribute("paint-order","stroke"),n.textContent=t.label,p.appendChild(n),t.data){var o=t.data.eventName.match(/(.+?)(?:\s+parkrun)?$/i),r=o?o[1]:t.data.eventName,i="".concat(r," - ").concat(t.data.date),c="text-path-".concat(t.name),a=document.createElementNS("http://www.w3.org/2000/svg","path"),d="",u=245;switch(t.name){case"north":d="M ".concat(180," ").concat(105," A ").concat(u," ").concat(u," 0 0 1 ").concat(520," ").concat(105);break;case"east":d="M ".concat(595," ").concat(180," A ").concat(u," ").concat(u," 0 0 1 ").concat(595," ").concat(520);break;case"south":d="M ".concat(180," ").concat(595," A ").concat(u," ").concat(u," 0 0 0 ").concat(520," ").concat(595);break;case"west":d="M ".concat(105," ").concat(520," A ").concat(u," ").concat(u," 0 0 1 ").concat(105," ").concat(180);break;default:console.warn("Unknown direction: ".concat(t.name))}a.setAttribute("id",c),a.setAttribute("d",d),a.setAttribute("fill","none"),p.appendChild(a);e=document.createElementNS("http://www.w3.org/2000/svg","text"),s=(e.setAttribute("fill","#FFFFFF"),e.setAttribute("font-size","14px"),e.setAttribute("font-weight","bold"),document.createElementNS("http://www.w3.org/2000/svg","textPath"));s.setAttribute("href","#".concat(c)),s.setAttribute("startOffset","50%"),s.setAttribute("text-anchor","middle"),"south"===t.name&&s.setAttribute("side","left"),s.textContent=i,e.appendChild(s),p.appendChild(e)}});var i,c,e=document.createElementNS("http://www.w3.org/2000/svg","defs"),r=document.createElementNS("http://www.w3.org/2000/svg","filter"),o=(r.setAttribute("id","text-shadow"),r.setAttribute("x","-20%"),r.setAttribute("y","-20%"),r.setAttribute("width","140%"),r.setAttribute("height","140%"),document.createElementNS("http://www.w3.org/2000/svg","feDropShadow")),o=(o.setAttribute("dx","0"),o.setAttribute("dy","0"),o.setAttribute("stdDeviation","2"),o.setAttribute("flood-color","#000000"),o.setAttribute("flood-opacity","0.7"),r.appendChild(o),e.appendChild(r),p.appendChild(e),document.createElementNS("http://www.w3.org/2000/svg","circle")),r=(o.setAttribute("cx",m),o.setAttribute("cy",b),o.setAttribute("r",30),o.setAttribute("fill",h.accentColor),p.appendChild(o),document.createElementNS("http://www.w3.org/2000/svg","text"));return r.setAttribute("x",m),r.setAttribute("y",b),r.setAttribute("text-anchor","middle"),r.setAttribute("dominant-baseline","middle"),r.setAttribute("fill",h.backgroundColor),r.setAttribute("font-size","24px"),r.setAttribute("font-weight","bold"),r.textContent="".concat(Math.round(t.completedCount/4*100),"%"),p.appendChild(r),a.appendChild(p),n.appendChild(a),i=n,e=s(),(o=document.createElement("div")).style.marginTop=e.button.marginTop,o.id="compass-download-btn-container",(c=document.createElement("button")).textContent="💾 Save as Image",c.style.padding=e.button.padding,c.style.backgroundColor=h.accentColor,c.style.color=h.backgroundColor,c.style.border="none",c.style.borderRadius="4px",c.style.cursor="pointer",c.style.fontWeight="bold",c.style.fontSize=e.button.fontSize,c.addEventListener("mouseover",function(){this.style.backgroundColor="#e59200"}),c.addEventListener("mouseout",function(){this.style.backgroundColor=h.accentColor}),c.addEventListener("click",function(){c.style.display="none",html2canvas(i,{backgroundColor:h.backgroundColor,scale:2,logging:!1,allowTaint:!0,useCORS:!0}).then(function(t){c.style.display="block";var e=document.createElement("a"),n=(new Date).toISOString().split("T")[0],o=window.location.pathname.split("/")[2]||"parkrunner";e.download="compass-challenge-".concat(o,"-").concat(n,".png"),e.href=t.toDataURL("image/png"),e.click()})}),o.appendChild(c),i.appendChild(o),n}document.querySelector("#results")?(t=t=n((t=>{for(var e={north:null,south:null,east:null,west:null},n=0,o=null,a=0,t=t.querySelectorAll("tr"),r=[],i=(t.forEach(function(t){var e,n,o,t=t.querySelectorAll("td");t.length<5||(e=t[0].textContent.trim(),n=t[1].textContent.trim(),o=t[2].textContent.trim(),(t=t[4].textContent.trim())&&o&&n&&e&&r.push({eventName:e,date:n,eventNumber:o,time:t}))}),r.reverse()),c=0;!o&&c<i.length;c++){var s=i[c],l=s.eventName,d=s.date,u=s.eventNumber,p=s.time;a++;for(var m=0,b=Object.entries(y);m<b.length;m++){var h=_slicedToArray(b[m],2),g=h[0];h[1].test(l)&&!e[g]&&(e[g]={eventName:l,date:d,eventNumber:u,time:p},4===++n)&&(o=o||d)}}return{directions:e,completedCount:n,dateOfCompletion:o,totalEvents:a}})((t=document.querySelectorAll("#results"))[t.length-1])),(e=document.querySelector("h2"))&&e.parentNode&&(e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t))):console.log("Results table not found")})();

Support

Issues and support on GitHub