User:Habst/getWaNews.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Habst/getWaNews. |
await (await fetch("https://jsyr3xmt7nchpjukzohfslxfre.appsync-api.eu-west-1.amazonaws.com/graphql", {
headers: { "x-api-key": "da2-o5lb23etxbe3viqhbquknwoazq" }, // intentionally public
body: JSON.stringify({
operationName: "GetNewArticles",
variables: {
language: "en",
orderBy: "PublishedDate",
orderDirection: "Descending",
checkHiddenOnMainSite: true,
types: [13], // heritage
limit: 999,
offset: 0,
},
query: `query GetNewArticles($language: String = "en", $relatedEventIds: [Int], $relatedCompetitionIds: [String], $types: [Int], $orderBy: OrderByNewArticleEnum = PublishedDate, $orderDirection: OrderDirectionEnum = Descending, $limit: Int, $offset: Int, $relatedEventNameUrlSlug: [String], $relatedDisciplineUrlSlug: [String], $relatedDisciplineCodes: [String], $relatedAthleteUrlSlug: [String], $relatedAthleteIds: [String], $relatedCompetitionUrlSlug: [String], $relatedMinisiteIds: [String], $relatedLocationIds: [String], $relatedCountryCodes: [String], $relatedRegionCodes: [String], $tags: [String], $filterArticleSlug: String, $checkHiddenOnMainSite: Boolean = true, $publishedYear: String) {
getNewArticles(language: $language, relatedEventIds: $relatedEventIds, relatedCompetitionIds: $relatedCompetitionIds, relatedEventNameUrlSlug: $relatedEventNameUrlSlug, relatedDisciplineUrlSlug: $relatedDisciplineUrlSlug, relatedDisciplineCodes: $relatedDisciplineCodes, relatedAthleteUrlSlug: $relatedAthleteUrlSlug, relatedAthleteIds: $relatedAthleteIds, relatedCompetitionUrlSlug: $relatedCompetitionUrlSlug, relatedMinisiteIds: $relatedMinisiteIds, relatedLocationIds: $relatedLocationIds, relatedCountryCodes: $relatedCountryCodes, relatedRegionCodes: $relatedRegionCodes, tags: $tags, types: $types, orderBy: $orderBy, orderDirection: $orderDirection, limit: $limit, offset: $offset, filterArticleSlug: $filterArticleSlug, checkHiddenOnMainSite: $checkHiddenOnMainSite, publishedYear: $publishedYear) {
...ArticleUrlFields
id
title
body
gatedContent
standFirst
standfirst
liveFrom
contentId
urlSlug
backgroundColour
seoDescription
imageEdited
campaignId
relatedUrls
slug
articleType
featureImageId
featureImageEdited
hideOnTheMainSite
sEOTitle: seoTitle
seoTitle
metaDescription: seoDescription
eventId
blogUpdated
liveBlog
language
contentModules {
moduleType
backgroundColor
__typename
}
relatedMedia {
id
fileName
__typename
}
relatedCompetitions {
...ArticleRelatedCompetitions
__typename
}
event {
...ArticleEventUrlFields
__typename
}
relatedEventIds
relatedEvents {
id
name
...ArticleEventUrlFields
__typename
}
relatedCompetitors {
id
iaafId
firstName
lastName
friendlyName
fullName
friendlyNameLetter
friendlyNameFirst3Letter
sexCode
sexName
countryCode
countryName
birthDate
birthPlace
birthPlaceCountryName
sexNameUrlSlug
countryUrlSlug
birthPlaceCountryUrlSlug
birthCountryCode
primaryMediaId
primaryMedia {
fileName
__typename
}
urlSlug
representativeId
biography
twitterLink
instagramLink
facebookLink
transfersOfAllegiance
aaId
countryFullName
familyName
givenName
birthDateStr
facebookUsername
twitterUsername
instagramUsername
__typename
}
relatedCountryCodes
relatedRegionCodes
__typename
}
}
fragment ArticleUrlFields on NewArticle {
articleType
urlSlug
relatedMinisiteIds
relatedMinisitePages {
slug
__typename
}
tags
__typename
}
fragment ArticleEventUrlFields on WAWEvent {
id
eventId_WA
nameUrlSlug
subCategoryNameUrlSlug
categoryCode
endDate
name
countryName
venue
areaName
areaCode
countryCode
indoorOutdoor
categoryCode
categoryName
page {
slug
__typename
}
__typename
}
fragment ArticleRelatedCompetitions on Competition {
id
name
urlSlug
category
__typename
}`
}),
method: "POST",
})).json();
temp1.toReversed().map(a => `* ${a.title.replace('Track & Field', 'Track_&_Field').replace('Hare & Hounds', 'Hare_&_Hounds').replace('Boys and Girls', 'Boys_and_Girls').split(/ (&|\/|and) /).filter(w => !['&', '/', 'and'].includes(w)).map(t => `[[${t}]]`).join(', ')}: ${a.body.split('\n').find(l => l.toLowerCase().includes('plaque categor'))?.split('-').at(-1).split('–').at(-1).replace('</span>', '').replace('</p>', '')}`).join('\n')