Skip to content

Instantly share code, notes, and snippets.

@stekern
Created May 15, 2019 18:02
Show Gist options
  • Save stekern/7739ca39f56bfe01291a5e1fc5228892 to your computer and use it in GitHub Desktop.
Save stekern/7739ca39f56bfe01291a5e1fc5228892 to your computer and use it in GitHub Desktop.
Calculate GPA from StudentWeb
// This script will calculate your GPA according to your grades on StudentWeb.
// 1. Go to https://fsweb.no/studentweb/resultater.jsf
// 2. Open up your browser's developer console
// 3. Run the following code
{const e=$x('//table[@id="resultatlisteForm:HeleResultater:resultaterPanel"]/tbody/tr[@class="none" or @class="resultatTop"]/td[contains(@class, "col6Resultat") or contains(@class, "col7Studiepoeng")]//span[last()]/text()').reduce((e,t,s,a)=>(s%3==0&&1===a[s+1].length&&e.push({grade:a[s+1].data,credits:parseFloat(a[s+2].data.replace(",","."))}),e),[]),t=e.reduce((e,t)=>e+t.credits,0),s=e.reduce((e,t)=>e+(70-t.grade.charCodeAt(0))*t.credits,0)/t;console.log(`GPA: ${s}, sum of credits: ${t}`)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment