2023-06-23 10:52:03 +00:00
|
|
|
import {log} from "./logging.js";
|
|
|
|
import {querySelectorAll} from "./query-selectors.js";
|
2020-10-10 23:32:27 +00:00
|
|
|
|
|
|
|
/**
|
2023-06-25 10:00:43 +00:00
|
|
|
* Try to extract the groups when in the group listing page at `/groups`.
|
2020-10-10 23:32:27 +00:00
|
|
|
*/
|
2022-02-23 13:52:06 +00:00
|
|
|
export function extractGroups(): string[] | undefined {
|
2023-06-23 10:52:03 +00:00
|
|
|
if (window.location.pathname !== "/groups") {
|
2020-10-10 23:32:27 +00:00
|
|
|
log('Not in "/groups", returning early.');
|
2022-02-23 13:52:06 +00:00
|
|
|
return;
|
2020-10-10 23:32:27 +00:00
|
|
|
}
|
|
|
|
|
2023-06-23 10:52:03 +00:00
|
|
|
return querySelectorAll(".link-group").map(
|
|
|
|
(value) => value.textContent ?? "<unknown group>",
|
2020-10-10 23:32:27 +00:00
|
|
|
);
|
|
|
|
}
|