diff --git a/index.html b/index.html index 38f38611..a1c5c97a 100644 --- a/index.html +++ b/index.html @@ -2,9 +2,9 @@ - + - Vite App + OpenSauced.ai
diff --git a/src/content-scripts.css b/src/content-scripts.css deleted file mode 100644 index e089f726..00000000 --- a/src/content-scripts.css +++ /dev/null @@ -1,22 +0,0 @@ -@tailwind components; -@tailwind utilities; - -* { - box-sizing: border-box; - margin: 0px; - padding: 0px; -} - -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", - "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", - monospace; -} diff --git a/src/hooks/useGithubPRPageCheck.ts b/src/hooks/useGithubPRPageCheck.ts new file mode 100644 index 00000000..d2ea60b1 --- /dev/null +++ b/src/hooks/useGithubPRPageCheck.ts @@ -0,0 +1,19 @@ +import { useEffect, useState } from "react"; +import { isGithubPullRequestPage } from "../utils/urlMatchers"; + +export const useIsGithubPRPageCheck = () => { + const [isGithubPRPage, setIsGithubPRPage] = useState(false); + + useEffect(() => { + chrome.tabs.query({ active: true, currentWindow: true }, tabs => { + if (tabs.length > 0) { + const tab = tabs[0]; + + setIsGithubPRPage(isGithubPullRequestPage(tab.url!)); + } + }); + }, []); + + + return isGithubPRPage; +}; diff --git a/src/pages/home.tsx b/src/pages/home.tsx index 011c6264..4735279c 100644 --- a/src/pages/home.tsx +++ b/src/pages/home.tsx @@ -19,10 +19,12 @@ import { getHighlights } from "../utils/fetchOpenSaucedApiData"; import Help from "./help"; import { OPEN_SAUCED_INSIGHTS_DOMAIN } from "../constants"; import type { Highlight } from "../ts/types"; +import { useIsGithubPRPageCheck } from "../hooks/useGithubPRPageCheck"; const Home = () => { const { user } = useAuth(); const { currentTabIsOpensaucedUser, checkedUser } = useOpensaucedUserCheck(); + const isGithubPRPage = useIsGithubPRPageCheck(); const [highlights, setHighlights] = useState([]); const [currentPage, setCurrentPage] = useState(0); @@ -173,15 +175,16 @@ const Home = () => { AI Configuration - + {isGithubPRPage && ( + )} {currentTabIsOpensaucedUser && (