(username)
| 10 | }; |
| 11 | |
| 12 | async function fetchYears(username) { |
| 13 | const data = await fetch(`https://github.com/${username}?tab=contributions`, { |
| 14 | headers: { |
| 15 | "x-requested-with": "XMLHttpRequest" |
| 16 | } |
| 17 | }); |
| 18 | const body = await data.text(); |
| 19 | const $ = cheerio.load(body); |
| 20 | return $(".js-year-link.filter-item") |
| 21 | .get() |
| 22 | .map((a) => { |
| 23 | const $a = $(a); |
| 24 | const href = $a.attr("href"); |
| 25 | const githubUrl = new URL(`https://github.com${href}`); |
| 26 | githubUrl.searchParams.set("tab", "contributions"); |
| 27 | const formattedHref = `${githubUrl.pathname}${githubUrl.search}`; |
| 28 | |
| 29 | return { |
| 30 | href: formattedHref, |
| 31 | text: $a.text().trim() |
| 32 | }; |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | async function fetchDataForYear(url, year, format) { |
| 37 | const data = await fetch(`https://github.com${url}`, { |
no outgoing calls
no test coverage detected