Skip to content

Commit

Permalink
added date search for person
Browse files Browse the repository at this point in the history
  • Loading branch information
on committed Sep 4, 2025
1 parent 538e66c commit d970e3c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bas-search.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name BAS Quick Search
// @namespace http://tampermonkey.net/
// @version 1.7.7
// @version 1.7.8
// @description Quick search using `Ctrl` + `Shift` + `F` hotkey, group search with "g:" and person search with "p:" prefix. Navigate tabs with Ctrl + Left/Right keys. Navigate search results with up and down keys.
// @author Øyvind Nilsen (on@ntnu.no)
// @match https://bas.ntnu.no/*
Expand Down Expand Up @@ -448,7 +448,14 @@
url = `https://bas.ntnu.no/group/search/?name=${encodeURIComponent(groupName)}`;
} else if (searchQuery.toLowerCase().startsWith('p:')) {
const personName = searchQuery.substring(2).trim();
url = `https://bas.ntnu.no/person/search/?name=${encodeURIComponent(personName)}`;

// Check if personName matches ISO date format (YYYY-MM-DD)
const isoDateRegex = /^\d{4}-\d{2}-\d{2}$/;
if (isoDateRegex.test(personName)) {
url = `https://bas.ntnu.no/person/search/?birth_date=${encodeURIComponent(personName)}`;
} else {
url = `https://bas.ntnu.no/person/search/?name=${encodeURIComponent(personName)}`;
}
} else {
const accountName = searchQuery.toLowerCase().startsWith('a:') ? searchQuery.substring(2).trim() : searchQuery;
url = `https://bas.ntnu.no/account/search/?name=${encodeURIComponent(accountName)}`;
Expand Down

0 comments on commit d970e3c

Please sign in to comment.