1
Fork 0
tildes-reextended/source/utilities/groups.ts

18 lines
530 B
TypeScript
Raw Normal View History

2023-06-23 10:52:03 +00:00
import {log} from "./logging.js";
import {querySelectorAll} from "./query-selectors.js";
/**
* Tries to extract and save the groups. Returns the current saved groups when
* the user is not in `/groups` and the new ones when they are in `/groups`.
*/
export function extractGroups(): string[] | undefined {
2023-06-23 10:52:03 +00:00
if (window.location.pathname !== "/groups") {
log('Not in "/groups", returning early.');
return;
}
2023-06-23 10:52:03 +00:00
return querySelectorAll(".link-group").map(
(value) => value.textContent ?? "<unknown group>",
);
}