Skip to content

Commit

Permalink
Merge pull request #22 from KajSchmidt/18-år
Browse files Browse the repository at this point in the history
18 år
  • Loading branch information
KajSchmidt authored Oct 17, 2023
2 parents 7c39f0f + 2b53d48 commit 11a740e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Namnslumpare som hämtar namn från Schoolsoft genom en chrome extenstion.

## Versioner

### 2.1

* Räknar ut ålder på elevkort

### 2.0

* Manifest v3
Expand Down
15 changes: 15 additions & 0 deletions chrome-extension/check_age.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(function() {
let age_row = document.querySelector("#tab6 > table > tbody > tr > td > table > tbody > tr:nth-of-type(4)"); //Hämtar raden för personnummer
let age_row_header = age_row.children[0];
let age_row_age = age_row.children[1];
if (age_row_header.innerText == "Personnummer") { //Dubbelkollar att det är rätt celler
let birth_string = "20" + age_row_age.innerText.substring(0,2) + "-" + age_row_age.innerText.substring(2,4) + "-" + age_row_age.innerText.substring(4,6); //Formaterar YYYY-MM--DD
let birth_date = new Date(birth_string);
let age_diff = new Date(Date.now() - birth_date.getTime()); //Räknar ut skillnad i timestamp-format
let age_year = age_diff.getFullYear() - 1970; //Räknar om skillnaden till år

let age_span = document.createElement("span");
age_span.innerText = " (Ålder: " + age_year + ")";
age_row_age.append(age_span);
}
})();
7 changes: 5 additions & 2 deletions chrome-extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Lilla verktygslådan",
"version": "2.0",
"version": "2.1",
"manifest_version": 3,
"description": "Verktyg för att slumpa grupper, elever m.m. från närvaroinformation i schoolsoft.",
"author":"Kaj Schmidt, NTI-Gymnasiet Umeå, kaj.schmidt@ntig.se",
Expand All @@ -9,7 +9,10 @@
"128": "img/logo-128.png" },
"content_scripts": [{
"matches": ["https://*.schoolsoft.se/*/jsp/teacher/right_teacher_lesson_status.jsp*"],
"js": ["collector.js"]
"js": ["name_collector.js"]
},{
"matches": ["https://sms.schoolsoft.se/*/jsp/teacher/right_teacher_mentor_student_card.jsp*"],
"js": ["check_age.js"]
}],
"action": {
"name": "Lilla verktygslådan",
Expand Down
File renamed without changes.

0 comments on commit 11a740e

Please sign in to comment.