Adds a link to the consolidated club report for the most recent Sunday on junior parkrun group pages

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.

junior parkrun Group Sunday Link Screenshot

Install junior parkrun Group Sunday Link

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:

junior parkrun Group Sunday Link 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 findConsolidatedClubLink(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:document;return Array.from(t.querySelectorAll("a")).find(function(t){return t.href.includes("/consolidatedclub/?")})||null}function extractClubNumFromLink(t){try{return new URL(t.href).searchParams.get("clubNum")}catch(t){return null}}function getMostRecentSunday(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Date,e=new Date(t);return e.setDate(t.getDate()-t.getDay()),e}function formatDateYYYYMMDD(t){var e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),t=String(t.getDate()).padStart(2,"0");return"".concat(e,"-").concat(n,"-").concat(t)}function buildSundayLink(t,e,n){e="https://www.parkrun.com/results/consolidatedclub/?clubNum=".concat(e,"&eventdate=").concat(n),n=t.cloneNode(!0);return n.href=e,n.textContent="View the consolidated club report for member participation at last Sunday's junior parkruns",n}function insertAfter(t,e){t.parentNode.insertBefore(document.createElement("br"),t.nextSibling),t.parentNode.insertBefore(e,t.nextSibling.nextSibling)}(()=>{var t,e=findConsolidatedClubLink();e&&(t=extractClubNumFromLink(e))&&insertAfter(e,buildSundayLink(e,t,formatDateYYYYMMDD(getMostRecentSunday())))})(),"undefined"!=typeof module&&void 0!==module.exports&&(module.exports={findConsolidatedClubLink:findConsolidatedClubLink,extractClubNumFromLink:extractClubNumFromLink,getMostRecentSunday:getMostRecentSunday,formatDateYYYYMMDD:formatDateYYYYMMDD,buildSundayLink:buildSundayLink,insertAfter:insertAfter});
Last updated
Version
0.2.8
Author
Pete Johns (@johnsyweb)
Homepage
https://www.johnsy.com/tampermonkey-parkrun/
Support
Issues / support
License
MIT