diff --git a/manifest.json b/manifest.json
index eedf612a..c4ee64a5 100644
--- a/manifest.json
+++ b/manifest.json
@@ -7,13 +7,23 @@
{
"js": ["src/content-scripts/profileScreen.ts"],
"matches": ["https://github.com/*"]
+ },
+ {
+ "js": ["src/content-scripts/hotOSHomePage.ts"],
+ "matches": ["https://hot.opensauced.pizza/*"],
+ "run_at": "document_end"
}
],
+ "background": {
+ "service_worker": "src/worker/background.ts",
+ "type": "module"
+ },
"icons": {
"16": "src/assets/os-icons/os-icon-16.png",
"32": "src/assets/os-icons/os-icon-32.png",
"48": "src/assets/os-icons/os-icon-48.png",
"128": "src/assets/os-icons/os-icon-128.png"
},
- "permissions": ["storage"]
+ "host_permissions": [""],
+ "permissions": ["storage","webRequest"]
}
diff --git a/src/App.tsx b/src/App.tsx
index 9c3c7158..1f300517 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,7 +1,6 @@
import { useState, useEffect } from "react";
import Start from "./pages/start";
-import SignIn from "./pages/signin";
import Home from "./pages/home";
import Loading from "./pages/loading";
@@ -9,7 +8,7 @@ import { checkTokenValidity } from "./utils/fetchOpenSaucedApiData";
function App() {
const [osAccessToken, setOsAccessToken] = useState("");
- // renderedPage can be either "start", "home", "signin" or "loading"
+ // renderedPage can be either "start", "home" or "loading"
const [renderedPage, setRenderedPage] = useState("loading");
useEffect(() => {
@@ -36,8 +35,6 @@ function App() {
) : renderedPage === "home" ? (
- ) : renderedPage === "signin" ? (
-
) : (
)}
diff --git a/src/content-scripts/hotOSHomePage.ts b/src/content-scripts/hotOSHomePage.ts
new file mode 100644
index 00000000..0ebf3e9e
--- /dev/null
+++ b/src/content-scripts/hotOSHomePage.ts
@@ -0,0 +1,22 @@
+import { checkTokenValidity } from "../utils/fetchOpenSaucedApiData";
+import getAccessToken from "../utils/getAccessToken";
+import setAccessTokenInChromeStorage from "../utils/setAccessToken";
+
+const processHotOSHomePage = async () => {
+ const data = await chrome.storage.sync.get(["os-access-token"]);
+ if (data["os-access-token"]) return;
+ try {
+ const accessToken = getAccessToken();
+ if (!accessToken) return;
+
+ const isValid = await checkTokenValidity(accessToken);
+ if (!isValid) return;
+
+ await setAccessTokenInChromeStorage(accessToken);
+ } catch (error) {
+ console.error("Error processing Hot home page:", error);
+ }
+};
+
+//The local storage takes time to set after the document is idle
+setTimeout(processHotOSHomePage, 1000);
diff --git a/src/pages/signin.tsx b/src/pages/signin.tsx
deleted file mode 100644
index 45c9051f..00000000
--- a/src/pages/signin.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-import React from "react";
-import { checkTokenValidity } from "../utils/fetchOpenSaucedApiData";
-import { BiArrowBack, BiInfoCircle } from "react-icons/bi";
-
-interface SignInProps {
- setRenderedPage: (page: string) => void;
-}
-
-function SignIn({ setRenderedPage }: SignInProps) {
- const [token, setToken] = React.useState("");
-
- const authenticateUser = (token: string) => {
- if (token === "") {
- alert("Please enter a valid token");
- return;
- }
- checkTokenValidity(token)
- .then((valid) => {
- if (valid) {
- chrome.storage.sync.set({ "os-access-token": token }, () => {
- setRenderedPage("home");
- });
- } else {
- alert("Token is invalid");
- }
- })
- .catch((err) => {
- console.log(err);
- alert("An error occurred while authenticating");
- });
- };
-
- return (
-
- setRenderedPage("start")}
- />
-
Sign In
-
- Enter your Personal Access Token to sign in.
-
- window.open(
- "https://docs.opensauced.pizza/contributing/set-up-authentication/",
- "_blank"
- )
- }
- />
-