Skip to content

Commit

Permalink
prefixes can now be used without colon. So 'g <searchstring>' is the …
Browse files Browse the repository at this point in the history
…same as 'g:<searchstring>'
  • Loading branch information
on committed Oct 2, 2025
1 parent df2e3f8 commit e503718
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 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.10
// @version 1.7.11
// @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 @@ -454,12 +454,13 @@
inputBox.addEventListener('keydown', function(event) {
if (event.key === 'Enter') {
const searchQuery = inputBox.value.trim();
const lowerSearchQuery = searchQuery.toLowerCase();
let url;

if (searchQuery.toLowerCase().startsWith('g:')) {
if (lowerSearchQuery.startsWith('g:') || lowerSearchQuery.startsWith('g ')) {
const groupName = searchQuery.substring(2).trim();
url = `https://bas.ntnu.no/group/search/?name=${encodeURIComponent(groupName)}`;
} else if (searchQuery.toLowerCase().startsWith('p:')) {
} else if (lowerSearchQuery.startsWith('p:') || lowerSearchQuery.startsWith('p ')) {
const personName = searchQuery.substring(2).trim();

// Check if personName matches ISO date format (YYYY-MM-DD)
Expand All @@ -470,7 +471,10 @@
url = `https://bas.ntnu.no/person/search/?name=${encodeURIComponent(personName)}`;
}
} else {
const accountName = searchQuery.toLowerCase().startsWith('a:') ? searchQuery.substring(2).trim() : searchQuery;
let accountName = searchQuery;
if (lowerSearchQuery.startsWith('a:') || lowerSearchQuery.startsWith('a ')) {
accountName = searchQuery.substring(2).trim();
}
url = `https://bas.ntnu.no/account/search/?name=${encodeURIComponent(accountName)}`;
}

Expand Down

0 comments on commit e503718

Please sign in to comment.