Skip to content

Commit 0d54af2

Browse files
authored
Merge pull request #307 from fraz3alpha/2021-10-website-changes
2021-10 website changes
2 parents de7bcaf + 2a343f3 commit 0d54af2

File tree

17 files changed

+329
-93
lines changed

17 files changed

+329
-93
lines changed

browser-extensions/chrome/manifest.json

Lines changed: 79 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,27 @@
1818
"content_scripts": [
1919
{
2020
"matches": [
21-
"*://www.parkrun.org.uk/results/athleteeventresultshistory/*",
22-
"*://www.parkrun.com.au/results/athleteeventresultshistory/*",
23-
"*://www.parkrun.co.nz/results/athleteeventresultshistory/*",
24-
"*://www.parkrun.ca/results/athleteeventresultshistory/*",
25-
"*://www.parkrun.ie/results/athleteeventresultshistory/*",
26-
"*://www.parkrun.co.za/results/athleteeventresultshistory/*",
27-
"*://www.parkrun.us/results/athleteeventresultshistory/*",
28-
"*://www.parkrun.sg/results/athleteeventresultshistory/*",
29-
"*://www.parkrun.pl/results/athleteeventresultshistory/*",
30-
"*://www.parkrun.it/results/athleteeventresultshistory/*",
31-
"*://www.parkrun.dk/results/athleteeventresultshistory/*",
32-
"*://www.parkrun.se/results/athleteeventresultshistory/*",
33-
"*://www.parkrun.fi/results/athleteeventresultshistory/*",
34-
"*://www.parkrun.fr/results/athleteeventresultshistory/*",
35-
"*://www.parkrun.no/results/athleteeventresultshistory/*",
36-
"*://www.parkrun.com.de/results/athleteeventresultshistory/*",
37-
"*://www.parkrun.ru/results/athleteeventresultshistory/*",
38-
"*://www.parkrun.my/results/athleteeventresultshistory/*",
39-
"*://www.parkrun.jp/results/athleteeventresultshistory/*",
40-
"*://www.parkrun.co.nl/results/athleteeventresultshistory/*"
21+
"*://www.parkrun.org.uk/parkrunner/*/all/",
22+
"*://www.parkrun.com.au/parkrunner/*/all/",
23+
"*://www.parkrun.co.nz/parkrunner/*/all/",
24+
"*://www.parkrun.ca/parkrunner/*/all/",
25+
"*://www.parkrun.ie/parkrunner/*/all/",
26+
"*://www.parkrun.co.za/parkrunner/*/all/",
27+
"*://www.parkrun.us/parkrunner/*/all/",
28+
"*://www.parkrun.sg/parkrunner/*/all/",
29+
"*://www.parkrun.pl/parkrunner/*/all/",
30+
"*://www.parkrun.it/parkrunner/*/all/",
31+
"*://www.parkrun.dk/parkrunner/*/all/",
32+
"*://www.parkrun.se/parkrunner/*/all/",
33+
"*://www.parkrun.fi/parkrunner/*/all/",
34+
"*://www.parkrun.fr/parkrunner/*/all/",
35+
"*://www.parkrun.no/parkrunner/*/all/",
36+
"*://www.parkrun.com.de/parkrunner/*/all/",
37+
"*://www.parkrun.ru/parkrunner/*/all/",
38+
"*://www.parkrun.my/parkrunner/*/all/",
39+
"*://www.parkrun.jp/parkrunner/*/all/",
40+
"*://www.parkrun.co.nl/parkrunner/*/all/",
41+
"*://www.parkrun.co.at/parkrunner/*/all/"
4142
],
4243
"js": [
4344
"js/lib/version.js",
@@ -53,7 +54,7 @@
5354
"js/lib/i18n.js",
5455
"js/lib/challenges.js",
5556
"js/lib/challenges_ui.js",
56-
"js/content-scripts/content-script-athleteeventresultshistory.js"
57+
"js/content-scripts/content-script-parkrunner.js"
5758
],
5859
"css": [
5960
"css/third-party/leaflet/leaflet.css",
@@ -85,7 +86,8 @@
8586
"*://www.parkrun.ru/results/athleteresultshistory/*",
8687
"*://www.parkrun.my/results/athleteresultshistory/*",
8788
"*://www.parkrun.jp/results/athleteresultshistory/*",
88-
"*://www.parkrun.co.nl/results/athleteresultshistory/*"
89+
"*://www.parkrun.co.nl/results/athleteresultshistory/*",
90+
"*://www.parkrun.co.at/results/athleteresultshistory/*"
8991
],
9092
"js": [
9193
"js/lib/third-party/browser-polyfill/browser-polyfill-76eeeac.js",
@@ -95,6 +97,59 @@
9597
],
9698
"run_at": "document_end"
9799
},
100+
{
101+
"matches": [
102+
"*://www.parkrun.org.uk/parkrunner/*/",
103+
"*://www.parkrun.com.au/parkrunner/*/",
104+
"*://www.parkrun.co.nz/parkrunner/*/",
105+
"*://www.parkrun.ca/parkrunner/*/",
106+
"*://www.parkrun.ie/parkrunner/*/",
107+
"*://www.parkrun.co.za/parkrunner/*/",
108+
"*://www.parkrun.us/parkrunner/*/",
109+
"*://www.parkrun.sg/parkrunner/*/",
110+
"*://www.parkrun.pl/parkrunner/*/",
111+
"*://www.parkrun.it/parkrunner/*/",
112+
"*://www.parkrun.dk/parkrunner/*/",
113+
"*://www.parkrun.se/parkrunner/*/",
114+
"*://www.parkrun.fi/parkrunner/*/",
115+
"*://www.parkrun.fr/parkrunner/*/",
116+
"*://www.parkrun.no/parkrunner/*/",
117+
"*://www.parkrun.com.de/parkrunner/*/",
118+
"*://www.parkrun.ru/parkrunner/*/",
119+
"*://www.parkrun.my/parkrunner/*/",
120+
"*://www.parkrun.jp/parkrunner/*/",
121+
"*://www.parkrun.co.nl/parkrunner/*/"
122+
],
123+
"exclude_matches": [
124+
"*://www.parkrun.org.uk/parkrunner/*/all/",
125+
"*://www.parkrun.com.au/parkrunner/*/all/",
126+
"*://www.parkrun.co.nz/parkrunner/*/all/",
127+
"*://www.parkrun.ca/parkrunner/*/all/",
128+
"*://www.parkrun.ie/parkrunner/*/all/",
129+
"*://www.parkrun.co.za/parkrunner/*/all/",
130+
"*://www.parkrun.us/parkrunner/*/all/",
131+
"*://www.parkrun.sg/parkrunner/*/all/",
132+
"*://www.parkrun.pl/parkrunner/*/all/",
133+
"*://www.parkrun.it/parkrunner/*/all/",
134+
"*://www.parkrun.dk/parkrunner/*/all/",
135+
"*://www.parkrun.se/parkrunner/*/all/",
136+
"*://www.parkrun.fi/parkrunner/*/all/",
137+
"*://www.parkrun.fr/parkrunner/*/all/",
138+
"*://www.parkrun.no/parkrunner/*/all/",
139+
"*://www.parkrun.com.de/parkrunner/*/all/",
140+
"*://www.parkrun.ru/parkrunner/*/all/",
141+
"*://www.parkrun.my/parkrunner/*/all/",
142+
"*://www.parkrun.jp/parkrunner/*/all/",
143+
"*://www.parkrun.co.nl/parkrunner/*/all/"
144+
],
145+
"js": [
146+
"js/lib/third-party/browser-polyfill/browser-polyfill-76eeeac.js",
147+
"js/lib/third-party/jquery/jquery-3.3.1.js",
148+
"js/lib/i18n.js",
149+
"js/content-scripts/content-script-parkrunner-summary.js"
150+
],
151+
"run_at": "document_end"
152+
},
98153
{
99154
"matches": [
100155
"*://www.parkrun.org.uk/*/results/athletehistory/*",
@@ -116,7 +171,8 @@
116171
"*://www.parkrun.ru/*/athletehistory/*",
117172
"*://www.parkrun.my/*/results/athletehistory/*",
118173
"*://www.parkrun.jp/*/results/athletehistory/*",
119-
"*://www.parkrun.co.nl/*/results/athletehistory/*"
174+
"*://www.parkrun.co.nl/*/results/athletehistory/*",
175+
"*://www.parkrun.co.at/*/results/athletehistory/*"
120176
],
121177
"js": [
122178
"js/lib/third-party/browser-polyfill/browser-polyfill-76eeeac.js",

browser-extensions/common/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# Examples
22

3-
Someone who hasn't done many other parkruns other than their own course: [Liz MARSHALL](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=930349&eventNumber=0)
3+
Someone who hasn't done many other parkruns other than their own course: [Liz MARSHALL](https://www.parkrun.org.uk/parkrunner/930349/all/)
44

5-
Someone who done a lot of touristing: [James WHITE](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=556789&eventNumber=0)
5+
Someone who done a lot of touristing: [James WHITE](https://www.parkrun.org.uk/parkrunner/556789/all/)
66

7-
Someone who has done a lot of parkruns: [Glenna GREENSLADE](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=105134&eventNumber=0)
7+
Someone who has done a lot of parkruns: [Glenna GREENSLADE](https://www.parkrun.org.uk/parkrunner/105134/all/)
88

9-
The Famous Cowells: [Chris COWELL](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=11865&eventNumber=0) and [Linda COWELL](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=18414&eventNumber=0)
9+
The Famous Cowells: [Chris COWELL](https://www.parkrun.org.uk/parkrunner/11865&eventNumber=0) and [Linda COWELL](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=18414/all/)
1010

11-
People responsible for getting more involved: [Tim GP](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=78426&eventNumber=0) & [May GP](http://www.parkrun.org.uk/winchester/results/athletehistory/?athleteNumber=81219)
11+
People responsible for getting more involved: [Tim GP](https://www.parkrun.org.uk/parkrunner/78426/all/) & [May GP](http://www.parkrun.org.uk/winchester/results/athletehistory/?athleteNumber=81219)
1212

13-
Two other people [Laura COWEN](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=1386351&eventNumber=0) & [Andrew TAYLOR](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=1309364&eventNumber=0)
13+
Two other people [Laura COWEN](https://www.parkrun.org.uk/parkrunner/1386351&eventNumber=0) & [Andrew TAYLOR](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=1309364/all/)
1414

15-
Sparse Example: [Andy STANFORD-CLARK](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=1770518&eventNumber=0)
15+
Sparse Example: [Andy STANFORD-CLARK](https://www.parkrun.org.uk/parkrunner/1770518/all/)
1616

17-
Founder: [Paul Sinton-Hewitt](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=1674&eventNumber=0)
17+
Founder: [Paul Sinton-Hewitt](https://www.parkrun.org.uk/parkrunner/1674/all/)
1818

19-
Unfeasibly large number of different parkuns, and totals in a year: [Paul FREYNE](http://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=5227&eventNumber=0)
19+
Unfeasibly large number of different parkuns, and totals in a year: [Paul FREYNE](https://www.parkrun.org.uk/parkrunner/5227/all/)
2020

2121
Me: https://www.google.com/maps/search/?api=1&query=50.050091595041295,0.3533679090909079
2222
Laura: https://www.google.com/maps/search/?api=1&query=50.99635012087909,-4.604887230769234
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
To run the tests locally you will need a number of Docker containers that are running Selenium in order to run those tests.
2+
3+
You can run them all at once:
4+
```
5+
docker run --name selenium-firefox -d -p 4444:4444 -p 7900:7900 selenium/standalone-chrome
6+
docker run --name selenium-firefox -d -p 4445:4444 -p 7901:7900 selenium/standalone-firefox
7+
```
8+
These "latest" tagged images appear to be the latest in the 3.x line - which I assume is selenium,
9+
rather than any bearing on the browser version
10+
11+
I assume this will work too:
12+
```
13+
docker run --name selenium-firefox -d -p 4446:4444 -p 7902:7900 selenium/standalone-edge
14+
```
15+
16+
When run in Github Actions we can define the port to be constant, or for it to be dynamically
17+
generated at runtime, and pick it up from a variable. This is probably preferable
18+
19+
You need to set the value of EXTENSION_ZIP to point to a built extension, on Windows you do it like:
20+
```
21+
$Env:EXTENSION_ZIP="C:\\Users\\andre\\Downloads\\running_challenges-chrome-1.1.4.26.zip"
22+
```
23+
24+
If you want you can set the browser, but it will default to chrome - although perhaps we could derrive this from the zip name?:
25+
```
26+
$Env:EXTENSION_BROWSER="firefox"
27+
```
28+
The port defaults to 4444, but you can override it with:
29+
```
30+
$Env:SELENIUM_PORT="4445"
31+
```

browser-extensions/common/js/background.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ browser.browserAction.onClicked.addListener(function(tab) {
5151
}
5252

5353
console.log("local_url for this user is: " + local_url)
54-
results_url = "https://" + local_url + "/"+get_localised_value("url_athleteeventresultshistory", local_url)+"?athleteNumber="+items.athlete_number+"&eventNumber=0"
54+
results_url = "https://" + local_url + "/parkrunner/" + items.athlete_number + "/all"
5555
browser.tabs.create({ url: results_url });
5656
}
5757

@@ -96,6 +96,7 @@ function getCountryNameFromId(id) {
9696
// Sub-countries are assigned a number with a prefix of their main country site code.
9797
var countryMap = {
9898
"3": "Australia",
99+
"4": "Austria",
99100
"14": "Canada",
100101
"23": "Denmark",
101102
"30": "Finland",

browser-extensions/common/js/content-scripts/content-script-athleteeventhistory.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ function get_challenge_link_location() {
55
function get_athlete_id() {
66
// Very basic method to get only the parameter we care about
77
var page_parameters = window.location.search
8-
var athlete_id = null
9-
if (page_parameters.includes('athleteNumber=')) {
8+
var athlete_id = undefined
9+
10+
if (window.location.pathname.startsWith('/parkrunner')) {
11+
athlete_id = window.location.pathname.match('parkrunner\/([0-9]+)\/all')[1]
12+
} else if (page_parameters.includes('athleteNumber=')) {
1013
athlete_id = page_parameters.split('athleteNumber=')[1].split('&')[0]
1114
}
15+
1216
return athlete_id
1317
}
1418

1519
var athlete_id = get_athlete_id()
16-
if (athlete_id != null) {
17-
url = 'https://' + location.host + "/" + get_localised_value('url_athleteeventresultshistory')+'?athleteNumber='+athlete_id+'&eventNumber=0'
20+
if (athlete_id !== undefined) {
21+
url = 'https://' + location.host + "/parkrunner/" + athlete_id +'/all'
1822

1923
if (url != null) {
2024
var challenge_link = $("<a/>").attr("href", url)

browser-extensions/common/js/content-scripts/content-script-athleteresultshistory.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ function get_challenge_link_location() {
55
function get_athlete_id() {
66
// Very basic method to get only the parameter we care about
77
var page_parameters = window.location.search
8-
var athlete_id = null
9-
if (page_parameters.includes('athleteNumber=')) {
8+
var athlete_id = undefined
9+
10+
if (window.location.pathname.startsWith('/parkrunner')) {
11+
athlete_id = window.location.pathname.match('parkrunner\/([0-9]+)\/all')[1]
12+
} else if (page_parameters.includes('athleteNumber=')) {
1013
athlete_id = page_parameters.split('athleteNumber=')[1].split('&')[0]
1114
}
15+
16+
console.log('Athlete ID: '+athlete_id)
1217
return athlete_id
1318
}
1419

20+
1521
var athlete_id = get_athlete_id()
16-
if (athlete_id != null) {
17-
url = 'https://' + location.host + "/" + get_localised_value('url_athleteeventresultshistory')+'?athleteNumber='+athlete_id+'&eventNumber=0'
22+
if (athlete_id !== undefined) {
23+
url = 'https://' + location.host + "/parkrunner/" + athlete_id +'/all'
1824

1925
if (url != null) {
2026
var challenge_link = $("<a/>").attr("href", url)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
function get_challenge_link_location() {
2+
return $("div[id=content]").find("p:first")
3+
}
4+
5+
function get_athlete_id() {
6+
// Very basic method to get only the parameter we care about
7+
var page_parameters = window.location.search
8+
var athlete_id = undefined
9+
10+
if (window.location.pathname.startsWith('/parkrunner')) {
11+
athlete_id = window.location.pathname.match('parkrunner\/([0-9]+)\/')[1]
12+
} else if (page_parameters.includes('athleteNumber=')) {
13+
athlete_id = page_parameters.split('athleteNumber=')[1].split('&')[0]
14+
}
15+
16+
console.log('Athlete ID: '+athlete_id)
17+
return athlete_id
18+
}
19+
20+
21+
var athlete_id = get_athlete_id()
22+
if (athlete_id !== undefined) {
23+
url = 'https://' + location.host + "/parkrunner/" + athlete_id + '/all'
24+
25+
if (url != null) {
26+
var challenge_link = $("<a/>").attr("href", url)
27+
28+
var icon = $('<img/>')
29+
icon.attr('src', browser.extension.getURL("/images/logo/logo-128x128.png"))
30+
icon.attr('alt', get_localised_value("text_running_challenges"))
31+
icon.attr('title', get_localised_value("text_running_challenges"))
32+
icon.attr('height', 24)
33+
icon.attr('width', 24)
34+
35+
challenge_link.append(icon)
36+
challenge_link.append($("<span/>").text(get_localised_value("text_see_challenge_progress")))
37+
get_challenge_link_location().after($('<div/>').append($('<p/>').append(challenge_link)))
38+
}
39+
}

browser-extensions/common/js/content-scripts/content-script-athleteeventresultshistory.js renamed to browser-extensions/common/js/content-scripts/content-script-parkrunner.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ function parse_volunteer_table(result) {
3838
// "Volunteer Summary"
3939
var results_table = $(this)
4040
parent = $(this).parent()
41-
$("h1#volunteer-summary", parent).each(function (index) {
41+
$("h3#volunteer-summary", parent).each(function (index) {
4242
completed_volunteer_roles = {}
4343
$("tbody>tr", results_table).each(function (role_index) {
4444
table_cells = $("td", this)
45-
volunteer_role = table_cells[1].innerText
46-
volunteer_role_quantity = table_cells[2].innerText
45+
volunteer_role = table_cells[0].innerText.replace(/^\s+|\s+$/g, '');
46+
volunteer_role_quantity = table_cells[1].innerText
4747

4848
// Try and translate from whatever language it is in
4949
normalised_volunteer_role = get_normalised_volunteer_role(volunteer_role)
@@ -97,9 +97,9 @@ function parsePageAthleteInfo() {
9797
// </h2>
9898

9999
// It can look different in different languages, e.g.
100-
// https://www.parkrun.ru/results/athleteeventresultshistory/?athleteNumber=5481082&eventNumber=0
100+
// https://www.parkrun.ru/parkrunner/5481082/all/
101101
// <h2>Максим МАХНО - 14 пробежек на All Events<br/>14 забеги parkrun total</h2>
102-
// https://www.parkrun.jp/results/athleteeventresultshistory/?athleteNumber=6460713&eventNumber=0
102+
// https://www.parkrun.jp/parkrunner/6460713/all/
103103
// <h2>和輝 遠藤 - 10 参加 All Events<br/>10 parkrun total</h2>
104104

105105
// In each case, however, it is the first <h2> block, and everything before the dash is what we want.
@@ -610,9 +610,13 @@ function get_athlete_id() {
610610
// Very basic method to get only the parameter we care about
611611
var page_parameters = window.location.search
612612
var athlete_id = undefined
613-
if (page_parameters.includes('athleteNumber=')) {
613+
614+
if (window.location.pathname.startsWith('/parkrunner')) {
615+
athlete_id = window.location.pathname.match('parkrunner\/([0-9]+)\/all')[1]
616+
} else if (page_parameters.includes('athleteNumber=')) {
614617
athlete_id = page_parameters.split('athleteNumber=')[1].split('&')[0]
615618
}
619+
616620
console.log('Athlete ID: '+athlete_id)
617621
return athlete_id
618622
}

browser-extensions/common/js/lib/challenges.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,7 @@ function get_flag_image_src(country) {
990990
var flag_map = {
991991
"New Zealand": "nz",
992992
"Australia": "au",
993+
"Austria": "at",
993994
"Canada": "ca",
994995
"Denmark": "dk",
995996
"Finland": "fi",
@@ -1283,11 +1284,11 @@ function challenge_name_badge(data, params) {
12831284
// This works for English speaking countries, and we might be able to manage a bit of Russian,
12841285
// but we are broken for Japanese Kanji names :(
12851286
// Some samples
1286-
// https://www.parkrun.ru/results/athleteeventresultshistory/?athleteNumber=5481082&eventNumber=0
1287-
// https://www.parkrun.jp/results/athleteeventresultshistory/?athleteNumber=6460713&eventNumber=0
1287+
// https://www.parkrun.ru/parkrunner/5481082/all/
1288+
// https://www.parkrun.jp/parkrunner/6460713/all/
12881289
//
12891290
// PS-H, which has a hyphen is his surname:
1290-
// https://www.parkrun.org.uk/results/athleteeventresultshistory/?athleteNumber=1674&eventNumber=0
1291+
// https://www.parkrun.org.uk/parkrunner/1674/all/
12911292

12921293
// Find the data we are interested in
12931294
parkrun_results = data.parkrun_results
@@ -1530,7 +1531,7 @@ function challenge_start_letters(data, params) {
15301531
// Add the first on that we haven't already added
15311532
$.each(sorted_grouped_events[o.subparts[i]], function(index, event) {
15321533
// Only add it, and break out of the loop, if it is new
1533-
if (!(event.name in o.nearest_qualifying_events)) {
1534+
if (!(event.name in o.nearest_qualifying_events) && !(event.name in o.completed_qualifying_events)) {
15341535
o.nearest_qualifying_events[event.name] = get_parkrun_event_details(data, event.name)
15351536
// Break out
15361537
return false

0 commit comments

Comments
 (0)