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

17 lines
448 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";
/**
2023-06-25 10:00:43 +00:00
* Try to extract the groups when in the group listing page at `/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>",
);
}