Skip to content

Commit

Permalink
feat: Export isCurrentPageSupported
Browse files Browse the repository at this point in the history
  • Loading branch information
Neet-Nestor committed Sep 14, 2024
1 parent 8eaf5ed commit f0e643a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { IPageHandler } from "./page/interface";
import * as Oveleaf from "./page/overleaf";

const PAGE_HANDLER_MAP: Record<string, typeof Oveleaf.PageHandler> = {
Expand All @@ -9,15 +8,19 @@ const PAGE_TOOLS_MAP: Record<string, typeof Oveleaf.tools> = {
"www.overleaf.com": Oveleaf.tools,
};

export const isCurrentPageSupported = () => {
return Object.keys(PAGE_HANDLER_MAP).includes(window.location.hostname);
};

export const initHandler = () => {
if (Object.keys(PAGE_HANDLER_MAP).includes(window.location.hostname)) {
if (isCurrentPageSupported()) {
return new PAGE_HANDLER_MAP[window.location.hostname]();
}
console.error("[Web Agent Interface] No tools found for the current page");
};

const getTools = () => {
if (Object.keys(PAGE_TOOLS_MAP).includes(window.location.hostname)) {
if (isCurrentPageSupported()) {
return PAGE_TOOLS_MAP[window.location.hostname];
}
console.error("[Web Agent Interface] No tools found for the current page");
Expand Down

0 comments on commit f0e643a

Please sign in to comment.